// JavaScript Document

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}

function validateSignin(){
	if(document.signinform.username.value == ""){
		alert("Please Enter Username");
		document.signinform.username.focus();
		return false;
	}
	if(document.signinform.password.value == ""){
		alert("Please Enter Password");
		document.signinform.password.focus();
		return false;
	}	
}



function validateSignup(){
	if(document.signupform.firstname.value == ""){
		alert("Please Enter First Name");
		document.signupform.firstname.focus();
		return false;
	}
	if(document.signupform.lastname.value == ""){
		alert("Please Enter Last Name");
		document.signupform.lastname.focus();
		return false;
	}	
	if(document.signupform.country.selectedIndex == 0){
		alert("Please Select a Country");
		document.signupform.country.focus();
		return false;
	}	
	
	if(document.signupform.marital.selectedIndex == 0){
		alert("Please specify marital status");
		document.signupform.marital.focus();
		return false;
	}	

	if(document.signupform.children.selectedIndex == 0){
		alert("Please specify the children");
		document.signupform.children.focus();
		return false;
	}	
	
	if(document.signupform.height.value == ""){
		alert("Please Enter the height");
		document.signupform.height.focus();
		return false;
	}		

	if(document.signupform.weight.value == ""){
		alert("Please Enter the weight");
		document.signupform.weight.focus();
		return false;
	}		


	if(document.signupform.horoscope.selectedIndex == 0){
		alert("Please specify the horoscope");
		document.signupform.horoscope.focus();
		return false;
	}	

	if(document.signupform.smoking.selectedIndex == 0){
		alert("Please specify the smoking behavior");
		document.signupform.smoking.focus();
		return false;
	}	

	if(document.signupform.drinking.selectedIndex == 0){
		alert("Please specify the drinking behavior");
		document.signupform.drinking.focus();
		return false;
	}	


	if(document.signupform.job.value == ""){
		alert("Please Enter your occupation");
		document.signupform.job.focus();
		return false;
	}		

	if(document.signupform.interests.value == ""){
		alert("Please Enter your general interests");
		document.signupform.interests.focus();
		return false;
	}		


	if(document.signupform.howhe.value == ""){
		alert("Please descibe the lady you are looking for");
		document.signupform.howhe.focus();
		return false;
	}		
	
	
	emailStr = document.signupform.email.value;
	var emailPat = /^(.+)@(.+)$/;
  	var specialChars = "\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	var validChars = "\[^\\s" + specialChars + "\]";
	var quotedUser = "(\"[^\"]*\")";
	var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
    var atom = validChars + '+';
    var word = "(" + atom + "|" + quotedUser + ")";
    var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$");
    var matchArray = emailStr.match(emailPat);
    if(matchArray == null){
    	alert("Email address seems incorrect (check @ and .'s)");
    	document.signupform.email.focus();
        return false;
    }
    var user = matchArray[1];
    var domain = matchArray[2];
    if(user.match(userPat) == null) {
    	alert("The username doesn't seem to be valid.");
    	document.signupform.email.focus();
        return false;
    }
    var IPArray = domain.match(ipDomainPat)
    if(IPArray != null){
    	for(var i=1; i<=4; i++){
			if (IPArray[i]>255){
        		alert("Destination IP address is invalid!");
        		document.signupform.email.focus();
        		return false;
         	}
         }
    }
    var domainArray = domain.match(domainPat)
    if(domainArray == null){
    	alert("The domain name doesn't seem to be valid.");
        document.signupform.email.focus();
        return false;
    }
    var atomPat = new RegExp(atom,"g")
    var domArr = domain.match(atomPat)
    var len = domArr.length
    if(domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4){
    	alert("The e-mail address must end in a three or four-letter domain, or two letter country.");
        document.signupform.email.focus();
        return false;
    }
    if(len<2){
    	alert("This e-mail address is missing a hostname!");
        document.signupform.email.focus();
        return false;
    }
	/*if(document.signupform.username.value == ""){
		alert("Please Enter Username");
		document.signupform.username.focus();
		return false;
	}
	if(document.signupform.username.value.length < 6 ){
		alert("Username must be more than 6 Characters");
		document.signupform.username.focus();
		return false;
	}*/		
	if(document.signupform.password.value.length < 6 || document.signupform.password.value.length > 16){
		alert("Password must be between 7 and 16 Characters");
		document.signupform.password.focus();
		return false;
	}	
	if(document.signupform.password.value == ""){
		alert("Please Enter Password");
		document.signupform.password.focus();
		return false;
	}
	if(document.signupform.password.value != document.signupform.confirmpass.value){
		alert("Invalid Password Confirmation");
		document.signupform.confirmpass.value = "";
		document.signupform.confirmpass.focus();
		return false;
	}	

}

/*function validateForm(){
	if(document.contactusForm.firstname.value == ""){
		alert("Please enter your first name");
		document.contactusForm.firstname.focus();
		return false;
	}
	if(document.contactusForm.lastname.value == ""){
		alert("Please enter your last name");
		document.contactusForm.lastname.focus();
		return false;
	}
	if(document.contactusForm.email.value == ""){
		alert("Please enter your email");
		document.contactusForm.email.focus();
		return false;
	}
	emailStr = document.contactusForm.email.value;
	var emailPat = /^(.+)@(.+)$/;
  	var specialChars = "\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	var validChars = "\[^\\s" + specialChars + "\]";
	var quotedUser = "(\"[^\"]*\")";
	var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
    var atom = validChars + '+';
    var word = "(" + atom + "|" + quotedUser + ")";
    var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$");
    var matchArray = emailStr.match(emailPat);
    if(matchArray == null){
    	alert("Email address seems incorrect (check @ and .'s)");
    	document.contactusForm.email.focus();
        return false;
    }
    var user = matchArray[1];
    var domain = matchArray[2];
    if(user.match(userPat) == null) {
    	alert("The username doesn't seem to be valid.");
    	document.contactusForm.email.focus();
        return false;
    }
    var IPArray = domain.match(ipDomainPat)
    if(IPArray != null){
    	for(var i=1; i<=4; i++){
			if (IPArray[i]>255){
        		alert("Destination IP address is invalid!");
        		document.contactusForm.email.focus();
        		return false;
         	}
         }
    }
    var domainArray = domain.match(domainPat)
    if(domainArray == null){
    	alert("The domain name doesn't seem to be valid.");
        document.contactusForm.email.focus();
        return false;
    }
    var atomPat = new RegExp(atom,"g")
    var domArr = domain.match(atomPat)
    var len = domArr.length
    if(domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4){
    	alert("The e-mail address must end in a three or four-letter domain, or two letter country.");
        document.contactusForm.email.focus();
        return false;
    }
    if(len<2){
    	alert("This e-mail address is missing a hostname!");
        document.contactusForm.email.focus();
        return false;
    }
	if(isNaN(document.contactusForm.phonenumber.value)){
		alert("Phone number must be numeric");
		document.contactusForm.phonenumber.focus();
		return false;
	}
	else{
		document.contactusForm.submit();
		return true;
	}
}*/


function showHideState(){
	if(document.signupform.country.selectedIndex == 157){
		document.getElementById("amerc").style.display = '';
	}
	if(document.signupform.country.selectedIndex != 157){
		document.getElementById("amerc").style.display = 'none';
	}
}


function DeleteConfirmation(param){
	msg = "Are You Sure You want to delete ?";
	if(confirm(msg)){
		location.href = param;	
	}
}


function EmptyConfirmation(param){
	msg = "Are You Sure You want to empty ?";
	if(confirm(msg)){
		location.href = param;	
	}
}


function ChangeConfirmation(param){
	msg = "Are You Sure You want to Change the picture ?";
	if(confirm(msg)){
		location.href = param;	
	}
}

function validateGirls(){
	/*if(! IsNumeric(document.girlForm.profileID.value)){
		alert("Profile ID must be numeric");
		document.girlForm.profileID.value = "";
		document.girlForm.profileID.focus();
		return false;			
	}*/
	if(document.girlForm.girlName.value == ""){
		alert("Please Enter Girl Name");
		document.girlForm.girlName.focus();
		return false;
	}
	if(document.girlForm.age.value != "" ){
		if(! IsNumeric(document.girlForm.age.value)){
			alert("Girl Age must be numeric");
			document.girlForm.age.value = "";
			document.girlForm.age.focus();
			return false;			
		}			
	}
	if(document.girlForm.height.value != "" ){
		if(! IsNumeric(document.girlForm.height.value)){
			alert("Girl Height must be numeric");
			document.girlForm.height.value = "";
			document.girlForm.height.focus();
			return false;			
		}			
	}	
	if(document.girlForm.weight.value != "" ){
		if(! IsNumeric(document.girlForm.weight.value)){
			alert("Girl Weight must be numeric");
			document.girlForm.weight.value = "";
			document.girlForm.weight.focus();
			return false;			
		}			
	}		
}


function validateText(){
	if(document.textForm.textTitle.value == ""){
		alert("Please Enter a Title");
		document.textForm.textTitle.focus();
		return false;
	}
	if(document.textForm.tText.value == ""){
		alert("Please Enter a Text");
		document.textForm.tText.focus();
		return false;
	}
}

function validatePhoto(){
	if(document.form1.File1.value == ""){
		alert("Please Enter the file");	
		document.form1.File1.focus();
		return false;
	}
}


function validateEntry(){
	if(document.forgotForm.email.value == ""){
		alert("Please Enter your E-mail");
		document.forgotForm.email.focus();
		return false;
	}
}


function validateSearch(){
	if(document.form1.age1.value != ""){
		if(! IsNumeric(document.form1.age1.value)){
		alert("Age Intervals must be numeric");
		document.form1.age1.focus();
		return false;
		}
	}
	if(document.form1.age2.value != ""){
		if(! IsNumeric(document.form1.age2.value)){
		alert("Age Intervals must be numeric");
		document.form1.age1.focus();
		return false;
		}	
	}
	if(document.form1.age1.value != "" && document.form1.age2.value == ""){
		alert("Incorrect age Interval, Please fill the 2 fields");
		return false;
	}
	if(document.form1.age1.value == "" && document.form1.age2.value != ""){
		alert("Incorrect age Interval, Please fill the 2 fields");
		return false;
	}	

	if(document.form1.height1.value != ""){
		if(! IsNumeric(document.form1.height1.value)){
		alert("Height Intervals must be numeric");
		document.form1.height1.focus();
		return false;
		}
	}
	if(document.form1.height2.value != ""){
		if(! IsNumeric(document.form1.height2.value)){
		alert("Height Intervals must be numeric");
		document.form1.height2.focus();
		return false;
		}	
	}
	if(document.form1.height1.value != "" && document.form1.height2.value == ""){
		alert("Incorrect height Interval, Please fill the 2 fields");
		return false;
	}
	if(document.form1.height1.value == "" && document.form1.height2.value != ""){
		alert("Incorrect height1 Interval, Please fill the 2 fields");
		return false;
	}	

}


function validateCallHer(){
	if(document.signupform.ptime.value == ""){	
		alert("Prefered Time is Empty");	
		document.signupform.ptime.focus();
		return false;
	}
	
	emailStr = document.signupform.email.value;
	var emailPat = /^(.+)@(.+)$/;
  	var specialChars = "\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	var validChars = "\[^\\s" + specialChars + "\]";
	var quotedUser = "(\"[^\"]*\")";
	var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
    var atom = validChars + '+';
    var word = "(" + atom + "|" + quotedUser + ")";
    var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$");
    var matchArray = emailStr.match(emailPat);
    if(matchArray == null){
    	alert("Email address seems incorrect (check @ and .'s)");
    	document.signupform.email.focus();
        return false;
    }
    var user = matchArray[1];
    var domain = matchArray[2];
    if(user.match(userPat) == null) {
    	alert("The username doesn't seem to be valid.");
    	document.signupform.email.focus();
        return false;
    }
    var IPArray = domain.match(ipDomainPat)
    if(IPArray != null){
    	for(var i=1; i<=4; i++){
			if (IPArray[i]>255){
        		alert("Destination IP address is invalid!");
        		document.signupform.email.focus();
        		return false;
         	}
         }
    }
    var domainArray = domain.match(domainPat)
    if(domainArray == null){
    	alert("The domain name doesn't seem to be valid.");
        document.signupform.email.focus();
        return false;
    }
    var atomPat = new RegExp(atom,"g")
    var domArr = domain.match(atomPat)
    var len = domArr.length
    if(domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4){
    	alert("The e-mail address must end in a three or four-letter domain, or two letter country.");
        document.signupform.email.focus();
        return false;
    }
    if(len<2){
    	alert("This e-mail address is missing a hostname!");
        document.signupform.email.focus();
        return false;
    }

	if(document.signupform.country.selectedIndex == 0){
		alert("Please Select a Country");	
		document.signupform.country.focus();
		return false;
	}

}


function validateEmail(){
	if(document.form1.emailText.value == ""){
		alert("E-mail Empty");
		document.form1.emailText.focus();
		return false;
	}
}


function RedirectTo(path){
	location.href = path;
}


function addToFavorite(param){
	msg = "Lady will be added to your favorite";
	if(confirm(msg)){
		location.href = param;	
	}
}

function diplayDate(){
	if(document.form1.protype.value == "Tour"){
		if(document.all.tourdate.style.display == "none"){
			document.all.tourdate.style.display = "";	
		}else{	
			document.all.tourdate.style.display = "none";		
		}
	}else{
		     document.all.tourdate.style.display = "none";	
	}
}







