 //************remove error/ success massage*************//
  
function remove_hs_message(){
	
	setTimeout(function(){ 
		$(".hs_message").removeClass("open_alert hs_error hs_success");
		$('.popup_message').text('');  }, 3000);
}
 
//**************remove message end************************//
 
 
//**********login form validation**********//
 function validationfunction(){
	var baseurl =$("#baseurl").val(); 
	var user_email= $.trim($("#uemail").val());
    var user_password= $.trim($("#upassword").val());
	var isChecked = $("#user_remember").is(":checked");
	if (isChecked == true) {
	   
		var user_remember = 1;
	 
	} else {
		var user_remember = 0;
	   
	}
	
    var pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$";
    var error=0;
	 
  
	if (user_email == "")
	{
		$(".hs_message").addClass("open_alert hs_error");
		$("#popup_message").text('Please enter email Address');
		error++;
	}else if (!user_email.match(pattern))                
	{
		$(".hs_message").addClass("open_alert hs_error");
		$("#popup_message").text('Please enter a valid e-mail address'); 
		error++;
	}else if (user_password == "")                       
	{
		$(".hs_message").addClass("open_alert hs_error");
		$("#popup_message").text('Please enter your password'); 
		error++;
	}else if(user_password.length<6)
	{  
		$(".hs_message").addClass("open_alert hs_error");
		$("#popup_message").text('Password must be at least 6 characters long'); 
		error++;
	} 
	
	if(error == 0){
		
		jQuery.ajax({
		type: "POST",
		url: baseurl + "login/login_user",
		data: {email: user_email, pwd: user_password, u_remeber: user_remember},
		success: function(resp) {
			 
					if(resp == 0){
						$(".hs_message").addClass("open_alert hs_error");
						$("#popup_message").text('email and password does not matched'); 
					 }else if(resp == 1){
						$(".hs_message").addClass("open_alert hs_success");
						$("#popup_message").text('login successfull');	
						window.location.href = baseurl + "admin/dashboard";
					}else if(resp == 2){
						$(".hs_message").addClass("open_alert hs_success");
						$("#popup_message").text('login successfull');	
						window.location.href = baseurl + "home";
					}else if(resp == 3){
						$(".hs_message").addClass("open_alert hs_error");
						$("#popup_message").text('Please, Activate Your Account');	
					}  
											
				}
		}); 
	}
	remove_hs_message();  
 }  
