function js_notification(type,msg){ 
	if(type == 'error'){
		toastr.error(msg, "", {
				showMethod: "fadeIn",
				hideMethod: "fadeOut",
				tapToDismiss : true,
				timeOut: 8000,
				positionClass : "toast-top-center"
		});
	} else if(type == 'success'){
		toastr.success(msg, "", {
				showMethod: "fadeIn",
				hideMethod: "fadeOut",
				tapToDismiss : true,
				closeButton: true,
				positionClass : "toast-top-center",
				timeOut: 8000
		});
	}
	
}

function js_time_notification(msg){ 
	
		toastr.error(msg, "", {
				showMethod: "fadeIn",
				hideMethod: "fadeOut",
				tapToDismiss : true,
				timeOut: 11800000000000,
				positionClass : "toast-top-center"
		});
	
	
}

$(document).on('keypress','.js-number',function(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	 if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;

	 return true;
});

$('.datepicker').datepicker({
        format: 'mm/dd/yyyy',
        endDate: '+0d',
        autoclose: true
    });

$(document).ready(function() {
    var $password = $(".form-control[type='password']");
    var $passwordAlert = $(".password-alert");
    var $requirements = $(".requirements");
    var leng, bigLetter, num, specialChar;
    var $leng = $(".leng");
    var $bigLetter = $(".big-letter");
    var $num = $(".num");
    var $specialChar = $(".special-char");
    var specialChars = "!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?`~";
    var numbers = "0123456789";

    $requirements.addClass("wrong");
	 $password.on("focus", function(){$passwordAlert.show();});

    $password.on("input blur change", function (e) {
        var el = $(this);
        var val = el.val();
        $passwordAlert.show();

        if (val.length < 8) {
            leng = false;
        }
        else if (val.length > 7) {
            leng=true;
        }
        

        if(val.toLowerCase()==val){
            bigLetter = false;
        }
        else{bigLetter=true;}
        
        num = false;
        for(var i=0; i<val.length;i++){
            for(var j=0; j<numbers.length; j++){
                if(val[i]==numbers[j]){
                    num = true;
                }
            }
        }
        
        specialChar=false;
        for(var i=0; i<val.length;i++){
            for(var j=0; j<specialChars.length; j++){
                if(val[i]==specialChars[j]){
                    specialChar = true;
                }
            }
        }

        
        if(leng==true&&bigLetter==true&&num==true&&specialChar==true){
            $(this).addClass("valid").removeClass("invalid");
            $requirements.removeClass("wrong").addClass("good");
            $passwordAlert.removeClass("alert-warning").addClass("alert-success");
        }
        else
        {
            $(this).addClass("invalid").removeClass("valid");
            $passwordAlert.removeClass("alert-success").addClass("alert-warning");

            if(leng==false){$leng.addClass("wrong").removeClass("good");}
            else{$leng.addClass("good").removeClass("wrong");}

            if(bigLetter==false){$bigLetter.addClass("wrong").removeClass("good");}
            else{$bigLetter.addClass("good").removeClass("wrong");}

            if(num==false){$num.addClass("wrong").removeClass("good");}
            else{$num.addClass("good").removeClass("wrong");}

            if(specialChar==false){$specialChar.addClass("wrong").removeClass("good");}
            else{$specialChar.addClass("good").removeClass("wrong");}
        }
        
        
        if(e.type == "blur"){
               // $passwordAlert.hide();
            }
    });
});