function validate1AndSubmit(f) {


if (f.gender.selectedIndex == 0) 
  { alert("What is your gender?"); f.gender.focus();return(false); }

if (f.iso.selectedIndex == 0) 
  { alert("What type of partner are you looking for?"); f.iso.focus();return(false); }

if (f.rel_pref.selectedIndex == 0) 
  { alert("What relationship type are you looking for?"); f.rel_pref.focus();return(false); }

if (f.intent_pref.selectedIndex == 0) 
  { alert("How seriously are you looking?"); f.intent_pref.focus();return(false); }

if (f.body.selectedIndex == 0) 
  { alert("Please indicate your Body Type."); f.body.focus();return(false); }

if (f.hair.selectedIndex == 0) 
  { alert("What is your hair color?"); f.hair.focus();return(false); }

if (f.eye.selectedIndex == 0) 
  { alert("What is your eye color?"); f.eye.focus();return(false); }

if (f.heightfeet.selectedIndex == 0 && f.heightinch.selectedIndex == 0) 
  { alert("How tall are you?"); f.heightfeet.focus();return(false); }

if (f.tens.selectedIndex == 0 && f.units.selectedIndex == 0) 
  { alert("What is your weight?"); f.tens.focus();return(false); }

if(parseInt(f.weightKgs.value)/parseInt(f.heightcms.value) < 0.25) {
 alert("Your WEIGHT and HEIGHT do not seem to match.  Please make sure you are providing correct info."); return(false);
}





//end
//begin prompt to show user his selections

msg = "__________________________________\n\n";
msg += "Verify the information you entered...\n__________________________________";
msg += "\n\nClick Cancel to make any corrections,";
msg += "\nor Click OK if everything is correct...";
msg += "\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n\nYou are a: "; 
msg += f.gender.options[f.gender.selectedIndex].text;
msg += "\nSeeking a: " + f.iso.options[f.iso.selectedIndex].text + "\nRelationship: "; 
msg += f.rel_pref.options[f.rel_pref.selectedIndex].text;
msg += "\nCity/State: " + f.city.value + ", " + f.state.value;
msg += "\nAge: " + f.age.value + "\n\nBody Type: ";
msg += f.body.options[f.body.selectedIndex].text + "\nHair Color: ";
msg += f.hair.options[f.hair.selectedIndex].text + "\nEye Color:"; 
msg += f.eye.options[f.eye.selectedIndex].text + "\nHeight: ";
msg += f.heightfeet.options[f.heightfeet.selectedIndex].text + " feet "; 
msg += f.heightinch.options[f.heightinch.selectedIndex].text + " inches (";
msg += f.heightcms.value + " cm)";

msg += "\nWeight: "+f.weightLbs.value+" lbs. ("+f.weightKgs.value+" Kg)";

//f.GotoStep3.disabled=true;f.saveXit.disabled=true;

f.action="stage.php";
return confirm(msg);

//end

}





function validate2AndSubmit(f) {

if (f.ethnicity.selectedIndex == 0) 
  { alert("You forgot to select your ethnicity"); f.ethnicity.focus();return(false); }

if (f.faith.selectedIndex == 0) 
  { alert("Please select your religion."); f.faith.focus();return(false); }

if (f.edu.selectedIndex == 0) 
  { alert("Please indicate your level of education.");f.edu.focus();return(false); }

if (f.job.selectedIndex == 0) 
  { alert("Are you currently employed?"); f.job.focus();return(false); }

if (f.occupation.selectedIndex == 0) 
  { alert("What is your occupation?"); f.occupation.focus();return(false); }

if (f.income.selectedIndex == 0) 
  { alert("What is your income?"); f.income.focus();return(false); }

if (f.marital.selectedIndex == 0) 
  { alert("Are you married?"); f.marital.focus();return(false); }

if (f.smoke.selectedIndex == 0) 
  { alert("Please indicate whether or not you smoke."); f.smoke.focus();return(false); }

if (f.drink.selectedIndex == 0) 
  { alert("Please indicate whether or not you drink."); f.drink.focus();return(false); }

if (f.drugs.selectedIndex == 0) 
  { alert("Do you do drugs?"); f.drugs.focus();return(false); }

if (f.kid_have.selectedIndex == 0) 
  { alert("Do you have kids?"); f.kid_have.focus();return(false); }

if (f.kid_want.selectedIndex == 0) 
  { alert("Do you want (more) kids?"); f.kid_want.focus();return(false); }


//end
//begin prompt to show user his selections

msg = "__________________________________\n\n";
msg += "Verify the information you entered...\n__________________________________";
msg += "\n\nClick Cancel to make any corrections,";
msg += "\nor Click OK if everything is correct...";
msg += "\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n\nEthnicity: ";
msg += f.ethnicity.options[f.ethnicity.selectedIndex].text + "\nReligion: "; 
msg += f.faith.options[f.faith.selectedIndex].text + "\nEducation: ";
msg += f.edu.options[f.edu.selectedIndex].text + "\n\nEmployment: ";

msg += f.job.options[f.job.selectedIndex].text + "\nOccupation: ";
msg += f.occupation.options[f.occupation.selectedIndex].text + "\nIncome: ";

msg += f.income.options[f.income.selectedIndex].text + "\n\nMarital Status: ";
msg += f.marital.options[f.marital.selectedIndex].text + "\nSmoke: "; 
msg += f.smoke.options[f.smoke.selectedIndex].text + "\nDrink: ";
msg += f.drink.options[f.drink.selectedIndex].text + "\nDrugs: ";
msg += f.drugs.options[f.drugs.selectedIndex].text + "\nHave Kids: "; 
msg += f.kid_have.options[f.kid_have.selectedIndex].text;
msg += "\nWant kids: " + f.kid_want.options[f.kid_want.selectedIndex].text;

//f.GotoStep3.disabled=true;f.saveXit.disabled=true;

f.action="stage.php";
return confirm(msg);

//end

}






// count number of xters
function countXters(f,n){
f.count.value=n;
}




function manyToTwo() { // limit repeated xters to 3, e.g. !!!!!!!!!
   var f = document.step3, d = f.descr;
   var accumulator = new Array();
   var current = "";
   var count = 0;
   for (i = 0;i < d.value.length; i++) {
     var c = d.value.charAt(i);
     if (c == current) {
       count++;
     } else {
       count = 1;
       current = c;
     }
     if (count <= 2) {
       accumulator[i] = c;
     }
   }
   d.value = accumulator.join("");
 }




//function to validate step3

function validate3AndSubmit(f) {

var d_val = f.descr;

manyToTwo();

   if (f.title.value.length == 0) { 
      alert("You forgot to type a TITLE for your Personal Ad");f.title.focus(); return(false); 
   }

var get_indexof = d_val.value.replace(/^\s+/g,'').replace(/\s+$/g,'');

if (get_indexof.length < 135 ) 
  { alert("Please take a little time to tell people about yourself.\n\nMake your description 135 characters or more.\n\nThat would be about 30 words.\n\nNote: Descriptions with repeated phrases\n or rubbish entry will be deleted."); f.descr.focus();return(false); }

f.action="step3.php";

}




//function to validate step4


function validate4AndSubmit(what) {

var m = "Please complete the form";

    if (what.outdoor.selectedIndex==-1){
    alert(m); 
    return(false);
    }

    if (what.workout.selectedIndex==-1){
    alert(m); 
    return(false);
    }

    if (what.dd.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.ppl.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.season.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.fdate.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.pet.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.petpeeve.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.knownAs.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.alias.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.vac.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.person.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.party.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.food.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.role.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.muzik.selectedIndex==-1){
    alert(m); 
    return(false);
    }
    if (what.sport.selectedIndex==-1){
    alert(m); 
    return(false);
    }



return(true);
} // end step4 validate






function validateB4Reply()
{

var f = window.document.forms[0];

if (f.title.value == "") 
  { alert("A TITLE is required");f.title.focus(); return(false); }

if (f.descr.value == "" ) 
  { alert("You forgot to include your Message."); f.descr.focus();return(false); }

}


function validateEditForm()
{
var b = window.document.forms[0];
if(b.login.value=="")
{ alert("Enter your Login Name");b.login.focus();return(false); } 
if(b.passwd.value=="")
{ alert("Enter your password");b.passwd.focus();return(false); } 
}





function validateAndSubmit() {

var f = document.forms["regFrm"];

if (f.conf.value == "") 
  { alert("Correct Confirmation code required.");f.conf.focus();return(false); }


if (f.userLoginID.value == "") 
  { alert("Please type a login name");f.userLoginID.focus();return(false); }

if (f.passwd1.value.length < 4)
  { alert("A password is required\nand must be at least 4 characters long.");f.passwd1.focus();return(false); }

if (f.passwd1.value == f.userLoginID.value)
  { alert("Your password cannot be\nthe same as your login name.");f.passwd1.focus();return(false); }

if ((f.passwd2.value == "") || (f.passwd2.value != f.passwd1.value) )
  { alert("Your passwords do not match"); f.passwd2.focus();return(false); }

if (f.newUserEmail.value.search("@") == -1 || f.newUserEmail.value.search("[.*]") == -1) 
  { alert("A valid email is required"); f.newUserEmail.focus();return(false); }

/*
See [22]
*/
var mailP = f.newUserEmail.value;
var mailname = mailP.split("@");

if (f.userLoginID.value == mailname[0]) 
  { alert("The login name - "+mailname[0]+" is not available.  Please choose a different login name."); f.userLoginID.focus(); return(false); }

var lcn = f.userLoginID.value.toLowerCase();
if(lcn.indexOf('hotmai') !=-1 || lcn.indexOf('hotmail') !=-1 || lcn.indexOf('yahoo') !=-1 || lcn.indexOf('dotcom') !=-1) {
   alert("Login name - "+f.userLoginID.value+" - is not available.  Please choose a different login name."); f.userLoginID.focus(); return(false); 
}

if (isNaN(f.bday.value) == true) 
  { alert("Birthday can only be a numerical value 1-31"); f.bday.focus();return(false); }

if (isNaN(f.byear.value) == true) 
  { alert("Birthday can only be a numerical value\ne.g. 1972"); f.byear.focus();return(false); }

if (f.newUserEmail.value == f.alt_email.value) 
  { alert("Please provide two different email addresses"); f.alt_email.focus();return(false); }

if ( (f.passwd_q.selectedIndex == 0) )
  { alert('Please select a QUESTION'); document.regFrm.passwd_q.focus();return(false); }

if ( f.passwd_a.value.length == 0 ) { 
  alert("What is the answer to the question you selected?"); f.passwd_a.focus();return(false); 
}

if ( (f.sex.selectedIndex == 0) )
  { alert('Are you a Male or a Female?'); document.regFrm.sex.focus();return(false); }

if (f.fname.value == "") 
  { alert("What is your First Name?"); f.fname.focus();return(false); }

if (f.fromSrc.value == "") 
  {alert("How did you hear about oasisoflove.com?"); f.fromSrc.focus(); return(false);}else{f.action="user-reg2.php";}


//end
//begin prompt to show user his selections
msg = "_____________________________";
msg += "\n\nVerify the information you entered...";
msg += "\n_____________________________\n\nClick Cancel to make any corrections,";
msg += "\nor Click OK if everything is correct...\n\nName: " + f.fname.value;
msg += " " + f.lname.value + "\nLogin Name: " +  f.userLoginID.value;
msg += "\nPassword: ***************";
msg += "\nEmail: " + f.newUserEmail.value;
msg += "\nAlternate Email: " + f.alt_email.value;
msg += "\nQuestion: " + f.passwd_q.options[f.passwd_q.selectedIndex].text;
msg += "\nYour Answer: " + f.passwd_a.value;
msg += "\nBirthday: " + f.bmonth.options[f.bmonth.selectedIndex].text + " " + f.bday.value + ", " + f.byear.value;
return confirm(msg);

//end

}





function validateAccountEdit() {

var f = document.forms['regFrm'];
f.action="user-reg2.php";

if ( (f.passwd1.value.length != 0) && f.passwd1.value.length < 6)
  { alert("Your password must be at least 6 characters long.");f.passwd1.focus();return(false); }

if (f.passwd2.value !== f.passwd1.value)
  { alert("Your passwords do not match"); f.passwd2.focus();return(false); }

if (f.newUserEmail.value.search("@") == -1 || f.newUserEmail.value.search("[.*]") == -1) 
  { alert("A valid email is required"); f.newUserEmail.focus();return(false); }

if (f.bday.selectedIndex == 0) 
  { alert("Please select your day of birth"); f.bday.focus();return(false); }

if (isNaN(f.byear.value) == true) 
  { alert("Birth year can only be a numerical value\ne.g. 1972"); f.byear.focus();return(false); }

if (f.newUserEmail.value == f.alt_email.value) 
  { alert("Your alternate email address must be different from your main email address."); f.alt_email.focus();return(false); }

if ( (f.passwd_q.selectedIndex == 0) )
  { alert('Please select a QUESTION'); f.passwd_q.focus();return(false); }

if ( f.passwd_a.value.length == 0 ) { 
  alert("What is the answer to the question you selected?"); f.passwd_a.focus();return(false); 
}

if ( (f.sex.selectedIndex == 0) )
  { alert('Are you a Male or a Female?'); f.sex.focus();return(false); }

if ( (f.city.value.length == 0) && (f.state.value.length == 0) && (f.zip.value.length == 0))
  { alert('Please enter your CITY, STATE and COUNTRY, or your ZIPCODE'); f.city.focus();return(false); }

if ( (f.city.value.length != 0 || f.state.value.length != 0) && (f.zip.value.length == 0) && (f.country.selectedIndex==0) )
  { alert('Please select your COUNTRY'); f.country.focus();return(false); }

if ((f.zip.value.length == 0) && (f.country.selectedIndex==223) )
  { alert('Please enter your ZIP CODE'); f.zip.focus();return(false); }

if (f.fname.value.length == 0) 
  { alert("What is your First Name?"); f.fname.focus();return(false); }

//end

}



function validateEvent(w) {

var f = document.forms[w]; 
var sY = f.startYr.value, sM = f.startMo.value;
var sD = f.startDay.value, eY =  f.endYr.value;
var eM = f.endMo.value, eD = f.endDay.value;

if (f.title.value.length==0) { 
alert("You forgot to include a TITLE for your event");f.title.focus(); return(false); 
}

if (f.descr.value.length==0) { 
alert("Please describe your Event."); f.descr.focus();return(false); 
}

if(sY.length==0||sM.length==0||sD.length==0||eY.length==0||eM.length==0||eD.length==0) { 
alert("A date field is empty"); return(false); 
}

if(isNaN(parseInt(sY)) || isNaN(parseInt(sM)) || isNaN(parseInt(sD)) || isNaN(parseInt(eY)) || isNaN(parseInt(eM)) || isNaN(parseInt(eD))) { 
alert("Only numeric values are allowed in date fields."); return(false); 
}

if(sM<1 || sM>12 || sD<1 || sD>31 || eM<1 || eM>12 || eD<1 || eD>31) {
alert("Date values out of range.\n\nMonth: 1 - 12\nDay: 1 -31\n\nPlease verify."); return(false);
}

f.action="process.data.php"; 

}


function validateAdForm() {

var f = document.forms['adform'];

if(f.elements['Interests[]'].selectedIndex==0) 
{ alert('Please select one or more Interests that fit your advertisement.'); f.elements['Interests[]'].focus();return(false); }

if (f.title.value.length == 0) 
  { alert("What is the TITLE of your website?"); f.title.focus();return(false); }

if (f.descr.value.length == 0) 
  { alert("What is the description of your Advertisement?"); f.descr.focus();return(false); }

if (f.url.value.length == 0) 
  { alert("What is the URL of your website?"); f.url.focus();return(false); }



if(f.loginName.disabled==true && f.newAcctLogin.disabled==true) {
alert("You have not indicated if \nyou have an account or not.\n\nPlease answer YES or NO.");return(false); 
}


if(f.radio.value=="no") {

if (f.newAcctLogin.value.length == 0) 
  { alert("Please type a login name");f.newAcctLogin.focus();return(false); }

if (f.newAcctPassWrd.value.length < 6)
  { alert("A password is required\nand must be at least 6 characters long.");f.newAcctPassWrd.focus();return(false); }

if (f.newAcctPassWrd.value == f.newAcctLogin.value)
  { alert("Your password cannot be\nthe same as your login name.");f.newAcctPassWrd.focus();return(false); }

if ((f.newAcctPassWrd2.value.length == 0) || (f.newAcctPassWrd2.value != f.newAcctPassWrd.value)) 
  { alert("Your passwords do not match"); f.newAcctPassWrd2.focus();return(false); }

}

if (f.country.selectedIndex=='223') {
	if (f.zipcode.value.length == 0) { 
	alert('Please enter your ZIPCODE'); f.zipcode.focus();return(false); 
	}
}

if (f.fname.value.length == 0) 
  { alert("What is your FIRST NAME\nor your COMPANY NAME?"); f.fname.focus();return(false); }

if (f.lname.value.length == 0) 
  { alert("What is your LAST NAME\nor your COMPANY NAME?"); f.lname.focus();return(false); }

if ( (f.addr.value.length == 0) ) {alert('Please enter your STREET ADDRESS.'); f.addr.focus();return(false); }

if ( (f.city.value.length == 0) ) {alert('Please enter your CITY.'); f.city.focus();return(false); }

if ( (f.state.value.length == 0) ) {alert('Please enter your STATE.'); f.state.focus();return(false); }

if ( (f.country.selectedIndex==0) )
  { alert('Please select your COUNTRY'); f.country.focus();return(false); }

if ( (f.phone.value.length==0)&&(f.cell.value.length==0) )
  { alert('Please provide a phone number\nwhere you can be contacted.'); f.phone.focus();return(false); }

if (f.email.value.search("@") == -1 || f.email.value.search("[.*]") == -1) 
  { alert("A valid EMAIL is required"); f.email.focus();return(false); }

if(f.filterViolence.selectedIndex==0 || f.filterSex.selectedIndex==0 || f.filterNudity.selectedIndex==0 || f.filterLanguage.selectedIndex==0) 

  { alert('Please answer all questions about Content filtering.');return(false); }

if(f.elements['geoLocations[]'].selectedIndex==0) 
{ alert('Please select one or more Countries that fit your advertisement.'); f.elements['geoLocations[]'].focus();return(false); }

f.action="process.data.php"; 

}



























































function validateAdEdit() {

var f = document.forms['adform'];

if(f.elements['Interests[]'].selectedIndex==0) 
{ alert('Please select one or more Interests that fit your advertisement.'); f.elements['Interests[]'].focus();return(false); }

if (f.title.value.length == 0) 
  { alert("What is the TITLE of your website?"); f.title.focus();return(false); }

if (f.descr.value.length == 0) 
  { alert("What is the description of your Advertisement?"); f.descr.focus();return(false); }

if (f.url.value.length == 0) 
  { alert("What is the URL of your website?"); f.url.focus();return(false); }

if(f.filterViolence.selectedIndex==0 || f.filterSex.selectedIndex==0 || f.filterNudity.selectedIndex==0 || f.filterLanguage.selectedIndex==0) 

  { alert('Please answer all questions about Content filtering.');return(false); }

if(f.elements['geoLocations[]'].selectedIndex==0) 
{ alert('Please select one or more Countries that fit your advertisement.'); f.elements['geoLocations[]'].focus();return(false); }

if(f.elements['language'].selectedIndex==0) 
{ alert('What language is you ad in?'); f.elements['language'].focus();return(false); }

f.action="process.data.php"; 

}









































function validateAdAcctEdit(f) {


if(f.newPass.value.length>0 || f.newPass2.value.length>0) {

	if(f.loginName.value.length<1 || f.passWrd.value.length<1) {
	alert('To change your password, you must first enter your LOGIN and old PASSWORD.');
	f.loginName.focus();return(false);
	}

	if(f.newPass.value.length<6) {
	alert('Password must be six or more characters.');
	f.newPass.focus();return(false);
	}

	if(f.newPass.value!==f.newPass2.value) {
	alert('Your new passwords do not match.');
	f.newPass.focus();return(false);
	}
}

if (f.country.selectedIndex=='223') {
	if (f.zipcode.value.length == 0) { 
	alert('Please enter your ZIPCODE'); f.zipcode.focus();return(false); 
	}
}

if (f.fname.value.length == 0) 
  { alert("What is your FIRST NAME\nor your COMPANY NAME?"); f.fname.focus();return(false); }

if (f.lname.value.length == 0) 
  { alert("What is your LAST NAME\nor your COMPANY NAME?"); f.lname.focus();return(false); }

if ( (f.addr.value.length == 0) ) {alert('Please enter your STREET ADDRESS.'); f.addr.focus();return(false); }

if ( (f.city.value.length == 0) ) {alert('Please enter your CITY.'); f.city.focus();return(false); }

if ( (f.state.value.length == 0) ) {alert('Please enter your STATE.'); f.state.focus();return(false); }

if ( (f.country.selectedIndex==0) )
  { alert('Please select your COUNTRY'); f.country.focus();return(false); }

if ( (f.phone.value.length==0)&&(f.cell.value.length==0) )
  { alert('Please provide a phone number\nwhere you can be contacted.'); f.phone.focus();return(false); }

if (f.email.value.search("@") == -1 || f.email.value.search("[.*]") == -1) 
  { alert("A valid EMAIL is required"); f.email.focus();return(false); }

f.action="process.data.php"; 

}

