// JavaScript Document

function mem_chk(){	

//Start Of Checking
//sh_fname
	
	if(document.sh_frm.sh_fname.value == ""){
		alert("Please enter your Name !");
		document.sh_frm.sh_fname.focus();
		return false;
	}else{
		if(document.sh_frm.sh_fname.value.charCodeAt(0) == 32){
			alert("Invalid Character ! Please Enter A Valid Name !");
			document.sh_frm.sh_fname.value = '';
			document.sh_frm.sh_fname.focus();
			return false;
		}
	}
	
//sh_lname
  /*   if(document.sh_frm.sh_lname.value == ""){
        alert("Please enter your Last Name !");
        document.sh_frm.sh_lname.focus();
        return false;
    }else{
        if(document.sh_frm.sh_lname.value.charCodeAt(0) == 32){
            alert("Invalid Character ! Please Enter A Valid Name !");
            document.sh_frm.sh_lname.value = '';
            document.sh_frm.sh_lname.focus();
            return false;
        }
    }*/
    
//sh_email    
    
	if(document.sh_frm.sh_email.value == ""){
		alert("Please enter your email address !");
		document.sh_frm.sh_email.focus();
		return false;
	}else{
		var atFound = -1;
		var dotFound = -1;
		var charFound = false;    
		var checkStr;
		var splitString

	  	checkStr = document.sh_frm.sh_email.value;
	
	  	splitString = checkStr.split("");
	  	for (var i = 0; i < checkStr.length+1; i++) {
	  		if (splitString[i] == "\"" | splitString[i] == "'") {
	    		alert("Your email address appears invalid.");
	    		document.sh_frm.sh_email.value="";
			    document.sh_frm.sh_email.focus();
	    	}
		    if (splitString[i] < " " | splitString[i] > " ") { charFound = true; }
		    if (splitString[i] == "@") { atFound = i; }
		    if (splitString[i] == ".") { dotFound = i; }
		}
		if (charFound == true) {
			if (atFound > -1) {
				if (dotFound > -1) {
				    if (dotFound < atFound) {
					    alert("Your email address appears invalid.");
					    document.sh_frm.sh_email.value="";
					    document.sh_frm.sh_email.focus();
					    return false
				    } else {
						if ((dotFound-atFound) == 1 | dotFound == (checkStr.length-1) | atFound == 0) {
		    			        alert("Your email address appears invalid.");
		    			        document.sh_frm.sh_email.value="";
		    			        document.sh_frm.sh_email.focus();
		    			        return false;
		    			    }
		    	    }
		    	} else {
			        alert("Your email address appears invalid.");
			        document.sh_frm.sh_email.value="";
			        document.sh_frm.sh_email.focus();
			        return false;
			    }
			} else {
				alert("Your email address appears invalid.");
				document.sh_frm.sh_email.value="";
				document.sh_frm.sh_email.focus();
				return false;
			}	
		}
	}
	
	if(document.sh_frm.sh_email.value.charCodeAt(0) == 32){
		alert("Invalid Character ! Please Enter A Valid Email Address !");
		document.sh_frm.sh_email.value = '';
		document.sh_frm.sh_email.focus();
		return false;
	}
	
//sh_password
    if(document.sh_frm.sh_password.value == ""){
        alert("Please enter your password !");
        document.sh_frm.sh_password.focus();
        return false;
    }else{
        if(document.sh_frm.sh_password.value.length < 6){
            alert("Please enter at least 6 characters for password !");
            document.sh_frm.sh_password.value = '';
            document.sh_frm.sh_password.focus();
            return false;
        }
    }
    
    if(document.sh_frm.sh_password.value.charCodeAt(0) == 32){
        alert("Invalid Character ! Please Enter A Valid Password !");
        document.sh_frm.sh_password.value = '';
        document.sh_frm.sh_password.focus();
        return false;
    }
    
    if(document.sh_frm.sh_conpassword.value == ""){
        alert("Please re-type your password !");
        document.sh_frm.sh_conpassword.focus();
        return false;
    }
    if(document.sh_frm.sh_conpassword.value != document.sh_frm.sh_password.value){
        alert("Both password and confirm password have to be same !");
        document.sh_frm.sh_conpassword.value = '';
        document.sh_frm.sh_conpassword.value = '';
        document.sh_frm.sh_conpassword.focus();
        return false;
    }
	
 //sh_age
     if(document.sh_frm.sh_age.value == ""){
        alert("Please enter your Age!");
        document.sh_frm.sh_age.focus();
        return false;
    }else{
                
        var x=document.sh_frm.sh_age.value;
        if(isNaN(x)){
        alert('Please Key numbers only');
        document.sh_frm.sh_age.value ="";
        document.sh_frm.sh_age.focus();
        return false;
        }
    }

// sh_org
	if(document.sh_frm.sh_org.value == ""){
		alert("Please enter the Organization!");
		document.sh_frm.sh_org.focus();
		return false;
	}
//  sh_phone
          if(document.sh_frm.sh_phone.value == ""){
        alert("Please enter your Phone Number !");
        document.sh_frm.sh_phone.focus();
        return false;
    }else{
                
        var x=document.sh_frm.sh_phone.value;
        if(isNaN(x)){
        alert('Please Key numbers only');
        document.sh_frm.sh_phone.value ="";
        document.sh_frm.sh_phone.focus();
        return false;
        }
    }

 //sh_mob
     if(document.sh_frm.sh_mob.value == ""){
        alert("Please enter your Mobile Number !");
        document.sh_frm.sh_mob.focus();
        return false;
    }else{
                
        var x=document.sh_frm.sh_mob.value;
        if(isNaN(x)){
        alert('Please Key numbers only');
        document.sh_frm.sh_mob.value ="";
        document.sh_frm.sh_mob.focus();
        return false;
        }
    }

 //sh_aad
    if(document.sh_frm.sh_add.value == ""){
        alert("Please enter the Address!");
        document.sh_frm.sh_add.focus();
        return false;
    }
    
 //sh_city    
/*
    if(document.sh_frm.sh_city.value == ""){
        alert("Please enter the City!");
        document.sh_frm.sh_city.focus();
        return false;
    }
    
//sh_state	
    if(document.sh_frm.sh_state.value == ""){
        alert("Please enter the State!");
        document.sh_frm.sh_state.focus();
        return false;
    }*/
 

    
 //sh_country

    if(document.sh_frm.sh_country.value == ""){
		    alert("Please enter the Country!");
		    document.sh_frm.sh_country.focus();
		    return false;
	    }
        
        
//sh_postcode                      
	if(document.sh_frm.sh_postcode.value == ""){
		alert("Please enter your Postcode Number !");
		document.sh_frm.sh_postcode.focus();
		return false;
	}else{				
		var x=document.sh_frm.sh_postcode.value;
		if(isNaN(x)){
		alert('Please Key numbers only');
		document.sh_frm.sh_postcode.value ="";
		document.sh_frm.sh_postcode.focus();
		return false;
		}	
	}
//security_code catpache Bot    
    if (document.sh_frm.security_code.value.length==0){
       alert("Please Enter Security Code!");
       document.sh_frm.security_code.focus();
       return false;
      }   
    
///End of the checking 	
				
}

////this Validate for the Sign in Form

function login_sub(){

//sh_email    
    
    if(document.sh_frm.sh_email.value == ""){
        alert("Please enter your email address !");
        document.sh_frm.sh_email.focus();
        return false;
    }else{
        var atFound = -1;
        var dotFound = -1;
        var charFound = false;    
        var checkStr;
        var splitString

          checkStr = document.sh_frm.sh_email.value;
    
          splitString = checkStr.split("");
          for (var i = 0; i < checkStr.length+1; i++) {
              if (splitString[i] == "\"" | splitString[i] == "'") {
                alert("Your email address appears invalid.");
                document.sh_frm.sh_email.value="";
                document.sh_frm.sh_email.focus();
            }
            if (splitString[i] < " " | splitString[i] > " ") { charFound = true; }
            if (splitString[i] == "@") { atFound = i; }
            if (splitString[i] == ".") { dotFound = i; }
        }
        if (charFound == true) {
            if (atFound > -1) {
                if (dotFound > -1) {
                    if (dotFound < atFound) {
                        alert("Your email address appears invalid.");
                        document.sh_frm.sh_email.value="";
                        document.sh_frm.sh_email.focus();
                        return false
                    } else {
                        if ((dotFound-atFound) == 1 | dotFound == (checkStr.length-1) | atFound == 0) {
                                alert("Your email address appears invalid.");
                                document.sh_frm.sh_email.value="";
                                document.sh_frm.sh_email.focus();
                                return false;
                            }
                    }
                } else {
                    alert("Your email address appears invalid.");
                    document.sh_frm.sh_email.value="";
                    document.sh_frm.sh_email.focus();
                    return false;
                }
            } else {
                alert("Your email address appears invalid.");
                document.sh_frm.sh_email.value="";
                document.sh_frm.sh_email.focus();
                return false;
            }    
        }
    }
    
    if(document.sh_frm.sh_email.value.charCodeAt(0) == 32){
        alert("Invalid Character ! Please Enter A Valid Email Address !");
        document.sh_frm.sh_email.value = '';
        document.sh_frm.sh_email.focus();
        return false;
    }
    
//sh_password
    if(document.sh_frm.sh_password.value == ""){
        alert("Please enter your password !");
        document.sh_frm.sh_password.focus();
        return false;
    }else{
        if(document.sh_frm.sh_password.value.length < 6){
            alert("Please enter at least 6 characters for password !");
            document.sh_frm.sh_password.value = '';
            document.sh_frm.sh_password.focus();
            return false;
        }
    }
    
    if(document.sh_frm.sh_password.value.charCodeAt(0) == 32){
        alert("Invalid Character ! Please Enter A Valid Password !");
        document.sh_frm.sh_password.value = '';
        document.sh_frm.sh_password.focus();
        return false;
    }

//security_code catpache Bot    
    if (document.sh_frm.security_code.value.length==0){
       alert("Please Enter Security Code!");
       document.sh_frm.security_code.focus();
       return false;
      }   
    
///End of the checking     
                
}



//retrieve password

function retrieve()
{

//sh_email    
    
    if(document.sh_frm.sh_email.value == ""){
        alert("Please enter your email address !");
        document.sh_frm.sh_email.focus();
        return false;
    }else{
        var atFound = -1;
        var dotFound = -1;
        var charFound = false;    
        var checkStr;
        var splitString

          checkStr = document.sh_frm.sh_email.value;
    
          splitString = checkStr.split("");
          for (var i = 0; i < checkStr.length+1; i++) {
              if (splitString[i] == "\"" | splitString[i] == "'") {
                alert("Your email address appears invalid.");
                document.sh_frm.sh_email.value="";
                document.sh_frm.sh_email.focus();
            }
            if (splitString[i] < " " | splitString[i] > " ") { charFound = true; }
            if (splitString[i] == "@") { atFound = i; }
            if (splitString[i] == ".") { dotFound = i; }
        }
        if (charFound == true) {
            if (atFound > -1) {
                if (dotFound > -1) {
                    if (dotFound < atFound) {
                        alert("Your email address appears invalid.");
                        document.sh_frm.sh_email.value="";
                        document.sh_frm.sh_email.focus();
                        return false
                    } else {
                        if ((dotFound-atFound) == 1 | dotFound == (checkStr.length-1) | atFound == 0) {
                                alert("Your email address appears invalid.");
                                document.sh_frm.sh_email.value="";
                                document.sh_frm.sh_email.focus();
                                return false;
                            }
                    }
                } else {
                    alert("Your email address appears invalid.");
                    document.sh_frm.sh_email.value="";
                    document.sh_frm.sh_email.focus();
                    return false;
                }
            } else {
                alert("Your email address appears invalid.");
                document.sh_frm.sh_email.value="";
                document.sh_frm.sh_email.focus();
                return false;
            }    
        }
    }
    
    if(document.sh_frm.sh_email.value.charCodeAt(0) == 32){
        alert("Invalid Character ! Please Enter A Valid Email Address !");
        document.sh_frm.sh_email.value = '';
        document.sh_frm.sh_email.focus();
        return false;
    }
}   
////


function login_sub_down(){

//sh_email    
if(document.sh_frm.sh_email.value == ""){
            alert("Please enter the Username!");
            document.sh_frm.sh_email.focus();
            return false;
        }   
  
    
//sh_password
    if(document.sh_frm.sh_password.value == ""){
        alert("Please enter your password !");
        document.sh_frm.sh_password.focus();
        return false;
    }else{
        if(document.sh_frm.sh_password.value.length < 6){
            alert("Please enter at least 6 characters for password !");
            document.sh_frm.sh_password.value = '';
            document.sh_frm.sh_password.focus();
            return false;
        }
    }
    
    if(document.sh_frm.sh_password.value.charCodeAt(0) == 32){
        alert("Invalid Character ! Please Enter A Valid Password !");
        document.sh_frm.sh_password.value = '';
        document.sh_frm.sh_password.focus();
        return false;
    }

//security_code catpache Bot    
    if (document.sh_frm.security_code.value.length==0){
       alert("Please Enter Security Code!");
       document.sh_frm.security_code.focus();
       return false;
      }   
    
///End of the checking     
                
}
