<!-- // Hide code from old browsers
// 4/2/2001 - Validation added for Numeric Checking using onBlur event 
function validate(Field) {
      s = Field.value;
      if (  (isNaN(Math.abs(s)) && (s.charAt(0) != '#'))) {
          if ( validate.arguments.length  == 1 )
             alert( Field.name + " Value must be a number." );
          else 
             alert( Field +  " must be a number. Please re-enter." );
        Field.focus();
        return false;
      }
      return true;
}


// Validate for Group Page 1               
function validContact(fm) 
{ 
	rField = new Array();       // to hold the form field names 
        rText = new Array();        // to hold user-friendly strings for error message - should be exact same as form field label 
	rField[1]="name";      			rText[1] ="Your Name";
	rField[2]="company";      		rText[2] ="Company Name";
	rField[3]="address";       		rText[3] ="Address";
	rField[4]="city";           	rText[4] ="City";
	rField[5]="state";     			rText[5] ="State";
	rField[6]="zip";           		rText[6] ="Zip";
	rField[7]="phone";         		rText[7] ="Your Phone Number";
	rField[8]="email";      		rText[8] ="Your Email Address";
	rField[9]="comments";     		rText[9] ="Comments";

	// Confirm all required fields      
	for(i=1;i<rField.length;i++) {         
		if (field_cont=fm.elements[rField[i]].value=="") 
                {            
	  	        // display user-friendly field name   
	  		alert("An entry for '"+rText[i]+"' is required.");  
	      	        fm.elements[rField[i]].focus();


	    	        return false;
	  	}        
	}       


	return true;
}         

function validDemo(fm) 
{ 
	rField = new Array();       // to hold the form field names 
    rText = new Array();        // to hold user-friendly strings for error message - should be exact same as form field label 
	rField[1]="name";               rText[1] ="Name";
	rField[2]="company";      		rText[2] ="Company Name";
	rField[3]="address";       		rText[3] ="Address";
	rField[4]="city";           	rText[4] ="City";
	rField[5]="state";     			rText[5] ="State";
	rField[6]="zip";           		rText[6] ="Zip";
	rField[7]="phone";         		rText[7] ="Phone Number";
	rField[8]="email";      		rText[8] ="Email Address";
	rField[9]="time";     			rText[9] ="Best time of day to contact you";

	
	//Check that the terms box was checked
	if (fm.agreed_to_terms.checked == 1) {
    	//alert("Thank You");
	} else { 
    	alert("You must agree to the terms and conditions before proceeding. Thank You!")
    	fm.agreed_to_terms.focus(); 
		return false;
	}


	//Check email - requried and in a valid format
	var txt="A valid email address is required. Please check your email address and re-enter your information and send again.";
	var EmailAddress=fm.email;

	if(!emailValidation(EmailAddress,txt)) {
		fm.email.focus();
		return false;
	}

	// Confirm all required fields      
	for(i=1;i<rField.length;i++) {         
		if (field_cont=fm.elements[rField[i]].value=="") 
                {            
	  	        // display user-friendly field name   
	  		alert("An entry for '"+rText[i]+"' is required.");  
	      	        fm.elements[rField[i]].focus();


	    	        return false;
	  	}        
	}       


	return true;
}         


// Validate for Individual               
function validIndividual(fm) 
{ 
	rField = new Array();       // to hold the form field names 
        rText = new Array();        // to hold user-friendly strings for error message - should be exact same as form field label 
	rField[1]="prospectname";      	rText[1] ="Prospect Name";
	rField[2]="prospectzip";      	rText[2] ="Prospect Zip Code";
	rField[3]="name";       		rText[3] ="Your Name";
	rField[4]="phone";           	rText[4] ="Your Phone";
	rField[5]="fax";     			rText[5] ="Your Fax";
	rField[6]="effdate";           	rText[6] ="Effective Date";
	
	// Confirm all required fields      
	for(i=1;i<rField.length;i++) {         
		if (field_cont=fm.elements[rField[i]].value=="") 
                {            
	  	        // display user-friendly field name   
	  		alert("This field "+rText[i]+" is required.");  
	      	        fm.elements[rField[i]].focus();


	    	        return false;
	  	}        
	}       


	return true;
}         


function blank(field){
		field_cont=field.value;
		if (field_cont=="" || field_cont.trim()=="" ) {            
   			alert(field.name+" is a required field. Please enter a value.");
    		field.focus();
   		return false;
             }
}




// 3/6/2002 - Returns true if field contains html tag(s), otherwise false 
function containsHTML(field) {
	if ((field.value.indexOf("<") >= 0) && (field.value.indexOf(">") >= 0)) {
		alert("HTML tags are not allowed in " + field.name + ".  Please enter only plain text.");
		field.focus();
		field.select();
		return true;
	}
	return false;
}




function validatedec(field) {
	var valid = "0123456789.";
	var ok = 0;
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = -1;
	}
	if (ok == -1) {
		alert("Invalid entry:  Only numbers and a decimal point are accepted for " + field.name + ". Enter your number with up to two decimal places.");
		field.focus();
		field.select();
                return false;
	}
        return true;
}

function validateziplist(field) {
	var valid = "0123456789,* ";
	var ok = 0;
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = -1;
	}
	if (ok == -1) {
		alert("Incorrect list of Zip Codes:  Only numbers (five-digit or less), commas, and asterix may be used.");
		field.focus();
		return false;
	}




        if(field.value==""){
        alert(field.name+" is a required field. ");
    		field.focus();
   			return false;
		}
			
		if(field.value.length>255){
			alert("List of Zip Codes can only be 255 characters. Please shorten list.");      
    		field.focus();      
			return false;
		}
	return true;
}



function validatedecimal(field) {
	var valid = "0123456789.";
	var ok = 0;
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = -1;
	}
	if (ok == -1) {
		alert("Invalid entry:  Only numbers and a decimal point are accepted for " + field.name + ". Enter your number with up to two decimal places.");
		field.focus();
		return false;
	}
  	if(field.value==""){
        	alert(field.name+" is a required field. ");
                field.focus();
                return false;
        }
        return true;
}




// Get checked value from radio button.
function getRadioButtonValue (radio)
{
   for (var i = 0; i < radio.length; i++) {
       if (radio[i].checked) { break }
    }
    return radio[i].value
}




function validateAgree(field) {
  	if(!field.checked){
    	alert("Please indicate you agree to the terms and conditions.");
    	field.focus();
   		return false;
    }
    return true;
}



// Be sure popup email is non empty - Randy 03/13/02                
function validSellerEmail(fm)
 { 
	rField = new Array();           // to hold the form field names 
        rText = new Array();            // to hold user-friendly strings for error message - should be exact same as form field label 
	rField[1]="fullName";           rText[1]="Full Name";
	rField[2]="email";              rText[2]="Email Address";
	rField[3]="message";            rText[3]="Message";
	
	// Confirm all required fields      
	for(i=1;rField.length;i++)
        {         
		if (field_cont=fm.elements[rField[i]].value=="")
                {            
	  	        // display user-friendly field name   
	  		alert("This field "+rText[i]+" is required.");
	      	        fm.elements[rField[i]].focus();
	    	        return false;
	  	}        
	}       
	return true;
}  


     
function limitNoHTML(name,x){ 
	if(!limit(name,x)){
		return false;
	}
	if (containsHTML(name)) {
		return false;
	}
	return true;
} 
	
function limit(name,x){ 
	if(name.value.length>x){
		alert("This field can only hold "+x+" characters. Please shorten.");      
    	        name.focus();      
		name.select();
		return false;
	}
	return true;
}





function out1(topic){
	temp=document.images[topic].src;
	re=/ovr.gif/ ;    
	document.images[topic].src=temp.replace(re,'.gif');
}


function openwin(url){
	newwin=open(url,"Detail",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=550,height=560');
}




function openwin1(url)
{
      newwin=open(url,"Detail",'toolbar=no,location=no,directories=no,status=no,menubar=no,photobars=yes,resizable=yes,top=20, left=20,width=570,height=455');
}






// make sure multiple email addresses are seperated by enter key and email address is valid
function emailValidation(EmailAddress,txt)
{
        if(txt=="text")
        {
            var alertMessage="Enter at least one email address. For multiple addresses, enter one per line without any additional punctuation,\n" +
					" for example:\n" +
					"                   bill@acme.com\n"+
					"                   sue@acme.com\n"+
					"                   larry@acme.com" ;
        }
        else
         {
            var alertMessage=txt;
         }
	var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@-._";
	var count = 0; // is used to check how many times @ symbol appears in the mail id, if it appears more than once display error message.
	var temp="";
	var separator = '\n';
	var emailArray = EmailAddress.value.split(separator); 
	loop: for (var i=0; i < emailArray.length; i++)
	{ 
                var emailLength=0;	
		for (var k=0; k<emailArray[i].length; k++) 
		{	
			
			var lastCharacter=emailArray[i].substring(emailArray[i].length-1,emailArray[i].length);
                        // check the last character  enter key or not in the email address
			if(lastCharacter.charCodeAt(emailArray[i].substring(emailArray[i].length-1,emailArray[i].length)) == 13)
			{
				emailLength=emailArray[i].length-1; // last character is enter key
				break;
			}
			else
			{
				emailLength=emailArray[i].length;  // last character is not enter key
				break;
			}
			

        	}
                // get the email address from emailArray and validate 
		for (var j=0; j<emailLength; j++) 
		{
			temp = "" +emailArray[i].substring(j, j+1);
			if (valid.indexOf(temp) == -1 || emailArray[i].indexOf('@') == -1 || emailArray[i].indexOf('.') == -1  || emailArray[i].length<6 || emailArray[i].substring(0, 1)=='@' || emailArray[i].substring(0, 1)=='.') 
			{
				alert(alertMessage);
				EmailAddress.focus();
		  	        return false;
				break loop;
			}
			else if(temp=='@')
			{
			      count=count+1;
			}
			
		}
		if(count >1)
		{
			alert(alertMessage);
			EmailAddress.focus();
		  	return false;
			break;
		}
		else
		{
			count=0;
		}
	}
	return true;
}



// make sure the state field is non-empty
function selectState(state)
{
        if(state[state.selectedIndex].value == "" || state[state.selectedIndex].value == ".." || state[state.selectedIndex].value == "null" )
        {
                alert("This field State Name is required.")


		state.focus();
        	return false;
        }
        return true;
}




//  make sure phone number contains only digits and it should be minimum 10 characters
function phoneValidation(string ,alertTxt)
{
	var phone=string;
        var temp;
        var count=0;
        var valid="0123456789";
        for (var i=0; i<phone.value.length; i++) 
	{
		temp = "" + phone.value.substring(i, i+1);
        	if(valid.indexOf(temp) != -1)
                     count=count+1;   // counting the number of digits in phone number
        }
	if(count <10)
        	{
	            alert("Please enter a full "+alertTxt+" including area code.");    
	            phone.focus();
	            return false;
	        }
        return true;
}




function newWindow(url,X,Y)
{
     newwin=open(url,"Detail","toolbar=no,location=no,directories=no,status=no,menubar=no,photobars=yes,resizable=yes,width="+X+",height="+Y);
}


// Cancel
function validCancel(f1)
{
	if(document.f1.cancelReason[document.f1.cancelReason.selectedIndex].value =="null") {
		alert("Please enter the reason for cancelling this ad");
		document.f1.cancelReason.focus();
		return false;
   	}
        return true;
}

// function for partner_account.jsp. Make sure all the required fields are non-empty
function validPartnerAccount(fm)
{
        var rField = new Array();       // to hold the form field names 
        rText = new Array();            // to hold user-friendly strings for error message - should be exact same as form field label 
        rField[1]="Profile";            rText[1]="Profile Information";
        rField[2]="CompanyName";        rText[2]="Company Name";
	rField[3]="FirstName";          rText[3]="First Name";
        rField[4]="LastName";           rText[4]="Last Name";
	rField[5]="TypeOfBusiness";     rText[5]="Type Of Business";
        rField[6]="Address";            rText[6]="Address";
        rField[7]="City";               rText[7]="City Name";
        rField[8]="State";              rText[8]="State Name";
        rField[9]="Zip";                rText[9]="Zip Code";
        rField[10]="PhoneNumber";       rText[10]="Phone Number";
        rField[11]="EmailAddress";      rText[11]="Email Address";
        
        var state=fm.State;
        var zip=fm.Zip;
        var string=fm.PhoneNumber;
        var alertTxt="Phone Number";
        var txt="text";
        var EmailAddress=fm.EmailAddress;
        for(i=1;i<rField.length;i++) 
        {         
               if(fm.elements[rField[i]].value=="" || fm.elements[rField[i]].value=="null")
                {
                        // display user-friendly field name
                   	alert("This field "+rText[i]+" is required.");
    		        fm.elements[rField[i]].focus();
   			return false;
    	        }
        }
        if(!selectState(state)) return false;
        if(!zipValidation(zip)) return false;
        if(!phoneValidation(string,alertTxt)) return false;
        if(!emailValidation(EmailAddress,txt)) return false;
        return true;
}





// make sure the HearAboutUs field is non-empty
function selectHearAboutUsFn(hearAboutUs)
{
        if(hearAboutUs[hearAboutUs.selectedIndex].text ==".." ){
                alert("This field Hear About Us is required.")
		hearAboutUs.focus();
        	return false;
        }
        return true;
}

// make sure single dropdown forms should not require hitting "Go" button
function go(formObject)
{
    formObject.form.submit();
}


// 15/01/2003 - Validation added for Numeric Checking 
function validateField(Field)
{
     var s = Field.value;
     if(s.charAt(s.length-1)==' ' ) { // check last character is not space
  	        alert( Field.name + " Value must be a number with out any spaces. " );
	        Field.focus();
		Field.select();
	        return false;
     }
     if ( !(isNaN(Math.abs(s)) ) ) { // checking number or not
          if (   s.charAt(0)==' '  ){ // checking first character is not space
	        alert( Field.name + " Value must be a number with out any spaces." );
	        Field.focus();
		Field.select();
	        return false;
           }
     }
     else{  // not a number
     	        alert( Field.name + " Value must be a number with out any spaces." );
	        Field.focus();
		Field.select();
	        return false;
           }
      return true;
}

// function to open new window when user clicks on view website add hyper link  
     function viewWebSite(fm) {
                var str="http://"+fm.adURL.value;
                window.open(str);
     }

// function to open new window when user clicks on view online add add hyper link  
     function viewAdd(fm) {
                var str="http://www.gonehome.com/"+fm.adURL.value;
                window.open(str);
     }




// check emailadress for any mistyped invalid chars..
var testresults
function checkemail(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{
		alert("Please input a valid email address!");
		testresults=false;
	}
	return (testresults);


}


function popup_xy(url, x, y){
	newwin=open(url,"Detail","top=30,left=30,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" + escape(x) + ",height="+escape(y));
}


// for date format check 'mm/dd/yyyy' format 
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
// make sure 's' contains all numbers..
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 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++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}


function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		if (i==2) {this[i] = 29;}
   } 
   return this;
}


function isDate(dtStr){
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strMonth=dtStr.substring(0,pos1);
	var strDay=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy");
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month");
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day");
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date");
		return false;
	}
return true
}
        
function validateForm(dob){
	var dt=dob;
	if (isDate(dt.value)==false){
		dt.focus();
		return false;
	}
    return true;
 }


// end of date format check methods....





// End hide script from old browsers -->




