<!-- 
var errorVal = false;
function checklogin(){
   if($("#useremail").val()==''){
       alert(getalerterrorMssage("email"));
       $("#useremail").focus();
       errorVal = true;
       return false;
   }
    if($("#passwrd").val()==''){
       alert(getalerterrorMssage("passwordpopup"));
       $("#passwrd").focus()
       errorVal = true;
       return false;
   }
   
       onclickLogin('UserLogin','errorLogin')
        return false;
   
}

function onclickLogin(frmName,divID) {
    
      
 	urlva = "users/login";
       
 	var frm = "#"+frmName;
 	 $(frm).ready(function(){
		dataString = $(frm).serialize();
		$.ajax({
		type: "POST",
		url: siteurl+urlva,
		data: dataString,
		dataType: "",
		success: function(data) {
                      
 			ur = data.split("http://");
                        ur1 = "http://"+ur[1];
			if(ur1.indexOf('users/login/')!=-1){
				 Path = document.URL 
				 ec = Base64.encode(Path)
                                document.body.removeChild(divCenter);
    				showloginbox(ec)
                               
			}else{
                      
  			 location.href = ur1;
                       
                         
			}
                       
//                        $("#logpoup").html(data);
                    	
                        
  		}
 	});
 		return false;			
 	});

}
function checkemail(){
   var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
     if($("#email").val()=='') {
           alert("Please fill the email.");
             $("#email").focus();
           return false;
       }
       if(!emailReg.test($("#email").val())) {
            alert("Please fill valid email.");
             $("#email").focus();
             return false;
        }
   
    
   
       onclickforgot('UserLogin','errorLogin')
        return false;
   
}

function onclickforgot(frmName,divID) {
    
      
 	var urlva = "users/forgotpassword/";
			var frm = "#"+frmName;
			
	$(frm).ready(function(){
        dataString = $(frm).serialize();
		
		//alert(dataString)
		$.ajax({
		type: "POST",
		url: siteurl+urlva+"/",
		data: dataString,
		dataType: "",
                success: function(data) {
                   window.fbAsyncInit = function() {
			FB.init({
			  appId   : '210358048996705',
			  session : null, // don't refetch the session when PHP already has it
			  status  : true, // check login status
			  cookie  : true, // enable cookies to allow the server to access the session
			  xfbml   : true // parse XFBML
			});
	
			// whenever the user logs in, we refresh the page
			 
		  };
	
		  (function() {
			var e = document.createElement('script');
			e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
			e.async = true;
			document.getElementById('fb-root').appendChild(e);
		  }());
                        $("#logpoup").html(data);
                    					}
			});
 		return false;			
 	});

}
/**
 * function use to open thte registration popup
 */

function showregistrationbox(){
        windowheight =  getScrollHeight();
        windowwidth =  getScrollWidth();
          
        centerheight = (windowheight / 30)
        centerwidth = ((windowwidth / 2) - 340);
        url = "users/registration/";
       
        
        $("#signup").ready(function(){
            $.ajax({
                url: siteurl+url,
                success: function(data)  {   
                showCenterfixedPosition(centerwidth,centerheight,'logpoup',data);
                showHeight('logpoup');
                window.fbAsyncInit = function() {
			FB.init({
			  appId   : '210358048996705',
			  session : null, // don't refetch the session when PHP already has it
			  status  : true, // check login status
			  cookie  : true, // enable cookies to allow the server to access the session
			  xfbml   : true // parse XFBML
			});
	
			// whenever the user logs in, we refresh the page
			 
		  };
	
		  (function() {
			var e = document.createElement('script');
			e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
			e.async = true;
			document.getElementById('fb-root').appendChild(e);
		  }());
                    if(data.indexOf("flashMessage")!=-1){ 
                        $(".LoginBox").css('min-height','366px');
                        $(".logpoup").css('top','70px');
                        $(".LoginBoxContent").css('padding-top','22px');
                       
                    }

                }
            });
 		return false;			
 	});
}
/**
 * function use to open thte forgot password popup
 */

function forgot_password(){
        windowheight =  getScrollHeight();
        windowwidth =  getScrollWidth();
          
        centerheight = (windowheight / 30)
        centerwidth = ((windowwidth / 2) - 340);
        url = "users/forgotpassword/";
        $("#forgotpopup").ready(function(){
            $.ajax({
                url: siteurl+url,
                success: function(data)  {   
				
				window.fbAsyncInit = function() {
			FB.init({
			  appId   : '210358048996705',
			  session : null, // don't refetch the session when PHP already has it
			  status  : true, // check login status
			  cookie  : true, // enable cookies to allow the server to access the session
			  xfbml   : true // parse XFBML
			});
	
			// whenever the user logs in, we refresh the page
			 
		  };
	
		 				 (function() {
			var e = document.createElement('script');
			e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
			e.async = true;
			document.getElementById('fb-root').appendChild(e);
		  }());
		  
                showCenterfixedPosition(centerwidth,centerheight,'logpoup',data);
                showHeight('logpoup');
                
                    if(data.indexOf("flashMessage")!=-1){ 
                        $(".LoginBox").css('min-height','366px');
                        $(".logpoup").css('top','70px');
                        $(".LoginBoxContent").css('padding-top','22px');
						
						 
                       
                    }
                }
            });
 		return false;			
 	});
}


function showHeight(divid) {
    
         h = $("#"+divid).height()+10; 
        $("#loginBoxUser").css('min-height',h+'px')
}
function changeHeight(divId)
{
	 h = $("#"+divId).height()+10; 
     $("#"+divId).css('min-height',h+'px')
}

/**
 * function use to check the user registation
 */
function checkregistrationlogin (aForm,divID) {
   var bool = true;  
     for (var i=0; i < aForm.elements.length; i++) {
         returnvalue = checkFieldTask(aForm.elements[i].id)
        bool  =  returnvalue;
     }
		if(bool==false)
		{
			showHeight(divID);
		}
     return bool;  
}

/**
 * function use to check the files that provides
 * aFieldName as define as the id of the selected input box
 * it return the boolian value true and false
 * if field value not = blank the it remove the error message from the pages
 * after that it break the loop
 */
var checkval = true;
 function checkFieldTask (aFieldName) {  
      
     
     switch(aFieldName){
        case "first_name": {
                 if ($("#"+aFieldName).val()=="") {  
                      $("#error_"+aFieldName).html(getalerterrorMssage(aFieldName))
                      checkval = false;
                 }else{ 
                     $("#error_"+aFieldName).html('')
                     checkval = true;
                 }
                 break;
        }
        case "last_name": {
                 if ($("#"+aFieldName).val()=="") {  
                      $("#error_"+aFieldName).html(getalerterrorMssage(aFieldName))
                      checkval =  false;
                      
                 }else{
                     $("#error_"+aFieldName).html('')
                      checkval = true;
                 }
                  break;
        }
        case "useremail": {
              if ($("#"+aFieldName).val()=="") {  
                     $("#error_"+aFieldName).html(getalerterrorMssage(aFieldName))
                     checkval = false;
                 }else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById(aFieldName).value))) {
                            $("#error_"+aFieldName).html(getalerterrorMssage("validemail"))
                              checkval = false;
                 } else{
                     $("#error_"+aFieldName).html('')
                      checkval = true;
                     
                 }
                  break;
        }
        case "passwrd": {
                 if ($("#"+aFieldName).val()=="") {  
                      $("#error_"+aFieldName).html(getalerterrorMssage(aFieldName))
                      checkval = false;
                 }else{
                     $("#error_"+aFieldName).html('')
                      checkval = true;
                 }
                  break;
        }
        case "confpasswrd": {
                 if ($("#"+aFieldName).val()=="") {  
                      $("#error_"+aFieldName).html(getalerterrorMssage(aFieldName))
                      checkval = false;
                 } else if($("#"+aFieldName).val()!=document.getElementById("passwrd").value) {  
                       
                      $("#error_"+aFieldName).html(getalerterrorMssage("confpasswrd_match"))
                      checkval = false;
                 }else{
                     $("#error_"+aFieldName).html('')
                      checkval = true;
                 }
                  break;
        }
     }
     return checkval;
 } 
 /**
  * function use to 
  */
 function checkField(aField){
     
     return checkFieldTask(aField);  
 }
 
 function checkSetting(){
     //alert('fg');
     var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
     if($("#first_name").val()=='') {
           alert("Please fill the first name.");
             $("#first_name").focus();
           return false;
       }
       if($("#last_name").val()=='') {
           alert("Please fill the last name.");
             $("#last_name").focus();
           return false;
       }
       if($("#status").val()==1){
           if($("#email").val()=='') {
               alert("Please fill the valid email.");
                 $("#email").focus();
               return false;
           }
           if(!emailReg.test($("#email").val())) {
                alert("Please fill valid email.");
                 $("#email").focus();
                 return false;
            }
       }
       if($("#year").val()=='') {
           alert("Please fill the year.");
             $("#year").focus();
           return false;
       }
       if($("#month").val()=='') {
           alert("Please fill the month.");
             $("#month").focus();
           return false;
       }
       if($("#date").val()=='') {
           alert("Please fill the date.");
             $("#date").focus();
           return false;
       }
       if($("#password").val()!='') {
           if(document.getElementById('password').value.length < 6){
             alert("Please enter at least 6 charcter .");
             $("#password").focus();
             return false;
           }
           
       }
	   if($("#password").val()!='') {
       if($("#confpasswrd").val()=='') {
           alert("Please fill same value as password.");
             $("#confpasswrd").focus();
           return false;
       }
	   }
	   
       if($("#password").val()!='') {
	   if($("#confpasswrd").val()!='') {
           if(document.getElementById('password').value != document.getElementById('confpasswrd').value){
                  alert("Please enter same pasword.");
                 $("#confpasswrd").focus();
                 return false; 
               }
       } 
	   }
         return true;
   
 } 
 function showemail(chvalue){
     
     value=document.getElementById('status').value;
     if(value==1){
           $("#showEmail").css('display','none')
           document.getElementById('status').value='0';
       }else{
         $("#showEmail").css('display','')
         document.getElementById('status').value='1';
       }
 }

