
//This is a commom validation function for validating JUST Numeric values
function ValidateNumeric(sFld)    {
	
	//regular expression for checking alphanumeric, no comma, . 
	var regLP="^[0-9]+$"  //regular expression for checking numeric only, no comma, . 
	
	if (trim(sFld.value).length != 0 ){
		if ((trim(sFld.value).search(regLP)==-1)) {  //if match failed						
			alert("Invalid entry! Please enter numeric values only.");			
			sFld.value = "";
			sFld.select();sFld.focus();
			return false;		
		}
	}
	
	return true;
}

//This is a commom validation function for validating Alpha Numeric values
function ValidateAlphaNumeric(sFld)    {
	
	var regLP="^[a-z A-Z 0-9/-]+$"  //regular expression for checking alphaNumeric data only, no comma, , but special chars /-. 	
	
	if (trim(sFld.value).length != 0 ){		
		if ((sFld.value.search(regLP)==-1)) {  //if match failed								
			alert("Invalid entry! Please enter alphanumeric values only.");			
			sFld.value = "";
			sFld.select();sFld.focus();
			return false;
		}
	}
	
	return true;
}

function ValidateDecimal(sFld) {

	decallowed = 2;  // how many decimals are allowed?
	var dectext;
		
	var intIndex = sFld.value.indexOf('.')  + 1
		
	if (trim(sFld.value).length != 0 ){
		if (isNaN(sFld.value) ) {			
			alert("Invalid Entry. Not a valid number.");			
			sFld.select();sFld.focus();			
			return false;
		} else { if (sFld.value.indexOf('.') == -1) sFld.value  += ".00";
			if (intIndex == sFld.value.length ) sFld.value  += "00";
			
			dectext = sFld.value.substring(sFld.value.indexOf('.')+1, sFld.value.length);
			
			if (dectext.length > decallowed) {
				alert("Please enter a number with 2 decimals.");				
				sFld.select();sFld.focus();		
				return false;
	      	} 
	    }	
    }

	return true;
}


function noEntry(MLSSrch) {
	mt = trim(document.getElementById("ctl00_cntHomePage_txtMlsNumber").value)
	
	if (trim(mt) == '' ){								
		alert("Please enter MLS number.");
		return false;
	} else {
        //document.getElementById("ctl00_cntHomePage_txtMlsNumber").value
        if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMlsNumber"))) return false;
	}

	return true;	
}

function ltrim ( s ){
	return s.replace( /^\s*/, "" );
}

function rtrim ( s ){
	return s.replace( /\s*$/, "" );
}

function trim ( s ){
	return rtrim(ltrim(s));
}

function checkdetail(detail) {
	
	//check radio buttons
	var el = document.detail.elements;
	
	for(var i = 0 ; i < el.length ; ++i) {
  		if(el[i].type == "radio") {
   			var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
   			var itemchecked = false;
   			for(var j = 0 ; j < radiogroup.length ; ++j) {
    			if(radiogroup[j].checked) {
	 			itemchecked = true;
	 			break;
			}
   		}
   		if(!itemchecked) { 
    		alert("Please choose a Property.");
    		if(el[i].focus)
     			el[i].focus();
				return false;
   			}
  		}
	}
 
	document.detail.submit();
}

function fncHlpWindow() {	
		var title = document.getElementById("ctl00_cntHomePage_txtTitle").value ;		
		var sURL = "SearchTips.htm#" + title
		
		window.open(sURL ,'','toolbar=yes,status=no,resizable=yes,scrollbars=yes,location=no,menubar=no,directories=no,width=670,height=500,top=10,left=70'); 
	} 	

function validateForm() {
    
    var booAgtSrch = false;
    var booOfcSrch = false;
    var booMLSSrch = false;
    var strSrchType = "";
    var doc = document.forms[0];
   
    if (doc.ctl00$cntHomePage$txtLastName.value != "" || doc.ctl00$cntHomePage$txtFirstName.value != "" || doc.ctl00$cntHomePage$txtAgtOffice.value != "" || doc.ctl00$cntHomePage$txtAgtZip.value != "" || doc.ctl00$cntHomePage$txtAgtCity.value != "") {
		booAgtSrch = true;
		strSrchType ="Agt";
	}
	
	if (doc.ctl00$cntHomePage$txtCompany.value != "" || doc.ctl00$cntHomePage$txtOfcCity.value != "" || doc.ctl00$cntHomePage$txtOfcZip.value != "") {
		booOfcSrch = true;
		strSrchType ="Ofc";
	}
	
	
	if (doc.ctl00$cntHomePage$txtMLSNumber.value != "") {
		booMLSSrch = true;
		strSrchType ="MLS";
	}
	
	if (strSrchType == "") {
		alert("Please enter criteria for a single search type only!");
		doc.ctl00$cntHomePage$txtLastName.focus();
		return false;
	} else {
		if ((booAgtSrch == true && booOfcSrch == true) || (booAgtSrch == true && booMLSSrch == true)  || (booOfcSrch == true && booMLSSrch == true)) {
			alert("Please enter criteria for a single search type only.");
			doc.ctl00$cntHomePage$txtLastName.focus();
			return false;    
	    }
	 }
	 
	 doc.ctl00$cntHomePage$txtSrchType.value=strSrchType ;
}


function ValidateRadiusSrch(RadiusSrch){

    var doc = document.forms[0];
	
	var blnCheck = false ;
	var strStreetNumber = doc.ctl00_cntHomePage_txtRStreetNumber.value;
	var strCity = doc.ctl00_cntHomePage_txtRCity.value;
	var strStreetName = doc.ctl00_cntHomePage_txtRStreetName.value;
	var strZip = doc.ctl00_cntHomePage_txtRZip.value;
	
	if (!(strStreetName.length > 1 && strStreetNumber.length > 1 && strCity.length > 1)) blnCheck = true;
	
	//Make zipcode mandatory if any other other flds are filled in
	if (blnCheck == true) {		
		if ((strStreetName.length > 1 || strStreetNumber.length > 1 ) && (strCity.length < 1 && strZip.length < 1)) {	
			alert("A valid ZipCode is required for Radius search to return correct results.");
			doc.ctl00_cntHomePage_txtRZip.focus();
			return false;		
		}
	}
	
	if (blnCheck == true) {
		if ((strCity.length > 1 ) && (strZip.length < 1)) {
			alert("A valid ZipCode is required for Radius search to return correct results.");
			doc.ctl00_cntHomePage_txtRZip.focus();
			return false;
		}
	}
	
	//Make zipcode mandatory if no other flds are filled in
	if (strStreetName.length < 1 && strStreetNumber.length < 1 && strCity.length < 1) {
		if (strZip.length < 1){
			alert("A valid ZipCode is required for Radius search to return correct results.");
			doc.ctl00_cntHomePage_txtRZip.focus();
			return false;
		}
	}

	var strStreetNumber = doc.ctl00_cntHomePage_txtRStreetNumber.value;
	var strCity = doc.ctl00_cntHomePage_txtRCity.value;
	var strStreetName = doc.ctl00_cntHomePage_txtRStreetName.value;
	var strZip = doc.ctl00_cntHomePage_txtRZip.value;
	    
    if (strZip.length > 1){
        if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtRZip"))) return false;
    }
    
    if (strStreetName.length > 1) {
        if (!ValidateAlphaNumeric(document.getElementById("ctl00_cntHomePage_txtRStreetName"))) return false;	
	}
	
	if (strStreetNumber.length > 1) {        
        if (!ValidateAlphaNumeric(document.getElementById("ctl00_cntHomePage_txtRStreetNumber"))) return false;
	}
	
	if (strCity.length > 1) {
        if (!ValidateAlphaNumeric(document.getElementById("ctl00_cntHomePage_txtRCity"))) return false;	
	}
	
	return true;
	//document.RadiusSrch.submit();
}

function ValidateDetailFlds(strPropType) {
    
    if (strPropType =="RS" || strPropType == "CO") {
        if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMinPrice"))) return false;
        if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMaxPrice"))) return false;
        if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMinBed"))) return false;
        if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMaxBed"))) return false;
        if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMinYrBt"))) return false;
        if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMaxYrBt"))) return false;                        
        if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMinBath"))) return false;            
        if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMaxBath"))) return false;            
        if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMinSqft"))) return false;
        if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMaxSqft"))) return false;
    }
    
    if (strPropType =="RS") {
        if (!ValidateDecimal(document.getElementById("ctl00_cntHomePage_txtMinAcreage"))) return false;
        if (!ValidateDecimal(document.getElementById("ctl00_cntHomePage_txtMaxAcreage"))) return false;        
    }
    
    switch (strPropType){
    
        case "MF":
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMFMinPrice"))) return false;
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMFMaxPrice"))) return false;  
            if (!ValidateAlphaNumeric(document.getElementById("ctl00_cntHomePage_txtUnits"))) return false;
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMFMinYrBt"))) return false;
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMFMaxYrBt"))) return false;              
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMFMinSqft"))) return false;            
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtMFMaxSqft"))) return false;
        break;
        
        case "CM":            
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtCMMinPrice"))) return false;
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtCMMaxPrice"))) return false;  
            if (!ValidateDecimal(document.getElementById("ctl00_cntHomePage_txtCMMinAcreage"))) return false;
            if (!ValidateDecimal(document.getElementById("ctl00_cntHomePage_txtCMMaxAcreage"))) return false;                        
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtCMMinYrBt"))) return false;
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtCMMaxYrBt"))) return false;              
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtCMMinSqft"))) return false;            
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtCMMaxSqft"))) return false;
        break;
        
        case "VL":        
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtVLMinPrice"))) return false;
            if (!ValidateNumeric(document.getElementById("ctl00_cntHomePage_txtVLMaxPrice"))) return false;  
            if (!ValidateDecimal(document.getElementById("ctl00_cntHomePage_txtVLMinAcreage"))) return false;
            if (!ValidateDecimal(document.getElementById("ctl00_cntHomePage_txtVLMaxAcreage"))) return false;                
        break;
    }
    
}


function ValidateAddressSrch(){	
	
	et = document.getElementById("ctl00_cntHomePage_txtCity").value
	if (et.length<1){
		alert("Please enter a City.");
		return false;
	} else {
	    if (!ValidateAlphaNumeric(document.getElementById("ctl00_cntHomePage_txtCity"))) return false;
	}
	
	dt = document.getElementById("ctl00_cntHomePage_txtStreetName").value
	if (dt.length<1){
		alert("Please enter Street Name.");
		return false;
	} else {
	    if (!ValidateAlphaNumeric(document.getElementById("ctl00_cntHomePage_txtStreetName"))) return false;
	}
	
	var Street_Number = document.getElementById("ctl00_cntHomePage_txtStreetNumber").value
	if (Street_Number.length > 1) {	
	    if (!ValidateAlphaNumeric(document.getElementById("ctl00_cntHomePage_txtStreetNumber"))) return false;
	}
	
	return true;
	//document.address.submit();
}

function Entry(type){

	return true;
	document.type.submit();
}			

function Validate(form,proptype){
	
	gt = document.form.txtCity.value
	ht = document.form.txtSchool.value
	if ( gt.length<1 && ht.length<1)
	{
		alert("please enter either City or School district.");
		return false;
	}
	
	//Check for number of values selected in the dropdown
	var Counter = 0;
	
	// Loop through the select box to see how many are selected;
	for (i=0; i<document.form.txtCity.length; i++)
	{
		// If an element is selected, increment the counter
		if (document.form.txtCity[i].selected == true)
		{
			Counter++;	
		}
	}
	////alert (Counter);
	//// If the counter is greater than 3, display an alert message.
	
	if (Counter > 15)
	{
		alert("You have selected more than 15 Areas.");
		return false;
	}
	
	//**************Check for non numeric values************************************
	
	//Check miminum and max price
	valMinPrice= document.form.txtMinPrice.value
	
 	if ( (valMinPrice*0) !=0) {
		alert ("Minimum Price is invalid! Please check and enter again!")
       	return false;
	}
	
	valMaxPrice= document.form.txtMaxPrice.value
	
 	if ((valMaxPrice*0) !=0) {
		alert ("Maximum Price is invalid! Please check and enter again!")
		return false;
	}
	
	
	//Check min and max sq. footage for all properties except vacantland
	
	if ((proptype !="VL")){ 
		valMinSqft= document.form.txtMinSqft.value
	
 		if ( (valMinSqft*0) !=0) {
			alert ("Minimum Square Footage is invalid! Please check and enter again!")
         	return false;
		}
	
		valMaxSqft= document.form.txtMaxSqft.value
	
 		if ( (valMaxSqft*0) !=0) {
			alert ("Maximum Square Footage is invalid! Please check and enter again!")
         	return false;
		}
	
	}
	
	//Check min and beds/baths for res and condo
	
	if ((proptype =="RS") || (proptype =="CO")){ 
		valMinBeds= document.form.txtMinBed.value
	
 		if ( (valMinBeds*0) !=0) {
			alert ("Minimum Beds is invalid! Please check and enter again!")
         	return false;
		}
	
		valMaxBeds= document.form.txtMaxBed.value
	
 		if ((valMaxBeds*0) !=0) {
			alert ("Maximum Beds is invalid! Please check and enter again!")
         	return false;
		}
	
		valMinBaths= document.form.txtMinBath.value
	
 		if ((valMinBaths*0) !=0) {
			alert ("Minimum Baths is invalid! Please check and enter again!")
         	return false;
		}
	
		valMaxBaths= document.form.txtMaxBath.value
	
 		if ((valMaxBaths*0) !=0) {
			alert ("Maximum Baths is invalid! Please check and enter again!")
         	return false;
		}
	}

	//Check #Units for Multifamily
	
	if ((proptype =="MF")){ 
		valUnits= document.form.txtUnits.value
	
 		if ( (valUnits*0) !=0) {
			alert ("# of Units is invalid! Please check and enter again!")
         	return false;
		}
	}

	//Check Acreage for vacantland
	
	if ((proptype =="VL")){ 
		valAcreage= document.form.txtAcreage.value
	
 		if ( (valAcreage*0) !=0) {
			alert ("Acreage is invalid! Please check and enter again!")
         	return false;
		}
	}
	
	return true;
	document.form.submit();
}			

function IsNumeric(field) {
	
	var valid = "0123456789"
	var ok = "yes";
	var temp;
	for (var i=0; i< trim(field.value).length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	
	if (ok == "no") {
		alert("Invalid entry!  Please enter numeric values only.");
		field.focus();
		field.select();
	}
	
}

function ValidateDecimal(sFld) {

	decallowed = 2;  // how many decimals are allowed?
	var dectext;
		
	var intIndex = sFld.value.indexOf('.')  + 1
		
	if (trim(sFld.value).length != 0 ){
		if (isNaN(sFld.value) ) {			
			alert("Invalid Entry. Not a valid number.");			
			sFld.select();sFld.focus();			
			return false;
		} else { if (sFld.value.indexOf('.') == -1) sFld.value  += ".00";
			if (intIndex == sFld.value.length ) sFld.value  += "00";
			
			dectext = sFld.value.substring(sFld.value.indexOf('.')+1, sFld.value.length);
			
			if (dectext.length > decallowed) {
				alert("Please enter a number with 2 decimals.");
				sFld.select();sFld.focus();		
				return false;
	      	}
		}
	}	
	return true;
}
/*
function EmailValidate(SendMail) {

	var RegEmail = new RegExp ("@");
	var reg=/[^0-9a-zA-Z@_]/;
	var regL=/[^0-9]/;
 
	//alert('in validate ' + document.SendMail.From.value);
	var emailVal = document.SendMail.From.value;
   
	var emailToVal =document.SendMail.toEmail.value;
   
    VarPos = emailVal.indexOf("@")
    VarPos1 = emailVal.lastIndexOf("@")
   
	if (document.SendMail.toEmail.value == "" && document.SendMail.BCCto.value == "") {
		alert("Please enter a valid email address in To or CC.");
		document.SendMail.toEmail.focus();
		return (false);
	}
	
	if (document.SendMail.toEmail.value.search(RegEmail) <= 0 && document.SendMail.BCCto.value.search(RegEmail) <= 0) {
		alert("Please enter a valid email address in To or CC.");
		document.SendMail.toEmail.focus();
		return (false);
	}
	
	if (document.SendMail.From.value == "") {
		alert("Please enter a valid email address in From.");
		document.SendMail.From.focus();
		return (false);
	}
	
	if ((emailVal.indexOf(";") > -1 ) || (emailVal.indexOf(",") > -1 ) || (emailVal.indexOf(" ") > -1 ) ) { 
		alert('Only ONE email address is allowed in the  “From:”  field'); 
		document.SendMail.From.focus();
		return (false);
	}
	
	//if ((emailToVal.indexOf(" ") > -1 ) || (emailToVal.indexOf(",") > -1 )) { 
	//	alert('Please seperate “To:”  Addresses using a semicolon'); 
	//	document.SendMail.toEmail.focus();
	//	return (false);
	//}
	if (VarPos1 != VarPos) {
		alert('The email address you have entered contains invalid characters.  Please correct the email address.'); 
		return (false);
	}
	if (document.SendMail.From.value.search(RegEmail) <= 0) {
		alert("Please enter a valid email address in From.");
		document.SendMail.From.focus();
		return (false);
	} else {
		//document.SendMail.BCCto.value = document.SendMail.From.value;
	}
	//document.SendMail.submit()
}	

*/
function ValidateAreaSrch(AreaSrch) {
	
	ar = document.AreaSrch.txtArea.value
	
	if(ar.length<1){
		alert("Please select Area(s)!");
		return false;
	}
	
	return true;
	
	document.AreaSrch.submit();
}
	
function ValidateSchool(School) {
	
	sc = document.School.txtSchool.value
	
	if(sc.length<1){
		alert("Please Select School District(s)!");
		return false;
	}
	
	return true;
	document.School.submit();
}

function SetPropType(strProp){

    var varSeq = document.getElementById("ctl00_cntHomePage_txtSeq").value 
    

    document.getElementById("ctl00_cntHomePage_txtPropType").value = strProp ;
    window.location = "AreaViewList.aspx?PropType=" + strProp + "&SrchType=" + varSrchType + "&Region=" + varRegion + "&Refine=false&Seq=" + varSeq;
}

function SetPropTypeAddr(strProp){

    var varSeq = document.getElementById("ctl00_cntHomePage_txtSeq").value 
    

    document.getElementById("ctl00_cntHomePage_txtPropType").value = strProp ;
    //window.location = "AreaViewList.aspx?PropType=" + strProp + "&SrchType=" + varSrchType + "&Region=" + varRegion + "&Refine=false&Seq=" + varSeq;
}
	
function ChangeTabImage(strProp){

	var varTitle="";
		
	if (varType =='1'){
	    var strLink = "MI_County_Map.aspx?varPropSrch=Y&PropType=" + strProp + "&Type=" + varSrchType;
        
        window.location = strLink ;
        
	} else {	
	    if (strProp=="RS"){
		    var aryImages = new Array(0);
    		
		    aryImages[0] = "/Images/menuresidential.gif";				
		    varTitle = "Residential";
	    }	
    			
	    if (strProp=="CO"){	
	        var aryImages = new Array(0);
    	    	    		
		    aryImages[0] = "/images/menucondo.gif";		
		    varTitle= "Condo";			
	    }
    			
	    if (strProp=="CM"){
		    var aryImages = new Array(0);
    			
		    aryImages[0] = "Images/menucommercial.gif";		
	        varTitle= "Commercial";
	    }	
    			
	    if (strProp=="MF"){
		    var aryImages = new Array(0);
    			
		    aryImages[0] ="Images/menumultifamily.gif" ;
	        varTitle = "MultiFamily";
	    }	
    			
	    if (strProp=="VL"){
		    var aryImages = new Array(0);
    			
		    aryImages[0] ="Images/menuvacantland.gif";	
	        varTitle = "Vacantland"
	    }	
    			
	    document.getElementById("ctl00_cntHomePage_txtPropType").value = strProp ;		
        document.getElementById("ctl00_cntHomePage_txtTitle").value = varTitle ;
        document.forms(0).imgMenuBar.src=aryImages[0];    				
    }
    
    
}

function SchoolsCount()	{
	
	//Check for number of values selected in the dropdown
	var Cntr = 0;
	var el = document.SchoolSrch.elements;
	
	for(var i = 0 ; i < el.length ; ++i) {
  		if(el[i].type == "checkbox") {
   			var checkbox = el[el[i].name]; // get the whole set of radio buttons.
   	
			for(var j = 0 ; j < checkbox.length ; ++j) {
    			if(checkbox[j].checked) {
	 				Cntr++;
	 			}
   			}
   			
   			break;		
   		}		
   	}	
   	
	//alert (Cntr);
	if (Cntr ==0){
		alert("Please select at least 1 School District (maximum of 15 School Districts) to search on.");
		return false;
	} else {
		if (Cntr > 15) {
			alert("You have selected more than 15 School Districts.");
			return false;
		}else{
			return true;
			document.SchoolSrch.submit();	
		}
	}	
}


function ClearCheckBox(){
    
    for (var e = 0; e < document.forms[0].elements.length; e++) {							
		if (document.forms[0].elements[e].type == 'checkbox' ){
		    if (document.forms[0].elements[e].checked) {
		        document.forms[0].elements[e].checked = false;
		    }
		}
	}			
	
}


function AreaCount_safariver(strType)	{

	//Check for number of values selected in the dropdown
	var Cntr = 0;
		
	for (var e = 0; e < document.forms[0].elements.length; e++) {							
		if (document.forms[0].elements[e].type == 'checkbox' ){
		    if (document.forms[0].elements[e].checked) {
		        Cntr++;
		    }
		}
	}			
			
	if(Cntr == 0){
		alert("Please select at least 1 area (maximum of 5 areas) to search on.");
		return false;
	} else {
		if (Cntr > 5) {
			alert("Please narrow your selection to 5 areas or less.");
			return false;
		} else {
			//return true;
			//document.AreaSrch.submit();	
		}
	}	
	
	CheckItem();
	//alert(varArea);
	//Response.Redirect("SearchResults.aspx?SrchType=" & txtSrchType.Value & "&PropType=RS" & txtPropType.Value & "&Region=" & txtRegion.Value & "&Print=false&Seq=" & txtSeq.Value)
	varURL = "SearchResults.aspx?SrchType=" + document.getElementById("ctl00_cntHomePage_txtSrchType").value + "&PropType=" + document.getElementById("ctl00_cntHomePage_txtPropType").value + "&Region=" + document.getElementById("ctl00_cntHomePage_txtRegion").value + "&Print=false&Seq=" + document.getElementById("ctl00_cntHomePage_txtSeq").value ;
	
	var intSeq = 0;	
	
	intSeq = document.getElementById("ctl00_cntHomePage_txtSeq").value 
	intSeq ++;intSeq ++;
	
	if (strType == '1') varURL = "PropertySearch.aspx?SrchType=" + document.getElementById("ctl00_cntHomePage_txtSrchType").value + "&PropType=" + document.getElementById("ctl00_cntHomePage_txtPropType").value + "&Region=" + document.getElementById("ctl00_cntHomePage_txtRegion").value + "&Print=false&Refine=false&Seq=" + intSeq ;
	
	window.location=varURL ;
	//return true;
}		

function AreaCount(strType)	{

	//Check for number of values selected in the dropdown
	var Cntr = 0;
		
	for (var e = 0; e < document.forms[0].elements.length; e++) {							
		if (document.forms[0].elements[e].type == 'checkbox' ){
		    if (document.forms[0].elements[e].checked) {
		        Cntr++;
		    }
		}
	}			
			
	if(Cntr == 0){
		alert("Please select at least 1 area (maximum of 5 areas) to search on.");
		return false;
	} else {
		if (Cntr > 5) {
			alert("Please narrow your selection to 5 areas or less.");
			return false;
		} else {
			//return true;
			//document.AreaSrch.submit();	
		}
	}	
	
	return true;
}		


function CheckItem() { 

    var doc = document.forms[0];
    
    var CheckedItems ="";    
            
    for(i=0;i<doc.chkArea.length;i++) { 
        
        if (doc.chkArea[i].checked) {            
            CheckedItems  = CheckedItems + doc.chkArea[i].value +","; 
        }    
    } 
    
    /*var the_length=CheckedItems.length;
    var last_char=CheckedItems.charAt(the_length-1);
    CheckedItems = CheckedItems.replace(CheckedItems.charAt(the_length-1),"");*/
    
    createCookie("City",CheckedItems ,"");		        
} 

function EmailValidate_Listing(SendMail) {

	var RegEmail = new RegExp ("@");
	var reg=/[^0-9a-zA-Z@_]/;
	var regL=/[^0-9]/;
	
	var doc = document.forms[0];
	 
	var emailVal = doc.txtFromEmail.value;   
	var emailToVal = doc.txtToEmail.value;
   
    VarPos = emailVal.indexOf("@")
    VarPos1 = emailVal.lastIndexOf("@")
   
	if (doc.txtToEmail.value == "" && doc.txtCC.value == "") {
		alert("Please enter a valid email address in To or CC.");
		doc.txtToEmail.focus();
		return (false);
	}
	
	if ((doc.txtFromEmail.value == "")  || echeck(doc.txtFromEmail.value)==false){
	    alert("Please enter a valid email address in From.");
		doc.txtFromEmail.focus();
		return (false);
	}
	
	if (echeck(doc.txtToEmail.value)==false){
	    alert("Please enter a valid email address in To.");
		doc.txtToEmail.focus();
		return (false);
	}
	
    if ((doc.txtCC.value != "")  && echeck(doc.txtCC.value)==false){
	    alert("Please enter a valid email address in 'CC'.");
		doc.txtCC.focus();
		return (false);
	}
	
	if ((emailVal.indexOf(";") > -1 ) || (emailVal.indexOf(",") > -1 ) || (emailVal.indexOf(" ") > -1 ) ) { 
		alert('Only ONE email address is allowed in the  “From:”  field'); 
		doc.txtFromEmail.focus();
		return (false);
	}
	
	if (VarPos1 != VarPos) {
		alert('The email address you have entered contains invalid characters.  Please correct the email address.'); 
		return (false);
	}	
}

function EmailValidate(SendMail) {

	var RegEmail = new RegExp ("@");
	var reg=/[^0-9a-zA-Z@_]/;
	var regL=/[^0-9]/;
	
	
	var doc = document.forms[0];
	 
	var emailVal = doc.txtFromEmail.value;   
	var emailToVal = doc.txtToEmail.value;
   
    VarPos = emailVal.indexOf("@")
    VarPos1 = emailVal.lastIndexOf("@")
   
	/*if (doc.txtToEmail.value == "" && doc.txtCC.value == "") {
		alert("Please enter a valid email address in To or CC.");
		doc.txtToEmail.focus();
		return (false);
	}*/
	
	if ((doc.txtFromEmail.value == "")  || echeck(doc.txtFromEmail.value)==false){
	    alert("Please enter a valid email address in From.");
		doc.txtFromEmail.focus();
		return (false);
	}
	
	//if (echeck(doc.txtToEmail.value)==false){
	if (echeck(doc.hdnEmailAddress.value)==false){	
	    alert("Invalid recipient email address");
		doc.txtToEmail.focus();
		return (false);
	}
	
    if ((doc.txtCC.value != "")  && echeck(doc.txtCC.value)==false){
	    alert("Please enter a valid email address in 'CC'.");
		doc.txtCC.focus();
		return (false);
	}
	
	if ((emailVal.indexOf(";") > -1 ) || (emailVal.indexOf(",") > -1 ) || (emailVal.indexOf(" ") > -1 ) ) { 
		alert('Only ONE email address is allowed in the  “From:”  field'); 
		doc.txtFromEmail.focus();
		return (false);
	}
	
	if (VarPos1 != VarPos) {
		alert('The email address you have entered contains invalid characters.  Please correct the email address.'); 
		return (false);
	}	
}	


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){		   
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		    return false;
		 }

 		 return true;					
	}

function SetFocusOnButton(){
    
	if (window.event.keyCode == 13)	{	    	    
	    document.forms[0].ctl00_cntHomePage_btnSearch.focus();	
	}						
}	
