var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-. ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 7;

function trim(sString) 
{
  while (sString.substring(0,1) == ' ')
  {
    sString = sString.substring(1, sString.length);
  }
  while (sString.substring(sString.length-1, sString.length) == ' ')
  {
    sString = sString.substring(0,sString.length-1);
  }
  return sString;
}

function emailValidate(str){
	
    var  filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
    if (filter.test(str))
	{
        testresults=true;
	}
    else{
       testresults=false;
    }

    return (testresults);
}

function CheckImHere() {
	boxes = document.RegisterPage.im_here.length
	txt = ""
	for (i = 0; i < boxes; i++) {
		if (document.RegisterPage.im_here[i].checked) {
			txt = txt + document.RegisterPage.im_here[i].value + " "
		}
	}

	if (txt == "") {
		return false;
	}
	else {
		return true
	}

}


function fraud_validate() 
{
		
	//alert('hi');
	if(trim(document.getElementById("con_level").value)=="") 
	{
		alert("Please enter a fraud confidence value (1- 10)");
		return false;
	}
}


function validateForm() {
	

	if(trim(document.getElementById("username").value).length<5) {
		alert("Username should be at least 55 characters");
		return false;
	}

	if(trim(document.getElementById("firstname").value)=="") {
		alert("Please Enter First Name");
		return false;
	}

	if(trim(document.getElementById("lastname").value)=="") {
		alert("Please Enter Last Name");
		return false;
	}

	if(emailValidate(document.getElementById("email1").value)==false) {
		alert("Please Enter Valid Email Address");
		return false;
	}

	if(emailValidate(document.getElementById("email2").value)==false) {
		alert("Email Confirmation Error: Please Re-type Your Email Address");
		return false;
	}

	if(document.getElementById("email1").value!=document.getElementById("email2").value) {
		alert("Email Confirmation Failed, Please enter same mail ids");
		return false;
	}

	if(trim(document.getElementById("pass1").value).length<5) {
		alert("Password should be at least 5 characters");
		return false;
	}
	
	if(document.getElementById("pass1").value!=document.getElementById("pass2").value) {
		alert("Password Confirmation Failed, Please enter same passwords");
		return false;
	}

	if(document.getElementById("dob_month").value=="0" || document.getElementById("dob_day").value=="0" || document.getElementById("dob_year").value=="0") {
		alert("Please Enter Your Birthday");
		return false;
	}

	if(checkInternationalPhone(trim(document.getElementById("phone").value))==false) {
		alert("Please Enter Valid Phone Number.");
		return false;
	}

	if(trim(document.getElementById("street").value)=="") {
		alert("Please Enter a Valid Street Address");
		return false;
	}

	if(trim(document.getElementById("city").value)=="") {
		alert("Please Enter Valid City");
		return false;
	}

	if(trim(document.getElementById("postal").value)=="") {
		alert("Please Enter a Valid Zip/Postal Code");
		return false;
	}
	
	if(document.getElementById("state").value=="") {
		alert("Please Select A State");
		return false;
	}

	if(document.getElementById("country").value=="") {
		alert("Please Select A Country");
		return false;
	}

	if(CheckImHere()==false) {
		alert("Please Select at least One Reason For Visiting Peep The Scene");
		return false;
	}

	if(document.getElementById("captcha").value=="") {
		alert("Please Enter Verification Code");
		return false;
	}

	if(document.getElementById("agreed").checked==false) {
		alert("Please Agree To Our Terms of Service and Privacy Policy Before Proceeding.");
		return false;
	}
	
	return true;
}



function focYrs(field, event) {
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
if (keyCode == 13)
{
document.login.submit();
}
}


function validate_ck_one() {
	
	//alert(document.getElementById("country").value);
	
	if(trim(document.getElementById("name").value).length<5) {  // name
		alert("Name should be at least 5 characters.");
		return false;
	}
	if(trim(document.getElementById("add1").value)=="") { // address
		alert("Please Enter Address.");
		return false;
	}
	


	if(trim(document.getElementById("city").value)=="") { //city
		alert("Please Enter Valid City.");
		return false;
	}
		if(document.getElementById("state").value=="") {// state
		alert("Please Select A State.");
		return false;
	}	
	if(trim(document.getElementById("zip").value)=="") { // zip
		alert("Please Enter Valid Zip/Postal Code."); 
		return false;
	}
	
if(document.getElementById("country").value=="") { // country
		alert("Please Select A Country."); 
		return false;
	}
	if(trim(document.getElementById("phone").value)=="") { // phone
		alert("Please Enter Phone Number.");
		return false;
	}
if(trim(document.getElementById("street").value)=="") {
		alert("Please Enter a Valid Street Address.");             
		return false;
	}


	
	return true;
}


function card_value_ck() 
{
	
	if(trim(document.getElementById("credit_card").value)=="Visa") 
		{
		
		if(trim(document.getElementById("credit_card_no").value).length<13) 
			{  // name
			alert("You must input at least 13 numerical characters.");
			return false;
			}
			
		}
	if(trim(document.getElementById("credit_card").value)=="MasterCard") 
		{
		
		if(trim(document.getElementById("credit_card_no").value).length<16) 
			{  // name
			alert("You must input at least 16 numerical characters.");
			return false;
			}
			
		}
	if(trim(document.getElementById("credit_card").value)=="Discover") 
		{
		
		if(trim(document.getElementById("credit_card_no").value).length<16) 
			{  // name
			alert("You must input at least 16 numerical characters.");
			return false;
			}
			
		}
	if(trim(document.getElementById("credit_card").value)=="American_Express") 
		{
		
		if(trim(document.getElementById("credit_card_no").value).length<15) 
			{  // name
			alert("You must input at least 15 numerical characters.");
			return false;
			}
			
		}
	if(trim(document.getElementById("credit_card").value)=="Diners_Club") 
		{
		
		if(trim(document.getElementById("credit_card_no").value).length<14) 
			{  // name
			alert("You must input at least 14 numerical characters.");
			return false;
			}
			
		}
	if(trim(document.getElementById("credit_card").value)=="JCB") 
		{
		
		if(trim(document.getElementById("credit_card_no").value).length<14) 
			{  // name
			alert("You must input at least 14 numerical characters.");
			return false;
			}
			
		}


}
function validate_ck_two() {
	
	
	
	/*if ((!document.getElementById('radio1').checked) && (!document.getElementById('radio2').checked)&& (!document.getElementById('radio3').checked)) 
	{
		alert ("Please Select a Premium Type!!");
		document.getElementById('radio1').focus();
		return false;
	}*/
	
	//alert('hi');
	//alert(document.getElementById("cvc").value);
	
	/*if ((!document.getElementById('radio3').checked)) 
	{
		alert ("Please Select a Premium Type!!");
		document.getElementById('radio1').focus();
		return false;
	}*/
		
	if(trim(document.getElementById("credit_card").value)=="") {
		alert("Please Select Credit Card.");
		return false;
	}

	

	if(trim(document.getElementById("credit_card_no").value)=="") {
		alert("Please enter a valid credit card number.");
		return false;
	}
	if(trim(document.getElementById("exp_year").value)==0) {
		alert("Please enter a valid expiration date.");
		return false;
	}
	if(trim(document.getElementById("exp_month").value)==0) {
		alert("Please enter a valid expiration date.");
		return false;
	}
	if(trim(document.getElementById("cvc").value)=="") {
		alert("Please enter a valid Security Code.");
		return false;
	}
	


	
	
	
	return true;
}


function acck() {
	
	//alert('hi');...................................................................................................

	}
function checkPassword(){
	if((document.getElementById("password").value!="")&& (document.getElementById("firstname").value=="")&& (document.getElementById("lastname").value=="")&& (document.getElementById("email1").value=="")&& (document.getElementById("dob_month").value=="0") && (document.getElementById("dob_day").value=="0") && (document.getElementById("dob_year").value=="0")&& (document.getElementById("postal").value=="")&& (document.getElementById("captcha").value==""))
																																																																																																												  {alert('Please confirm which user you are changing the password for');
																																																																																																												    return false;																																																																																																										}
																																																																																																												  else{
																																																																																																													  return true;} 
																																																																																																												
	}

function validateForm1() {
	
	if(trim(document.getElementById("username").value)=="") {
		ShowPopup('Error', "Please Enter Username", 'error');
		return false;
	}

	if(trim(document.getElementById("firstname").value)=="") {
		ShowPopup('Error', "Please Enter First Name", 'error');
		return false;
	}

	if(trim(document.getElementById("lastname").value)=="") {
		ShowPopup('Error', "Please Enter Last Name", 'error');
		return false;
	}
	
	if((document.getElementById("password").value=="")&&(document.getElementById("repassword").value==""))	{ 
		ShowPopup('Error', "Please enter valid passwordd.", 'error');
		return false;
	}
	
	if(document.getElementById("repassword").value.length<5) {
		document.getElementById("user_check_password").innerHTML="<font color='red'>Password length should be more then 6!!</font>";
		document.getElementById("repassword").focus();
		return false;
	}
			
	
	if((document.getElementById("password").value)!=(document.getElementById("repassword").value)) {
		document.getElementById("user_check_password").innerHTML="<font color='red'>Password does not match !!</font>";
		document.getElementById("repassword").focus();
		return false;
	}		
	/*if(trim(document.getElementById("password").value)=="") {
		alert("Please Enter Valid Password");
		return false;
	}*/

	//if(document.getElementById("signup_type").value=="0") {
		//alert("Please Choose Account Type");
	//	return false;
	//}
	
	if(emailValidate(document.getElementById("email1").value)==false) {
		ShowPopup('Error', "Please Enter Valid Email Address", 'error');
		return false;
	}

	if(document.getElementById("dob_month").value=="0" || document.getElementById("dob_day").value=="0" || document.getElementById("dob_year").value=="0") {
		ShowPopup('Error', "Please Enter Your Birthday", 'error');
		return false;
	}

	if(trim(document.getElementById("postal").value)=="") {
		ShowPopup('Error', "Please Enter a Valid Zip/Postal Code", 'error');
		return false;
	}
	
	if(document.getElementById("captcha").value=="") {
		ShowPopup('Error', "Please Enter Verification Code", 'error');
		return false;
	}

	if(document.getElementById("agreed").checked==false) {
		ShowPopup('Error', "Please Agree To Our Terms of Service and Privacy Policy Before Proceeding.", 'error');
		return false;
	}
	// new
	
	
	
	xmlHttp=GetXmlHttpObject();
		
			if (xmlHttp==null){
			   ShowPopup('Error', "Your browser does not support AJAX!", 'error');
			   return;
			}

	return true;
}

// code by masud 




// code by masud end
// code by shaukat

/*function worning() 
{
	
	if(trim(document.getElementById("firstname").value)=="" && trim(document.getElementById("lastname").value)=="" && emailValidate(document.getElementById("email1").value)==false && trim(document.getElementById("postal").value)=="" && document.getElementById("captcha").value=="" && document.getElementById("dob_month").value=="0" && document.getElementById("dob_day").value=="0" && document.getElementById("dob_year").value=="0" && document.getElementById("referralcode").value=="")
	{
		alert("Which Account You'd Like To Change The Password For");
		return false;
	} 
}*/
function retypepwd() 
{
	
	if(trim(document.getElementById("repassword").value)=="")
	{
		alert("Which Account You'd Like To Change The Password For");
		return false;
	} 	
	/*if(document.getElementById("dob_month").value=="0" || document.getElementById("dob_day").value=="0" || document.getElementById("dob_year").value=="0") {
		alert("Please Enter Your Birthday");
		return false;
	}*/


}

function ckoldpass()
{
//alert('hi');

 	xmlHttp=GetXmlHttpObject();

    if (xmlHttp==null){
       alert ("Your browser does not support AJAX!");
       return;
    }
    
    var url="ajaxCheckoldpass.php?useroldpass="+document.getElementById("oldpasswd").value;
	
    //parameters passed here
	//alert(url);
    xmlHttp.onreadystatechange=checkUserAvailabilityStateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);


}


// end code by shaukat



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function GetXmlHttpObject() {
    var xmlHttp=null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    } catch (e) {
        // Internet Explorer
        try {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

function checkUserAvailabilityStateChanged() 
{

    if (xmlHttp.readyState==4) {
        //logic goes here
	if(xmlHttp.responseText=="avaialable") {
		//alert("available");
		document.getElementById("user_check_text").innerHTML="<font color='green'>Username Available</font>";
		document.getElementById("user_value_sub").disabled=false;
	} else {
		//alert("unavailable");
		document.getElementById("user_check_text").innerHTML="<font color='red'>Username is already registered</font>";
		document.getElementById("user_value_sub").disabled=true;
	}
    } else if(xmlHttp.readyState<4) {
		document.getElementById("user_check_text").innerHTML="<font color='black'>Checking Username Availability</font>";
    }
}

function checkUserAvailability(value)
{
	if(document.getElementById("username").value=="")
	{
	document.getElementById("user_check_text").innerHTML="<font color='red'>Please enter a valid user name</font>";	
	document.getElementById("user_value_sub").disabled=true;
	return;
	}
	
    xmlHttp=GetXmlHttpObject();

    if (xmlHttp==null){
       alert ("Your browser does not support AJAX!");
       return;
    }
    
    var url="ajaxCheckUser.php?user="+document.getElementById("username").value+"&name="+value;
	
    //parameters passed here
//alert(url);
    xmlHttp.onreadystatechange=checkUserAvailabilityStateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function checkEmailAvailabilityStateChanged() 
{
	

    if (xmlHttp.readyState==4) {
       
		//alert(xmlHttp.responseText);
		//logic goes here
		if(xmlHttp.responseText=="available") {
			
			document.getElementById("email_check_text").innerHTML="<font color='green'>Email Available</font>";
		} else {
			//alert("unavailable");
			document.getElementById("email_check_text").innerHTML="<font color='red'>Email Already Registered !!</font>";
		}
    } else if(xmlHttp.readyState<4) {
		document.getElementById("email_check_text").innerHTML="<font color='black'>Checking Email Availability</font>";
    }
}

function checkEmailAvailability()
{
	//alert('hi');
	
    if(!emailValidate(document.getElementById("email1").value)) 
	{		
		document.getElementById("email_check_text").innerHTML="<font color='red'>Please Enter Valid Email !!</font>";
		return;
    }

    xmlHttp=GetXmlHttpObject();

    if (xmlHttp==null){
       alert ("Your browser does not support AJAX!");
       return;
    }
    
    var url="ajaxCheckEmail.php?email="+document.getElementById("email1").value;
	//alert(url);
	 //parameters passed here

    xmlHttp.onreadystatechange=checkEmailAvailabilityStateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function checkUsernameAvailability() {
	if (!(/^[\w]+$/).test($('#username').val())) {
		$('#username_check_text').html('<font color="red">Please Enter Valid Username !!</font>');
	} else {
		jQuery.post(
			'ajaxCheckUsername.php',
			{username: $('#username').val()},
			function (data) {
				$('#username_check_text').html(data);
			}
		);
	}
}

// masud...................................................chkpassword..................................................start.....
function checkPasswordAvailability()
{
/*	//alert('hi');
	
    if(!emailValidate(document.getElementById("email1").value)) 
	{		
		document.getElementById("email_check_text").innerHTML="<font color='red'>Please Enter Valid Email !!</font>";
		return;
    }*/

    xmlHttp=GetXmlHttpObject();

    if (xmlHttp==null){
       alert ("Your browser does not support AJAX!");
       return;
    }
    
    var url="ajaxCheckPassword.php?currentpassword="+document.getElementById("currentpassword").value;
	//alert(url);
	 //parameters passed here

    xmlHttp.onreadystatechange=checkEmailAvailabilityStateChangedd;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function checkEmailAvailabilityStateChangedd() 
{
	

    if (xmlHttp.readyState==4) {
       
		//alert(xmlHttp.responseText);
		//logic goes here
	if(xmlHttp.responseText=="available")
	     {
			
		document.getElementById("password_check_text").innerHTML="<font color='green'></font>";
		document.getElementById("commtitlee").disabled=false;
		} 
		else {
			//alert("unavailable");
		 
	   document.getElementById("password_check_text").innerHTML="<font color='red'>Password is not correct</font>";
       document.getElementById("commtitlee").disabled=true;
		     }
         } 
	   else if(xmlHttp.readyState<4) {	
		document.getElementById("password_check_text").innerHTML="<font color='black'>Checking Password</font>";
    }
}
// masud...................................................chkpassword..................................................end........

function reloadCaptcha() {
	document.captcha_img.src="includes/captcha/cp/visual-captcha.php?var="+Math.random();
}

function checkInternationalPhone(strPhone){
     
    if(strPhone.indexOf("+")>0 || countOfChar(strPhone,"+")>1) return false;
    for (i = 0; i < strPhone.length; i++) {   
        if(strPhone.charAt(i)=="." && i+1==strPhone.length) return false;
        if(strPhone.charAt(i)=="." && strPhone.charAt(i+1)==".") return false;
    }
    if(!validBracketing(strPhone)) return false;
    
    s=stripCharsInBag(strPhone,validWorldPhoneChars);
    return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function validBracketing(strPhone) {
     
    
    if(countOfChar(strPhone,"(")!=countOfChar(strPhone,")")) return false;
    if(strPhone.indexOf("(")>strPhone.indexOf(")")) return false;
    
    for (i = 0; i < strPhone.length; i++) {   
        if(strPhone.charAt(i)=="(" && !isInteger(trim(strPhone.charAt(i+1))) ) {
            return false;
        }
    }

    
    return true;
}

function countOfChar(strPhone,char1) {
   var count=0;
   for (i = 0; i < strPhone.length; i++) {   
        if(strPhone.charAt(i)==char1) count++;
   }

   return count;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function checkphno()
{
if(trim(document.getElementById("phone").value).length<10) {
		alert("Phone Number should be at least 10 characters");
		return false;
	}	
}

function validateForm2() {
	//alert('masud');
			if(trim(document.getElementById("signup_type").value)=="") { // account type
			alert("Please Select Account Type");
			return false;
	}


	/*if(document.getElementById("username").value).length<5) {*/ // user name
		if(trim(document.getElementById("username").value)=="") {	
		alert("Please enter a valid username");
		return false;
	}

	if(trim(document.getElementById("firstname").value)=="") {
		alert("Please Enter First Name");
		return false;
	}

	if(trim(document.getElementById("lastname").value)=="") {
		alert("Please Enter Last Name");
		return false;
	}

	if(emailValidate(document.getElementById("email1").value)==false) {
		alert("Please Enter Valid Email Address");
		return false;
	}

	if(emailValidate(document.getElementById("email2").value)==false) {
		alert("Email Confirmation Error: Please Re-type Your Email Address");
		return false;
	}

	if(document.getElementById("email1").value!=document.getElementById("email2").value) {
		alert("Email Confirmation Failed, Please enter same mail ids");
		return false;
	}

	if(document.getElementById("dob_month").value=="0" || document.getElementById("dob_day").value=="0" || document.getElementById("dob_year").value=="0") {
		alert("Please Enter Your Birthday");
		return false;
	}

	if(checkInternationalPhone(trim(document.getElementById("phone").value))==false) {
		alert("Please Enter Valid Phone Number.");
		return false;
	}
	
	if(trim(document.getElementById("street").value)=="") {
		alert("Please Enter a Valid Street Address");
		return false;
	}
if(trim(document.getElementById("city").value)=="") {
		alert("Please Enter Valid City");
		return false;
	}
	
	if(document.getElementById("state").value=="") {
		alert("Please Select A State/Province");
		return false;
	}
if(trim(document.getElementById("postal").value)=="") {
		alert("Please Enter a Valid Zip/Postal Code");
		return false;
	}
		if(document.getElementById("country").value=="") {
		alert("Please Select A Country");
		return false;
	}
	
	if ((!document.getElementById('male').checked) && (!document.getElementById('female').checked)) 
	{
		alert ("Please Select A Gender");
		document.getElementById('male').focus();
		return false;
	}
	
	
	

	
	
	


	if(CheckImHere()==false) {
		alert("Please Select at least One Reason For Visiting Peep The Scene");
		return false;
	}
	return true;
}
function validateForm3() {
	

	if(trim(document.getElementById("username").value) == "") {
		alert("Please Enter Username");
		return false;
	}

	if(trim(document.getElementById("firstname").value)=="") {
		alert("Please Enter First Name");
		return false;
	}

	if(trim(document.getElementById("lastname").value)=="") {
		alert("Please Enter Last Name");
		return false;
	}

	if(emailValidate(document.getElementById("email").value)==false) {
		alert("Please Enter Valid Email Address");
		return false;
	}


	if(trim(document.getElementById("postal").value)=="") {
		alert("Please Enter a Valid Zip/Postal Code");
		return false;
	}

	if(document.getElementById("country").value=="") {
		alert("Please Select A Country");
		return false;
	}
	
	return true;
}

function change() {
	if(document.getElementById('chb2').checked==true){
		document.getElementById('email1').style.backgroundColor = "#ccc";	
	}

	if(document.getElementById('chb2').checked==false)
		{
		document.getElementById('email1').style.backgroundColor = "#EFF3F4";
	}
	
}
function change1() {
	if(document.getElementById('chb1').checked==true){
		document.getElementById('signup_type').style.backgroundColor = "#ccc";	
	}

	if(document.getElementById('chb1').checked==false)
		{
		document.getElementById('signup_type').style.backgroundColor = "#EFF3F4";
	}
	
}
function change2(){
	if(document.getElementById('chb3').checked==true){
		document.getElementById('postal').style.backgroundColor = "#ccc";	
	}

	if(document.getElementById('chb3').checked==false)
		{
		document.getElementById('postal').style.backgroundColor = "#EFF3F4";
	}
}
function change3(){
	if(document.getElementById('chb4').checked==true){
		document.getElementById('occupation').style.backgroundColor = "#ccc";	
	}

	if(document.getElementById('chb4').checked==false)
		{
		document.getElementById('occupation').style.backgroundColor = "#EFF3F4";
	}
}
function change4(){
	if(document.getElementById('chb11').checked==true){
		document.getElementById('country').style.backgroundColor = "#ccc";	
	}

	if(document.getElementById('chb11').checked==false)
		{
		document.getElementById('country').style.backgroundColor = "#EFF3F4";
	}

}
function change5(){
	if(document.getElementById('chb6').checked==true){
		document.getElementById('firstname').style.backgroundColor = "#ccc";	
	}

	if(document.getElementById('chb6').checked==false)
		{
		document.getElementById('firstname').style.backgroundColor = "#EFF3F4";
	}
}
function change6(){
	if(document.getElementById('chb7').checked==true){
		document.getElementById('company').style.backgroundColor = "#ccc";	
	}

	if(document.getElementById('chb7').checked==false)
		{
		document.getElementById('company').style.backgroundColor = "#EFF3F4";
	}

}
function change7(){
	if(document.getElementById('chb8').checked==true){
		document.getElementById('lastname').style.backgroundColor = "#ccc";	
	}

	if(document.getElementById('chb8').checked==false)
		{
		document.getElementById('lastname').style.backgroundColor = "#EFF3F4";
	}

}
function change8(){
	if(document.getElementById('chb9').checked==true){
		document.getElementById('division').style.backgroundColor = "#ccc";	
	}

	if(document.getElementById('chb9').checked==false)
		{
		document.getElementById('division').style.backgroundColor = "#EFF3F4";
	}

}
function change9(){
	if(document.getElementById('chb10').checked==true){
		document.getElementById('age').style.backgroundColor = "#ccc";	
	}

	if(document.getElementById('chb10').checked==false)
		{
		document.getElementById('age').style.backgroundColor = "#EFF3F4";
	}

}
function change10() {
	if(document.getElementById('chb12').checked==true){
		document.getElementById('division').style.backgroundColor = "#ccc";	
	} else {
		document.getElementById('division').style.backgroundColor = "#EFF3F4";
	}
}
function change11() {
	if(document.getElementById('chb13').checked==true){
		document.getElementById('age').style.backgroundColor = "#ccc";	
	} else {
		document.getElementById('age').style.backgroundColor = "#EFF3F4";
	}
}
function popup1(){
	alert('This feature is coming soon! ');	
}
function showlist(){
	
	var el = document.getElementById('myMenu');

	if (el.style.display == 'none'){
	
	el.style.display = 'block';
	}
	else if (el.style.display == ''){
	
	el.style.display = 'block';
	}
	else {
	
	el.style.display = 'none';		
	}
}
function setSearchValue(src_value){
	
	var el = document.getElementById('myMenu');	
	var search_value = src_value;
	document.getElementById('select').value = search_value;	
	el.style.display = 'none';	
}
function showlist1(){
	
	
	var el = document.getElementById('myMenu1');
	

	if (el.style.display == 'none'){
	
	el.style.display = 'block';
	}
	else {
	
	el.style.display = 'none';		
	}
}
function setSearchValue1(src_value){
	
	var el = document.getElementById('myMenu1');	
	var search_value = src_value;
	document.getElementById('select1').value = search_value;	
	el.style.display = 'none';	
}

// masud changesssssssssssssssssssss
function abc()

{
if ((!document.getElementById('male').checked) && (!document.getElementById('female').checked)) 
	{
		alert ("select a gender!!");
		document.getElementById('male').focus();
		return false;
	}
return true;
}



function passwordAvailability()
{ 
	if((document.getElementById("password").value)&&(document.getElementById("repassword").value)) 
	{
		if(document.getElementById("repassword").value.length<5) {
			document.getElementById("user_check_password").innerHTML="<font color='red'>Password length should be more then 6!!</font>";
			document.getElementById("repassword").focus();
			return;
			}
		
		
		if((document.getElementById("password").value)!=(document.getElementById("repassword").value)) {
			document.getElementById("user_check_password").innerHTML="<font color='red'>Password does not match !!</font>";
			document.getElementById("repassword").focus();
			return false;
			}
		if((document.getElementById("password").value)==(document.getElementById("repassword").value)) {
			document.getElementById("user_check_password").innerHTML="";
		document.getElementById("repassword").focus();
			;
			}
			
			xmlHttp=GetXmlHttpObject();
		
			if (xmlHttp==null){
			   alert ("Your browser does not support AJAX!");
			   return;
			}
	}
	else
	{
		
	alert('Please enter valid password.');	
	}
}






// checking email..............................................................................................................................
function emailValidate(str){
	
    var  filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
    if (filter.test(str))
	{
        testresults=true;
	}
    else{
       testresults=false;
    }

    return (testresults);
}

function checkEmailAvailability_last(val)
{
    if(!emailValidate(document.getElementById("new_email").value)) 
	{		
		document.getElementById("email_test").innerHTML="<font color='red'>Please Enter Valid Email !!!</font>";
		document.getElementById("commtitleee").disabled=true;
		return;
    }

    xmlHttp=GetXmlHttpObject();

    if (xmlHttp==null){
       alert ("Your browser does not support AJAX!");
       return;
    }
    
    var url="ajaxCheckEmail2.php?email="+document.getElementById("new_email").value+"&prev_email="+val;
	
	//alert(url);
	 //parameters passed here

    xmlHttp.onreadystatechange=checkEmailAvailabilityStateChangeddd;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function checkEmailAvailabilityStateChangeddd() 
{
	

    if (xmlHttp.readyState==4) {
       
		//alert(xmlHttp.responseText);
		//logic goes here
		if(xmlHttp.responseText=="available") {
			
			document.getElementById("email_test").innerHTML="<font color='green'>Email Available</font>";
			document.getElementById("commtitleee").disabled=false;
		} else {
			//alert("unavailable");
			document.getElementById("email_test").innerHTML="<font color='red'>Email Already Registered !!</font>";
			document.getElementById("commtitleee").disabled=true;;
		}
    } else if(xmlHttp.readyState<4) {
		document.getElementById("email_test").innerHTML="<font color='black'>Checking Email Availability</font>";
    }
}
// checking email..............................................................................................................................