custLimit = '';
function trim(str) 
{
   return str.replace(/^\s*|\s*$/g,"");
}

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 Show(chkId , tblId)
{
	tblObj = document.getElementById(tblId);
	if(chkId.value == 'Yes')
	{
		tblObj.style.display = "block";
	}else
	{
		tblObj.style.display = "none";
	}
}

function validate_vs(theform)
{
	theform.form['vs'].value='0';
}

function validate_vs1(theform)
{
	theform.form['vs'].value='1';
}

function validate_search_step1()
{
	
	if(document.form1.vs.value == '0')
	{	
		return true;
	}
	var check = false;
	var length = document.form1.townid.length;
	for(i=0; i<length ; i++)
	{
		if(document.form1.townid[i].checked)
		{
			check = true;
			break;
		}
		
	}
	if(!check)
	{
		if(document.form1.OtherTown.value != '')
		{
			return true;
		}
	}else
	{
		return true;
	}
	
	alert ("Select minimum one town.");
	return false;
}


function validate_step7()
{
	if(document.form1.vs.value == '0')
	{	
		return true;
	}
	var obj1 = document.form1.Agreement;
	if(obj1[0].checked || obj1[1].checked)
	{
		
		return true;
		}
	alert("Select the agreement");
	return false;
	
}

function closeAll(chkId)
{
	var children=document.getElementById('mainDiv').getElementsByTagName('*');
	var chLen=children.length;
	for(i=0;i<chLen;i++)
	{
			if(children[i].getAttribute("name") == chkId)
			{
					children[i].disabled=true;
			}
	}
}

function openDivById(divId,chkId)
{	
	closeAll(chkId);
	var divId='tbl'+divId;	
	var children= document.getElementById(divId).getElementsByTagName('*');
	var chLen=children.length;
	for(i=0;i<chLen;i++)
	{
			if(children[i].getAttribute("name") == chkId)
			{
					children[i].disabled=false;
			}
	}
}

function checkRadioSelected(radioId,id)
{
	
		var id = id.split('tbl');
		var id1 = id[1];		
		x= eval("document.form1."+radioId);
		if(x)
		{
		len=eval("document.form1."+radioId+".length");
		for(i=0;i<len;i++)
		{
			checked=eval("document.form1."+radioId+"["+i+"].checked");
			if(checked)
				{
					check_val=eval("document.form1."+radioId+"["+i+"].value");
					break;
				}
		}
		if(!checked)
			{
				alert('Please check region to select area.');	
			}
		else if(check_val != id1)	
			{
				alert('Please select area relative to checked region.');	
			}
		}
			
}

function lengthless(val)
{
	
	if(Math.floor(val) == 0 )
		$('lengthofstay').value = "";	
	else
		$('lengthofstay').value = Math.floor(val);
	
	
	if(parseInt(val)<25)
	{								
		$('shownote').style.display = '';
		$('HideMonthlyRate').style.display = 'none';
		$('b_lim_n').checked = true;
	}
	else
	{
		$('shownote').style.display = 'none';
		$('HideMonthlyRate').style.display = '';
		$('b_lim_m').checked = true;
	}
	
	if(parseInt(val) < 25)	
	{
		$('tdLeaseContract').hide();
		$('3_month_lease_n').checked = false;
		$('3_month_lease_y').checked = false;
		
	}else
	{
			
		if($('stay_long_y').checked == true){	
				$('tdLeaseContract').show();
		}
		
	}
	
	
}


function CheckLength(val)
{
	
	if(parseInt(val) < 7 )
	{
	     $j.alerts.okButton = '&nbsp;&nbsp;Yes&nbsp;&nbsp;&nbsp;&nbsp;';
		 $j.alerts.cancelButton = '&nbsp;&nbsp;&nbsp;No&nbsp;&nbsp;';
		 $j.alerts.draggable = true;
		 jConfirm('Sorry, but Singapore landlords are forbidden by law to rent for less than <strong>7 DAYS MINIMUM</strong>.  Unless you can change your stay to 7 days or longer, we cannot assist you.  You would have to book a regular hotel room (we do not handle hotel stays, only serviced apartments).<br/><br/> Would you like to make this change and continue with the form? ', 'Warning', function(r) {
		  if(r==true){ 
			 $j("#lengthofstay").val("");
			 $j("#lengthofstay").focus();
			 return true;
		  }
		  else
		  {
			  location.href = "thanks_msg.php";
			  return false;  
		  }
	  });	
		 
	  return false;
		
	} 
	
} 

function CheckLengthUSA(val)
{
	
	if(parseInt(val) <= 26 )
	{
	     $j.alerts.okButton = '&nbsp;&nbsp;Yes&nbsp;&nbsp;&nbsp;&nbsp;';
		 $j.alerts.cancelButton = '&nbsp;&nbsp;&nbsp;No&nbsp;&nbsp;';
		 $j.alerts.draggable = true;
		 jConfirm('Sorry, but landlords are forbidden by law to rent for less than <strong>30 DAYS MINIMUM</strong>.  Unless you can change your stay to 7 days or longer, we cannot assist you.  You would have to book a regular hotel room (we do not handle hotel stays, only serviced apartments).<br/><br/> Would you like to make this change and continue with the form? ', 'Warning', function(r) {
		  if(r==true){ 
			 $j("#lengthofstay").val("");
			 $j("#lengthofstay").focus();
			 return true;
		  }
		  else
		  {
			  location.href = "thanks_msg.php";
			  return false;  
		  }
	  });	
		 
	  return false;
		
	} 
	
} 

/* for phone validation */

/*function CheckPhone(val)
{
	
	$j('#phonemsg').hide(); 
	$j('#phone_span').removeClass("yellowBkg"); 
	$j('#mobile_span').removeClass("yellowBkg");
	
	if($j.trim(val) == '' && echeck($('emailaddress').value))
	{
	     $j.alerts.okButton = '&nbsp;&nbsp;Yes&nbsp;&nbsp;&nbsp;&nbsp;';
		 $j.alerts.cancelButton = '&nbsp;&nbsp;&nbsp;No&nbsp;&nbsp;';
		 $j.alerts.draggable = true;
		 jConfirm('We noticed you chose to leave phone contact info blank.  We just want you to know that many of our best suppliers prefer to contact you via phone to give you personalized assistance regarding their property availability.  If you leave out your phone contact info, it\'s very possible you will not hear back from some of these suppliers..<br/><br/> Would you like to add your number now? ', 'Warning', function(r) {
		  if(r==true){
			  
			 $j('#phonemsg').show(); 
			 $j('#phone_span').addClass("yellowBkg");
			 $j('#mobile_span').addClass("yellowBkg");
			 $j("#d_phone").focus();
			 return true;
		  }
		  else
		  {
			  $j('#phonemsg').hide();  
			  $j('#phone_span').removeClass("yellowBkg"); 
			  $j('#mobile_span').removeClass("yellowBkg");
			  $j("#search_com_org_y").focus();
		  }
		 
	  });	
		
	} 
	
} */

/*function CheckPhone(val, val2)
{
	
	$j('#phonemsg').hide(); 
	$j('#phone_span').removeClass("yellowBkg"); 
	$j('#mobile_span').removeClass("yellowBkg");
	
	if($j.trim(val) == '' && $j.trim(val2) == '' && echeck($('emailaddress').value))
	{
		 $j.alerts.okButton = '&nbsp;&nbsp;Yes&nbsp;&nbsp;&nbsp;&nbsp;';
		 $j.alerts.cancelButton = '&nbsp;&nbsp;&nbsp;No&nbsp;&nbsp;';
		 $j.alerts.draggable = true;
		 jConfirm('We noticed you chose to leave phone contact info blank.  We just want you to know that many of our best suppliers prefer to contact you via phone to give you personalized assistance regarding their property availability.  If you leave out your phone contact info, it\'s very possible you will not hear back from some of these suppliers..<br/><br/> Would you like to add your number now? ', 'Warning', 
		function(r) {
		  if(r==true){
			  
			 $j('#phonemsg').show(); 
			 $j('#phone_span').addClass("yellowBkg");
			 $j('#mobile_span').addClass("yellowBkg");
			 $j("#d_phone").focus();
			  return true;
		  }
		  else
		  {
			  $j('#phonemsg').hide();  
			  $j('#phone_span').removeClass("yellowBkg"); 
			  $j('#mobile_span').removeClass("yellowBkg");
			  $j("#search_com_org_y").focus();
			  $('frmReq').submit();
		  }
		 
	  });	
		 
		 
		
	} 
	
} */

/* end */ 


function checkIntval(thisval)
{
	if(Math.floor(thisval.value) == 0 )
			thisval.value = "";		
	else
			thisval.value = Math.floor(thisval.value); 
	
	
}

function considerthreeshowhide()
{
	
	val  = $('lengthofstay').value;
			 
	if(Math.floor(val) < 25 || !val )	
	{
		$('tdLeaseContract').hide();
		$('3_month_lease_n').checked = false;
		$('3_month_lease_y').checked = false;
		
	}else
	{
			
		if($('stay_long_y').checked == true){	
				$('tdLeaseContract').show();
		}
		
	}
	
}

function showCom_Org(val,div)
{
	
	if(val)
	{		

		$('search_com_org_div').style.display = '';
	}
	else
	{
		$('search_com_org_div').style.display = 'none';
	}
}
function AddCom_Org(val,div)
{
	if($('search_com_org_y').checked && $('com_name').value)
	{
		if(val)
		{					
			$('div_sign_lease_com').style.display = '';
			$('showcompanyname').innerHTML = $('com_name').value;
		}
	}
	else
	{
		$('div_sign_lease_com').style.display = 'none';
		$('com_name').value = '';
	}
}

function showPetNum(val,div)
{
	if(val)
	{								
		$('pet_num_div').style.display = '';
	}
	else
	{
		$('pet_num_div').style.display = 'none';
	}
}

function checkProperty(me,val)
{
	document.getElementById('pricecat1').checked = false;
	document.getElementById('pricecat2').checked = false;
	document.getElementById('pricecat3').checked = false;
	document.getElementById('pricecat4').checked = false;
	
	if(val)
		document.getElementById(me).checked = true;
}

function checkUnit(me,val,con)
{
	
	if(con=='Kuala Lumpur' || con=='Singapore' || con=='Auckland' || con=='Atlanta & vicinity' || con=='Boston & vicinity' || con=='Chicago & vicinity' || $('FromCountry').value == "US" )
	{
		document.getElementById('unit5').checked = false;
		document.getElementById('unit6').checked = false;
		document.getElementById('unit7').checked = false;
		document.getElementById('unit8').checked = false;
	}
	else
	{
		document.getElementById('unit5').checked = false;
		document.getElementById('unit6').checked = false;
		document.getElementById('unit7').checked = false;
	}
	if(val)
		document.getElementById(me).checked = true;
}


function showme(id)
{
	
	div_id=id.value;
	
	if(div_id == "Me")
	{
		hide_div="Else";
		$('div_sign_lease_me').style.display = 'block';
		
		$('div_sign_lease_o').style.display = 'none';
		if(!$('sign_lease_s').checked)
			$('sign_lease').value = 'me';
		
		
		$('div_occemail').style.display = 'none';
		
	}
	else
	{
		
		hide_div="Me";
		$('div_sign_lease_o').show();
		$('div_occemail').show();
	//	$('div_sign_lease_o').style.display = 'block';
	//	$('div_occemail').style.display = 'table-row';
		
	}
	if(id.checked)
	{
		document.getElementById(div_id).style.display='';
		document.getElementById(hide_div).style.display='none';
	}	
	
}

/* kinjal added 230409 */
function validate_numof(val)
{
	
	if(isNaN($('num_person').value) || trim($('num_person').value) == '')
	{
		 /*	$('num_person_span').className = 'yellowBkg';	
				alert('Please specify number of persons are staying');
				$('num_person').value = "";
				$('num_person').focus();
				return false;
		 */
	}
	else
	{
		 <!-- Old pop up -->
		/*if(val > 6)
		{
			//var msg = "You have indicated here that you are a party of "+val+" persons. Is this correct?";
			var msg = "Please confirm you're a party of "+val+" persons"
			var x = confirm(msg);	
			if(!x)
			{
				$('num_person').focus();
				$('num_person').value = "";		
				return false;
			}
			$('num_person_span').className = '';	
			$('unit1').focus();
		}*/
		
		if(val > 6)
		{
			//var msg = "You have indicated here that you are a party of "+val+" persons. Is this correct?";
			var msg = "Please confirm you're a party of "+val+" persons"
			//var x = confirm(msg);	
			
			myConfirm(msg,function(answer) {
            if(!answer){
				$('num_person').focus();
				$('num_person').value = "";		
				return false;	
				} 
				$('num_person_span').className = '';	
		    	$('unit1').focus();
				
				})		
		}
		
		
	}
}

function lowpricelevel()
{
	
	$('price_cat_span').className = '';
	
	if(!$('pricecat1').checked && $('nr0') && $('nr0').checked)
	{
		$('nr0').checked = false;	
		$('price_cat_span').className = 'yellowBkg';
		$('pricecat1').focus();
		CUSTOM_ALERT.alert('Warning','You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property type. System will not accept a request for lowest price level UNLESS you first change your property type to "lower-end" type.');		
		//alert('You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property class. System will not accept a request for lowest price level UNLESS you first change your property class to "lower-end" type.');		
	//	$('pricelevelmsg').innerHTML = 'You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property class. System will not accept a request for lowest price level UNLESS you first change your property class to "lower-end" type.';
		return false;
	}
	else
	{
		
		$('price_cat_span').className = '';
		$('pricelevelmsg').innerHTML = '';
	}
}
/*#######################################
###  VALIDATION FOR WEBFOM 1 
#########################################*/
function validateReqForm(con,From)
{	

	$('moveindate_span').className = '';
	$('stay_long').className = '';	
	$('estdate_span').className = '';	
	$('spanMonth_lease').className = '';
	$('num_person_span').className = '';	
	$('span_dwe_div').className = '';	
	$('price_cat_span').className = '';
	
	
	$('pet_span').className = '';
	$('spanPet_Yes').className = '';
	$('spandogweight1').className = '';
	$('spandogweight2').className = '';
	$('spandogweight3').className = '';
	$('spanOtherpettype').className = '';
	
	
	
	/*$('price_rat_range').className = '';*/
	
	
	if($('moveindate').value == '')
	{
		window.scrollTo(0,350);
		$('moveindate_span').className = 'yellowBkg';	
		$('moveindate').focus();
		//$('btnCalFrom').focus();
		//alert('Please enter the Move-in date');
		CUSTOM_ALERT.alert('Warning','Please enter the Move-in date.'); 
		return false;
	}
	if(isNaN($('lengthofstay').value) || trim($('lengthofstay').value) == '')
	{
		window.scrollTo(0,350);
		$('lengthofstay').focus();
		$('estdate_span').className = 'yellowBkg';
		//alert('Please specify length of stay');	
		CUSTOM_ALERT.alert('Warning','Please specify length of stay.'); 
		return false;
	}
	if(!$('stay_long_y').checked && !$('stay_long_n').checked)	
	{
		window.scrollTo(0,350);
		$('stay_long_y').focus();
		$('stay_long').className = 'yellowBkg';
		//alert('Is it possible you may stay longer?');		
		CUSTOM_ALERT.alert('Warning','Is it possible you may stay longer?');	
		return false;
	}
	if($('stay_long_y').checked)	
	{
		if(!$('3_month_lease_y').checked && !$('3_month_lease_n').checked && trim($('lengthofstay').value) > 30)	
		{
			window.scrollTo(0,350);
			$('3_month_lease_y').focus();
			$('spanMonth_lease').className = 'yellowBkg';
			//alert('Would you consider a 3 month lease if it would lower your rate?');	
			CUSTOM_ALERT.alert('Warning','Would you consider a 3 month lease if it would lower your rate?');
			return false;
		}
	}
	if(isNaN($('num_person').value) || trim($('num_person').value) == '')
	{
		window.scrollTo(0,350);
		$('num_person').focus();
		$('num_person_span').className = 'yellowBkg';	
		//alert('Please specify number of persons are staying');	
		CUSTOM_ALERT.alert('Warning','Please specify number of persons are staying.');	
		return false;
	}
	
	if(!$('unit1').checked && !$('unit2').checked && !$('unit3').checked && !$('unit4').checked)	
	{
		$('unit1').focus();
		$('span_dwe_div').className = 'yellowBkg';	
		//alert('Please specify type of dwelling you would consider');
		CUSTOM_ALERT.alert('Warning','Please specify type of dwelling you would consider.');
		return false;
	}
	
	if(!$('pricecat1').checked && !$('pricecat2').checked && !$('pricecat3').checked && !$('pricecat4').checked)	
	{
		$('pricecat1').focus();		 
		$('price_cat_span').className = 'yellowBkg';
		//alert('Based on your budget, which class of property do you want us to search for?');
		CUSTOM_ALERT.alert('Warning','Based on your budget, which class of property do you want us to search for?');
		return false;
	}
	if(!$('pricecat1').checked && ($('nr0') &&  $('nr0').checked) )
	{
		$('price_cat_span').className = 'yellowBkg';
		$('pricecat1').focus();		
		//alert('You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property class. System will not accept a request for lowest price level UNLESS you first change your property class to "lower-end" type.');
		CUSTOM_ALERT.alert('Warning','You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property type. System will not accept a request for lowest price level UNLESS you first change your property type to "lower-end" type.');
	//	$('pricelevelmsg').innerHTML = 'You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property class. System will not accept a request for lowest price level UNLESS you first change your property class to "lower-end" type.';
		return false;
	}
	else
	{
		$('price_cat_span').className = '';
		$('pricelevelmsg').innerHTML = '';
	}
	

	if(con=='Kuala Lumpur' || con=='Singapore' || con=='Auckland' || con=='Atlanta & vicinity' || con=='Boston & vicinity' || con=='Chicago & vicinity' || $('FromCountry').value == "US" )
	{
		if(!$('unit5').checked && !$('unit6').checked && !$('unit7').checked && !$('unit8').checked)	
		{
			$('unit5').focus();
			$('unit_s_div').className = 'yellowBkg';	
			//alert('Please specify size of Unit Needed');	
			CUSTOM_ALERT.alert('Warning','Please specify size of Unit Needed.');		
			return false;
		}
	}
	else
	{
		if(!$('unit5').checked && !$('unit6').checked && !$('unit7').checked)	
		{
			$('unit5').focus();
			$('unit_s_div').className = 'yellowBkg';
			//alert('Please specify size of Unit Needed');
			CUSTOM_ALERT.alert('Warning','Please specify size of Unit Needed.');		
			return false;

		}
	}
	if(!$('b_lim_m').checked && !$('b_lim_n').checked)
	{
		$('unit_s_div').className = 'yellowBkg';
		$('b_lim_m').focus();
		//alert('Please specify rental rate');
		CUSTOM_ALERT.alert('Warning','Please specify rental rate.');		
		return false;
	}
	
	if(trim($('cur').value) == '')
	{
		$('unit_s_div').className = 'yellowBkg';		
		$('cur').focus();
		//alert('Please specify currency for price range ');
		CUSTOM_ALERT.alert('Warning','Please specify currency for price range.');		
		return false;
	}
	
	var len=document.getElementsByName("nr").length;
	var err=true;
	for(var i=0;i<len;i++)
	{		
		var id= 'nr'+i;  
		if($(id).checked)
		{
			err=false;
			break;
		}		
	}
	if(err)
	{
		$('nr0').focus();
		$('unit_s_div').className = 'yellowBkg';
		//alert('Please specify maximum budget limit preferred ');
		CUSTOM_ALERT.alert('Warning','Please specify maximum budget limit preferred.');
		return false;
	}
	
	$('u_s_div').className = '';
	$('email_span').className =  '';
	$('occemail_span').className =  '';
	$('phone_span').className = '';
	$('search_com_org_span').className =  '';
	$('sea_com_span').className = '';
	$('span_sign_lease').className = '';
	$('signer_name').className = '';
	$('live_con_span').className = '';
	$('com_name').className =  '';
	if(From == 'Admin')
	{
		$('spanArea').className =  '';
		$('spanTown').className =  '';
	}
	
	
	
	if(!$('renter_me').checked && !$('renter_else').checked)	
	{
		$('renter_me').focus();
		return false;
	}
	
	if($('renter_me').checked)
	{
		var fname = trim($('firstname').value);	
		var lname = trim($('lastname').value);
		if(fname == '' || fname.length < 2 || fname.indexOf(".") != -1 )
		{
			window.scrollTo(0,350);
			$('firstname').focus();
			$('u_s_div').className = 'yellowBkg';
			//alert("Please enter inquirer's first name");
			CUSTOM_ALERT.alert("Warning","Please enter inquirer's first name.");	
			return false;
		}
		if(lname == '' || lname.length < 2 || lname.indexOf(".") != -1 )
		{
			$('u_s_div').className = 'yellowBkg';		
			$('lastname').focus();
			//alert("Please enter inquirer's last name");
			CUSTOM_ALERT.alert("Warning","Please enter inquirer's last name.");	
			return false;
		}
	}
	if($('renter_else').checked)
	{
		var fnamep = trim($('firstnamep').value);	
		var lnamep = trim($('lastnamep').value);
		var pfname = trim($('pfirstname').value);	
		var plname = trim($('plastname').value);
		
			if(fnamep == '' && fnamep.length < 2 || fnamep.indexOf(".") != -1 )
			{
				$('u_s_div').className = 'yellowBkg';		
				$('firstnamep').focus();
				//alert("Please enter inquirer's first name");
				CUSTOM_ALERT.alert("Warning","Please enter inquirer's first name.");
				return false;
			}
			if(lnamep == '' && lnamep.length < 2 || lnamep.indexOf(".") != -1 )
			{
				$('u_s_div').className = 'yellowBkg';		
				$('lastnamep').focus();
				//alert("Please enter inquirer's last name");
				CUSTOM_ALERT.alert("Warning","Please enter inquirer's last name.");
				return false;
			}
			if(pfname == '' && pfname.length < 2 || pfname.indexOf(".") != -1 )
			{
				//alert('Please enter occupant first name');
				CUSTOM_ALERT.alert("Warning","Please enter occupant first name.");
				$('u_s_div').className = 'yellowBkg';		
				$('pfirstname').focus();
				return false;
			}
			if(plname == '' && plname.length < 2 || plname.indexOf(".") != -1 )
			{
				//alert('Please enter occupant last name');
				CUSTOM_ALERT.alert("Warning","Please enter occupant last name.");
				$('u_s_div').className = 'yellowBkg';		
				$('plastname').focus();
				return false;
			}
		
	}
	
	if(!echeck(trim($('emailaddress').value)))
	{
		$('emailaddress').focus();
		$('email_span').className =  'yellowBkg';
		//alert('Please specify valid email address');	
		CUSTOM_ALERT.alert("Warning","Please specify valid email address.");
		return false;
	}
	
	if($('renter_else').checked)
	{
		if(!echeck(trim($('occemailaddress').value)))
		{
			$('occemailaddress').focus();
			$('occemail_span').className =  'yellowBkg';
			//alert('Please specify valid occupant\'s email address');	
			CUSTOM_ALERT.alert('Warning','Please specify valid occupant\'s email address.');	
			return false;
		}
	}	 
	
	if(trim($('d_phone').value) == '')
	{
				$('d_phone').focus();
				$('phone_span').className = 'yellowBkg';
				//alert('Please enter phone no.');
				CUSTOM_ALERT.alert('Warning','Please enter phone no.');	
				return false;
	}
	
	
	if(!$('search_com_org_y').checked && !$('search_com_org_n').checked)	
	{
		$('search_com_org_y').focus();
		$('search_com_org_span').className = 'yellowBkg';
		//alert('Is this search on behalf of a company or organization ?');
		CUSTOM_ALERT.alert('Warning','Is this search on behalf of a company or organization?');	
		return false;
	}
	
	if($('search_com_org_y').checked && !trim($('com_name').value))
	{
		$('search_com_org_y').focus();
		$('search_com_org_span').className = 'yellowBkg';
		$('sea_com_span').className = 'yellowBkg';
		//alert('Please enter company name');
		CUSTOM_ALERT.alert('Warning','Please enter company name.');
		return false;
	}
	
	if(!$('sign_lease_me').checked && !$('sign_lease_s').checked && !$('sign_lease_o').checked && !$('sign_lease_com').checked)	
	{
		$('sign_lease_me').focus();
		$('span_sign_lease').className = 'yellowBkg';
		CUSTOM_ALERT.alert('Warning','Who will sign this lease?');
		//alert('Who will sign this lease?');					
		return false;
	}
	if($('sign_lease_s').checked && trim($F('sign_lease')) == '')
	{
		$('sign_lease').focus();
		$('span_sign_lease').className = 'yellowBkg';
		$('signer_name').className = 'yellowBkg';
		//alert('Please specify name of lease signer');
		CUSTOM_ALERT.alert('Warning','Please specify name of lease signer.');
		return false;
	}
	
	if(trim($('live_con').value) == '')
	{
		$('live_con').focus();
		$('live_con_span').className = 'yellowBkg';	
		//alert('Please enter country or city in which you live');
		CUSTOM_ALERT.alert('Warning','Please enter country or city in which you live.');
		return false;
	}
	
	if(!$('perpose_Business').checked && !$('perpose_Pleasure').checked && !$('perpose_Medical').checked && !$('perpose_School').checked && !$('perpose_relocation').checked && !$('perpose_Other').checked )	
	{
		$('perpose_Business').focus();
		$('purpose_span').className = 'yellowBkg';
		//alert('Please specify purpose of stay ');
		CUSTOM_ALERT.alert('Warning','Please specify purpose of stay.');
		return false;
	}
	
	
	if(!$('bring_pet_y').checked && !$('bring_pet_n').checked )
	{
		$('bring_pet_y').focus();
		$('pet_span').className = 'yellowBkg';		
		//alert('Please specify pets');
		CUSTOM_ALERT.alert('Warning','Please specify pets.');
		return false;	
	}
	
	if($('bring_pet_y').checked)
	{
			if(!$('pet_type_Dog').checked  && !$('pet_type_Cat').checked  && !$('pet_type_Other').checked)
			{
				$('pet_type_Dog').focus();
				$('spanPet_Yes').className = 'yellowBkg';		
				//alert('If "yes", specify type and number of pet(s)');
				CUSTOM_ALERT.alert('Warning','If "yes", specify type and number of pet(s).');
				return false;
			}
		
			if($('pet_type_Dog').checked)
			{
				if($('HMDogs').value == 1)
				{
					if($('HMDogsWeight1').value == '')
					{
						$('HMDogsWeight1').focus();
						$('spandogweight1').className = 'yellowBkg';		
						//alert('Please enter dog weight');
						CUSTOM_ALERT.alert('Warning','Please enter dog weight.');
						return false;
					}
				}
				if($('HMDogs').value == 2)
				{
					if($('HMDogsWeight1').value == '')
					{
						$('HMDogsWeight1').focus();
						$('spandogweight1').className = 'yellowBkg';		
						//alert('Please enter dog weight');
						CUSTOM_ALERT.alert('Warning','Please enter dog weight.');
						return false;
					}
					if($('HMDogsWeight2').value == '')
					{
						$('HMDogsWeight2').focus();
						$('spandogweight2').className = 'yellowBkg';		
						//alert('Please enter dog weight');
						CUSTOM_ALERT.alert('Warning','Please enter dog weight.');
						return false;
					}
				}
				if($('HMDogs').value == 3)
				{
					if($('HMDogsWeight1').value == '')
					{
						$('HMDogsWeight1').focus();
						$('spandogweight1').className = 'yellowBkg';		
						//alert('Please enter dog weight');
						CUSTOM_ALERT.alert('Warning','Please enter dog weight.');
						return false;
					}
					if($('HMDogsWeight2').value == '')
					{
						$('HMDogsWeight2').focus();
						$('spandogweight2').className = 'yellowBkg';		
						//alert('Please enter dog weight');
						CUSTOM_ALERT.alert('Warning','Please enter dog weight.');
						return false;
					}
					if($('HMDogsWeight3').value == '')
					{
						$('HMDogsWeight3').focus();
						$('spandogweight3').className = 'yellowBkg';		
						//alert('Please enter dog weight');
						CUSTOM_ALERT.alert('Warning','Please enter dog weight.');
						return false;
					}
				}
			}
		
			if($('pet_type_Other').checked)
			{
				if($('Other_Pet_Type').value == '')
				{
					$('Other_Pet_Type').focus();
					$('spanOtherpettype').className = 'yellowBkg';	
					//alert('Please specify other pet type');
					CUSTOM_ALERT.alert('Warning','Please specify other pet type.');
					return false;
				}
			}
	}
	
	val = density();
	if(val == 'fail' )	
	{
	   return false;
	}
	
	//CheckPhone($('d_phone').value,$('m_phone').value)
	//if(($j.trim($('d_phone').value) != '') || ($j.trim($('m_phone').value) != ''))
		$('frmReq').submit();
	
	//$('frmReq').submit();
	
}

/*#######################################
###  VALIDATION FOR WEBFOM 2 -PART 1 
#########################################*/

function validateReqFormPART1(con,From)
{	
	
	$('moveindate_span').className = '';
	$('stay_long').className = '';	
	$('estdate_span').className = '';	
	$('spanMonth_lease').className = '';
	$('num_person_span').className = '';	
	$('span_dwe_div').className = '';	
	$('price_cat_span').className = '';
	$('unit_s_div').className = '';	
	/*$('price_rat_range').className = '';*/
	
	
	if($('moveindate').value == '')
	{
		window.scrollTo(0,350);
		$('moveindate_span').className = 'yellowBkg';	
		$('btnCalFrom').focus();
		alert('Please enter the Move-in date');		
		return false;
	}
	if(isNaN($('lengthofstay').value) || trim($('lengthofstay').value) == '')
	{
		window.scrollTo(0,350);
		$('lengthofstay').focus();
		$('estdate_span').className = 'yellowBkg';
		alert('Please specify length of stay');		
		return false;
	}
	if(!$('stay_long_y').checked && !$('stay_long_n').checked)	
	{
		window.scrollTo(0,350);
		$('stay_long_y').focus();
		$('stay_long').className = 'yellowBkg';
		alert('Is it possible you may stay longer?');			
		return false;
	}
	if($('stay_long_y').checked)	
	{
		if(!$('3_month_lease_y').checked && !$('3_month_lease_n').checked && trim($('lengthofstay').value) > 30 ) 	
		{
			window.scrollTo(0,350);
			$('3_month_lease_y').focus();
			$('spanMonth_lease').className = 'yellowBkg';
			alert(' Would you consider a 3 month lease if it would lower your rate?');			
			return false;
		}
	}
	if(isNaN($('num_person').value) || trim($('num_person').value) == '')
	{
		window.scrollTo(0,350);
		$('num_person').focus();
		$('num_person_span').className = 'yellowBkg';	
		alert('Please specify number of persons are staying');				
		return false;
	}
	
	if(!$('unit1').checked && !$('unit2').checked && !$('unit3').checked && !$('unit4').checked)	
	{
		$('unit1').focus();
		$('span_dwe_div').className = 'yellowBkg';	
		alert('Please specify type of dwelling you would consider');
		return false;
	}
	
	if(!$('pricecat1').checked && !$('pricecat2').checked && !$('pricecat3').checked && !$('pricecat4').checked)	
	{
		$('pricecat1').focus();	
		$('price_cat_span').className = 'yellowBkg';
		alert('Based on your budget, which class of property do you want us to search for?');				
		return false;
	}
	if(!$('pricecat1').checked && ($('nr0') &&  $('nr0').checked) )
	{
		$('price_cat_span').className = 'yellowBkg';
		$('pricecat1').focus();		
		alert('You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property class. System will not accept a request for lowest price level UNLESS you first change your property class to "lower-end" type.');
	//	$('pricelevelmsg').innerHTML = 'You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property class. System will not accept a request for lowest price level UNLESS you first change your property class to "lower-end" type.';
		return false;
	}
	else
	{
		$('price_cat_span').className = '';
		$('pricelevelmsg').innerHTML = '';
	}
	
	
	if(con=='Kuala Lumpur' || con=='Singapore'  || con=='Auckland' || con=='Atlanta & vicinity' || con=='Boston & vicinity' || con=='Chicago & vicinity' || $('FromCountry').value == "US" )
	{
		if(!$('unit5').checked && !$('unit6').checked && !$('unit7').checked && !$('unit8').checked)	
		{
			$('unit5').focus();
			$('unit_s_div').className = 'yellowBkg';	
			alert('Please specify size of Unit Needed');					
			return false;
		}
	}
	else
	{
		if(!$('unit5').checked && !$('unit6').checked && !$('unit7').checked)	
		{
			$('unit5').focus();
			$('unit_s_div').className = 'yellowBkg';
			alert('Please specify size of Unit Needed');						
			return false;
		}
	}
	if(!$('b_lim_m').checked && !$('b_lim_n').checked)
	{
		$('unit_s_div').className = 'yellowBkg';
		$('b_lim_m').focus();
		alert('Please specify rental rate');		
		return false;
	}
	
	if(trim($('cur').value) == '')
	{
		$('unit_s_div').className = 'yellowBkg';		
		$('cur').focus();
		alert('Please specify currency for price range ');			
		return false;
	}
	
	var len=document.getElementsByName("nr").length;
	var err=true;
	for(var i=0;i<len;i++)
	{		
		var id= 'nr'+i;  
		if($(id).checked)
		{
			err=false;
			break;
		}		
	}
	if(err)
	{
		$('nr0').focus();
		$('unit_s_div').className = 'yellowBkg';
		alert('Please specify maximum budget limit preferred ');				
		return false;
	}
	
	
	
	
	$('frmReq1').submit();
	/*$('PART1').hide();
	$('PART2').show();
	
	$('BACKPAGEPART1').hide();
	$('BACKPAGEPART2').show();
		
	$('PART1SUBMIT').hide();
	$('PART2SUBMIT').show();*/
	
}	

/*#######################################
###  VALIDATION FOR WEBFOM 2 -PART 1 
#########################################*/

function validateReqFormPART2(con,From)
{	

	$('u_s_div').className = '';
	$('email_span').className =  '';
	$('phone_span').className = '';
	$('search_com_org_span').className =  '';
	$('span_sign_lease').className = '';
	$('live_con_span').className = '';
	$('com_name').className =  '';
	if(From == 'Admin')
	{
		$('spanArea').className =  '';
		$('spanTown').className =  '';
	}
	
	
	
	if(!$('renter_me').checked && !$('renter_else').checked)	
	{
		$('renter_me').focus();
		return false;
	}
	
	if($('renter_me').checked)
	{
		var fname = trim($('firstname').value);	
		var lname = trim($('lastname').value);
		if(fname == '' || fname.length < 2 || fname.indexOf(".") != -1 )
		{
			window.scrollTo(0,350);
			$('firstname').focus();
			$('u_s_div').className = 'yellowBkg';
			alert("Please enter inquirer's first name");			
			return false;
		}
		if(lname == '' || lname.length < 2 || lname.indexOf(".") != -1 )
		{
			$('u_s_div').className = 'yellowBkg';		
			$('lastname').focus();
			alert("Please enter inquirer's last name");			
			return false;
		}
	}
	if($('renter_else').checked)
	{
		var fnamep = trim($('firstnamep').value);	
		var lnamep = trim($('lastnamep').value);
		var pfname = trim($('pfirstname').value);	
		var plname = trim($('plastname').value);
		
		if(fnamep == '' && fnamep.length < 2 || fnamep.indexOf(".") != -1 )
		{
			$('u_s_div').className = 'yellowBkg';		
			$('firstnamep').focus();
			alert("Please enter inquirer's first name");			
			return false;
		}
		if(lnamep == '' && lnamep.length < 2 || lnamep.indexOf(".") != -1 )
		{
			$('u_s_div').className = 'yellowBkg';		
			$('lastnamep').focus();
			alert("Please enter inquirer's last name");			
			return false;
		}
		if(pfname == '' && pfname.length < 2 || pfname.indexOf(".") != -1 )
		{
			alert('Please enter occupant first name');
			$('u_s_div').className = 'yellowBkg';		
			$('pfirstname').focus();
			return false;
		}
		if(plname == '' && plname.length < 2 || plname.indexOf(".") != -1 )
		{
			alert('Please enter occupant last name');
			$('u_s_div').className = 'yellowBkg';		
			$('plastname').focus();
			return false;
		}
	}
	
	if(!echeck(trim($('emailaddress').value)))
	{
		$('emailaddress').focus();
		$('email_span').className =  'yellowBkg';
		alert('Please specify valid email address');				
		return false;
	}
	/*if(trim($('FromCountry').value) == "US")
	{
		if(trim($('d_phone').value) == '')
		{
			$('d_phone').focus();
			$('phone_span').className = 'yellowBkg';
			alert('Please enter phone no.');				
			return false;
		}
	}*/
	
	if(!$('search_com_org_y').checked && !$('search_com_org_n').checked)	
	{
		$('search_com_org_y').focus();
		$('search_com_org_span').className = 'yellowBkg';
		alert('Is this search on behalf of a company or organization ?');					
		return false;
	}
	
	if($('search_com_org_y').checked && !trim($('com_name').value))
	{
		$('search_com_org_y').focus();
		$('search_com_org_span').className = 'yellowBkg';
		alert('Please enter company name');					
		return false;
	}
	
	if(!$('sign_lease_me').checked && !$('sign_lease_s').checked && !$('sign_lease_o').checked && !$('sign_lease_com').checked)	
	{
		$('sign_lease_me').focus();
		$('span_sign_lease').className = 'yellowBkg';
		alert('Who will sign this lease?');					
		return false;
	}
	if($('sign_lease_s').checked && trim($F('sign_lease')) == '')
	{
		$('sign_lease').focus();
		$('span_sign_lease').className = 'yellowBkg';
		alert('Please specify name of lease signer');				
		return false;
	}
	
	if(trim($('live_con').value) == '')
	{
		$('live_con').focus();
		$('live_con_span').className = 'yellowBkg';	
		alert('Please enter country or city in which you live');			
		return false;
	}
	
	$('frmReq').submit();


}

/*#######################################
###Start a search back pade div show /hide 
#########################################*/
function BackToPrerviousPartWise()
{
		$('PART1').show();
		$('PART2').hide();
		
		$('BACKPAGEPART1').show();
		$('BACKPAGEPART2').hide();
		
		$('PART1SUBMIT').show();
		$('PART2SUBMIT').hide();		
}


function loadBudgetLimitEditLead(selected,con,budgetlim)
{
	//alert(budgetlim);
	//alert(con);
	var err=false;
	if(!err)
	{
		
	var url = 'priceRate.php?lim='+budgetlim+'&con='+escape(con);	
	var rate_cur = '';
	var rate_type = '';
	var rate_unit = '';	
	if(con=='Kuala Lumpur' || con=='Singapore' || con=='Auckland' || con=='Atlanta & vicinity' || con=='Boston & vicinity' || con=='Chicago & vicinity' || $('FromCountry').value == "US" )
	{		
		if($('unit5').checked) { rate_unit = 'STUDIO'; }
		if($('unit6').checked) { rate_unit = '1BD_RM'; }
		if($('unit7').checked) { rate_unit = '2BD_RM'; }
		if($('unit8').checked) { rate_unit = '3BD_RM'; }
		
	}
	else
	{
		if($('unit5').checked) { rate_unit = 'STUDIO'; }
		if($('unit6').checked) { rate_unit = '1BD_RM'; }
		if($('unit7').checked) { rate_unit = '2BD_RM'; }
	}
	
	if($('b_lim_m').checked) { rate_type = 'MONTHLY'; }
	if($('b_lim_n').checked) { rate_type = 'NIGHTLY'; }
	
	if($F('cur') == 'Thai Baht') { rate_cur = 'THAI'; }
	if($F('cur') == 'MYR') { rate_cur = 'MYR'; }
	if($F('cur') == 'SGD') { rate_cur = 'SGD'; }
	if($F('cur') == 'AUD') { rate_cur = 'AUD'; }
	if($F('cur') == 'HKD') { rate_cur = 'HKD'; }
	if($F('cur') == 'GPB') { rate_cur = 'GPB'; }
	if($F('cur') == 'PHP') { rate_cur = 'PHP'; }
	if($F('cur') == 'Euros') { rate_cur = 'EURO'; }
	if($F('cur') == 'USD') { rate_cur = 'US'; }
	
	if(rate_type && rate_cur && rate_unit)
	{
		var qs = 'rate_type='+ rate_type +'&rate_cur='+ rate_cur +'&unit='+ rate_unit +'&selected='+ selected ;
		//alert(qs);
		
		ajaxRequest(url,qs,function(reqobj)
		{ 
			var varResponse = trim(reqobj.responseText);				
			resp = varResponse.split('|');
			custLimit = resp[1];
			$('limDiv').innerHTML = resp[0];
		});
	}
	else
	{
		if(selected == 'c')
		{
			alert('Please specify unit size, rental-rate basis and currency to get price range');
		}
		return false;
	}
	}
}

function uspricelevel()
{
	
	if(document.getElementById('unit7').checked)
	{
		document.getElementById('nr0').checked = false;
		
		var firstpriceval = document.getElementById('nr1').value;
		/*alert('The unit size you selected (2 BEDROOM) is not covered by your chosen price range.  You must select a higher price level, or change to a smaller unit size.');*/
		alert('The unit size you selected (2 BEDROOM) is not covered by your chosen price range.  You must increase your price range (starting range for this is "'+firstpriceval+'") OR reduce the size of the rental unit.');
	}
	if(document.getElementById('unit8').checked)
	{
		document.getElementById('nr0').checked = false;
		document.getElementById('nr1').checked = false;
		
		var firstpriceval = document.getElementById('nr2').value;
		/*alert('The unit size you selected (3 BEDROOM) is not covered by your chosen price range.  You must select a higher price level, or change to a smaller unit size.');*/
		alert('The unit size you selected (3 BEDROOM) is not covered by your chosen price range.  You must increase your price range (starting range for this is "'+firstpriceval+'") OR reduce the size of the rental unit.');
	}
}

function loadBudgetLimit(selected,con, budget_lim, budget_level)
{
	loadBudgetPriceDiv("",false);
	ConfirmBudgetPrice("","",false)
	
	
	var err=false;
	if(!err)
	{

	var url = 'priceRate.php';	
	var rate_cur = '';
	var rate_type = '';
	var rate_unit = '';	
	if(con=='Kuala Lumpur' || con=='Singapore'  || con=='Auckland' || con=='Atlanta & vicinity' || con=='Boston & vicinity' || con=='Chicago & vicinity' || $('FromCountry').value == "US" )
	{		
		if($('unit5').checked) { rate_unit = 'STUDIO'; }
		if($('unit6').checked) { rate_unit = '1BD_RM'; }
		if($('unit7').checked) { rate_unit = '2BD_RM'; }
		if($('unit8').checked) { rate_unit = '3BD_RM'; }
		
	}
	else
	{
		if($('unit5').checked) { rate_unit = 'STUDIO'; }
		if($('unit6').checked) { rate_unit = '1BD_RM'; }
		if($('unit7').checked) { rate_unit = '2BD_RM'; }
	}
	
	if($('b_lim_m').checked) { rate_type = 'MONTHLY'; }
	if($('b_lim_n').checked) { rate_type = 'NIGHTLY'; }
	
	if($F('cur') == 'Thai Baht') { rate_cur = 'THAI'; }
	if($F('cur') == 'MYR') { rate_cur = 'MYR'; }
	if($F('cur') == 'SGD') { rate_cur = 'SGD'; }
	if($F('cur') == 'AUD') { rate_cur = 'AUD'; }
	if($F('cur') == 'HKD') { rate_cur = 'HKD'; }
	if($F('cur') == 'GPB') { rate_cur = 'GPB'; }
	if($F('cur') == 'PHP') { rate_cur = 'PHP'; }
	if($F('cur') == 'Euros') { rate_cur = 'EURO'; }
	if($F('cur') == 'USD') { rate_cur = 'US'; }
	if($F('cur') == 'CAD') { rate_cur = 'CAD'; }
	if($F('cur') == 'NZD') { rate_cur = 'NZD'; }
	
	if(rate_type && rate_cur && rate_unit)
	{
		var qs = 'rate_type='+ rate_type +'&rate_cur='+ rate_cur +'&unit='+ rate_unit +'&selected='+ selected +'&b_lim='+ budget_lim +'&b_level='+ budget_level;
		ajaxRequest(url,qs,function(reqobj)
		{ 
			
			var varResponse = trim(reqobj.responseText);				
			resp = varResponse.split('|');
			custLimit = resp[1];
			$('limDiv').innerHTML = resp[0];
			
			if(selected && $('divcontent') != null && $('divcontent').hide())
			{
					
					$('divcontent').show();
					$('divsubnote').hide();			
					//window.scrollBy(0,700);
					$('unit_s_div').scrollTo();
			}
			$('divMaskImg').hide();	
			//alert(resp[0]);
		},null,null,$('divMaskImg').show());
		
		
		/*if(con=='Kuala Lumpur' || con=='Singapore' )
		{
			if($('unit7').checked)
			{
				//$('sel_unit_span').innerHTML = ' for 2 bedroom (fully-furnished with kitchen) ';
				$('sel_unit_span').innerHTML = ' (for fully-furnished 2 bedroom)';
			}
			else if($('unit6').checked)
			{
				//$('sel_unit_span').innerHTML = ' for 1 bedroom (fully-furnished with kitchen) ';
				$('sel_unit_span').innerHTML = ' (for fully-furnished 1 bedroom)';			
			}
			else if($('unit5').checked)
			{
				//$('sel_unit_span').innerHTML = ' for studio (fully-furnished with kitchen) ';
				$('sel_unit_span').innerHTML = ' (for fully-furnished studio)';			
			}
			else if($('unit8').checked)
			{
				//$('sel_unit_span').innerHTML = ' for studio (fully-furnished with kitchen) ';
				$('sel_unit_span').innerHTML = ' (for fully-furnished 3 bedroom)';			
			}
		}
		else
		{
			if($('unit7').checked)
			{
				//$('sel_unit_span').innerHTML = ' for 2 bedroom (fully-furnished with kitchen) ';
				$('sel_unit_span').innerHTML = ' (for fully-furnished 2 bedroom)';
			}
			else if($('unit6').checked)
			{
				//$('sel_unit_span').innerHTML = ' for 1 bedroom (fully-furnished with kitchen) ';
				$('sel_unit_span').innerHTML = ' (for fully-furnished 1 bedroom)';			
			}
			else if($('unit5').checked)
			{
				//$('sel_unit_span').innerHTML = ' for studio (fully-furnished with kitchen) ';
				$('sel_unit_span').innerHTML = ' (for fully-furnished studio)';			
			}
		}*/
	}
	else
	{
		//$('limDiv').innerHTML = '<select id="lim" name="lim"><option value=""></option></select>';
		if(selected == 'c')
		{
			alert('Please specify unit size, rental-rate basis and currency to get price range');
		}
		return false;
	}
	}
}

function showpetsproperty(val)
{
	if(val == 1)
	{
		$('trNoOfDogs1').style.display = 'block';
		$('trNoOfDogs2').style.display = 'none';
		$('trNoOfDogs3').style.display = 'none';	
		$('HMDogsWeight2').value = '';
		$('HMDogsWeight3').value = '';		
	}
	if(val == 2)
	{
		
		$('trNoOfDogs1').style.display = 'block';
		$('trNoOfDogs2').style.display = 'block';
		$('trNoOfDogs3').style.display = 'none';
		$('HMDogsWeight3').value = '';
	}
	if(val == 3)
	{
		$('trNoOfDogs1').style.display = 'block';
		$('trNoOfDogs2').style.display = 'block';
		$('trNoOfDogs3').style.display = 'block';
	}
}

function signLease(val,name)
{
	if(val && name == 's')
	{
		$('div_sign_lease').style.display = 'block';
		$('sign_lease').value = '';
	}
	else if(val && name != 's')
	{
		$('div_sign_lease').style.display = 'none';
	}
	if(val && name == 'o')
	{
		$('sign_lease').value = 'ocp';
	}
	if(val && name == 'u')
	{
		$('sign_lease').value = 'me';
	}
	if(val && name == 'c')
	{
		$('sign_lease').value = 'com';
	}
}

/*function aptCheckVal(val)
{					
		if(val.value != '' && val.value  > 2)
		{
			var msg = "You have indicated that you want to rent " + val.value + " separate housing units.\nIs this correct?" ;
			var x = confirm(msg);	
			if(!x)
			{
				val.selectedIndex = 0;	
			}
		}
}*/

function aptCheckVal(val)
{			
		if(val.value != '' && val.value  > 2)
		{
			var msg = "You have indicated that you want to rent " + val.value + " separate housing units.\nIs this correct?" ;
			//var x = confirm(msg);	
			
			myConfirm(msg, function(answer) {
             if(!answer){
				val.selectedIndex = 0;	
				}  
			})		
		}
}

function PropcatPriceValidation(pramaval)
{
	
		
		$('price_cat_span').className = '';
		$('unit_s_div').className = '';	
		if( ($('nr0') || $('nr1') || $('nr2') || $('nr3'))   &&  ( $('pricecat1') || $('pricecat2') || $('pricecat3') || $('pricecat4') ) )
		{
			
			if($('pricecat4').checked && $('nr1').checked )
			{
					//alert("Sorry, but you told us you prefer nothing less than the “High End” property class. For this, you must increase your starting budget to the "+$('nr2').value+" price level (or higher).  Otherwise, you must change your selection & check “Upper-Moderate” property class as your starting point..")
					CUSTOM_ALERT.alert("Warning","Sorry, but you told us you prefer nothing less than the “High End” property type. For this, you must increase your starting budget to the "+$('nr2').value+" price level (or higher).  Otherwise, you must change your selection & check “Upper-Moderate” property type as your starting point..")
					if(pramaval == 'propcat')
					{
						$('pricecat4').checked = false;	
						$('pricecat4').focus();
						$('price_cat_span').className = 'yellowBkg';
					}else
					{
						$('nr1').checked = false;
						$('nr1').focus();
						$('unit_s_div').className = 'yellowBkg';	
					}
					
			}	
			
			
		}
}
function ValidatePropCatUnitPriceforUS()
{
	
	$('price_cat_span').className = '';
	$('pricelevelmsg').innerHTML = '';
	
	
		if($('nr0') && $('nr0').checked) 
		{
			if( !$('unit5').checked )
			{
				
				if( !($('unit6').checked && $('pricecat1').checked )  )  
				{
					//alert('You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property class. System will not accept a request for lowest price level UNLESS you first change your property class to "lower-end" type.');		
					CUSTOM_ALERT.alert('Warning','You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property type. System will not accept a request for lowest price level UNLESS you first change your property type to "lower-end" type.');
					$('pricelevelmsg').innerHTML = 'You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property class. System will not accept a request for lowest price level UNLESS you first change your property class to "lower-end" type.';
					$('nr0').checked = false;	
				}
				
			}
			
		}else if($('nr1') && $('nr1').checked )
		{
			
			if( !$('unit5').checked && !$('unit6').checked )
			{
				
				if( !($('unit7').checked && $('pricecat1').checked )  )  
				{
					//alert('You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property class. System will not accept a request for lowest price level UNLESS you first change your property class to "lower-end" type.');
					CUSTOM_ALERT.alert('Warning','You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property type. System will not accept a request for lowest price level UNLESS you first change your property type to "lower-end" type.');
					$('pricelevelmsg').innerHTML = 'You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property class. System will not accept a request for lowest price level UNLESS you first change your property class to "lower-end" type.';
					$('nr1').checked = false;	
				}
				
			}
			
			
			
		}else if($('nr2') && $('nr2').checked )
		{
			
			if( !$('unit5').checked && !$('unit6').checked && !$('unit7').checked )
			{
				
				if( !($('unit8').checked && $('pricecat1').checked )  )  
				{
					//alert('You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property class. System will not accept a request for lowest price level UNLESS you first change your property class to "lower-end" type.');
					CUSTOM_ALERT.alert('Warning','You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property type. System will not accept a request for lowest price level UNLESS you first change your property type to "lower-end" type.');
					$('pricelevelmsg').innerHTML = 'You must select SECOND PRICE LEVEL (or higher) if you want the system to search for your preferred property class. System will not accept a request for lowest price level UNLESS you first change your property class to "lower-end" type.';
					$('nr2').checked = false;	
				}
				
			}
			
			
		}else if($('nr3') && $('nr3').checked )
		{
			
			
		}else if($('nr4') && $('nr4').checked )
		{
			
			
		} 
	 
}

/***************************************************************/
/*** Folowing code is used to add sequence validation in form **/
/***************************************************************/
function density(val)
{
		var numberunits = $('numberunits').value;
		var num_person = $('num_person').value;
		
		switch (numberunits)
		{
			case '1':
					num = 'one';
					break;
			case '2':
					num = 'two';
					break;
			case '3':
					num = 'three';
					break;	
			case '4':
					num = 'four';
					break;
			case '5':
					num = 'five';
					break;
			case '6':
					num = 'six';
					break;
			case '7':
					num = 'seven';
					break;
			case '8':
					num = 'eight';
					break;
			case '9':
					num = 'nine';
					break;
			case '10':
					num = 'ten';
					break;
			case '11':
					num = 'eleven';
					break;
			case '12':
					num = 'twelve';
					break;
			case '13':
					num = 'thirteen';
					break;
			case '14':
					num = 'fourteen';
					break;
			case '15':
					num = 'fifteen';
					break;
			case '16':
					num = 'sixteen';
					break;
			case '17':
					num = 'seventeen';
					break;
			case '18':
					num = 'eighteen';
					break;
			case '19':
					num = 'ninteen';
					break;
			case '20':
					num = 'twenty';
					break;
			case '21':
					num = 'twenty one';
					break;
			case '22':
					num = 'twenty two';
					break;
			case '23':
					num = 'twenty three';
					break;
			case '24':
					num = 'twenty four';
					break;
			case '25':
					num = 'twenty five';
					break;
			case '26':
					num = 'twenty six';
					break;
			case '27':
					num = 'twenty seven';
					break;
			case '28':
					num = 'twenty eight';
					break;
			case '29':
					num = 'twenty nine';
					break;
			case '30':
					num = 'thirty';
					break;
					
			case '31':
					num = 'thirty one';
					break;
			case '32':
					num = 'thirty two';
					break;
			case '33':
					num = 'thirty three';
					break;
			case '34':
					num = 'thirty four';
					break;
			case '35':
					num = 'thirty five';
					break;
			case '36':
					num = 'thirty six';
					break;
			case '37':
					num = 'thirty seven';
					break;
			case '38':
					num = 'thirty eight';
					break;
			case '39':
					num = 'twenty nine';
					break;
			case '40':
					num = 'fourty';
					break;
			case '41':
					num = 'fourty one';
					break;
			case '42':
					num = 'fourty two';
					break;
			case '43':
					num = 'fourty three';
					break;
			case '44':
					num = 'fourty four';
					break;
			case '45':
					num = 'fourty five';
					break;
			case '46':
					num = 'fourty six';
					break;
			case '47':
					num = 'fourty seven';
					break;
			case '48':
					num = 'fourty eight';
					break;
			case '49':
					num = 'fourty nine';
					break;
			case '50':
					num = 'fifty';
					break;
			case '51+':
					num = 'fifty plus';
					break;
			
			
		}
			if(num == 'one' )
					single = 'single';
			else
					single =num ;
		
		if( $('unit5').checked){
			var altval = $('unit5').alt ;
			var str =	"STUDIO (takes “up to 2 persons max”)";	
			var str1 = "STUDIO";
		}else if( $('unit6').checked  ){
			var altval = $('unit6').alt ;
			var str =	"1 BEDROOM (takes “up to 3 persons max”)";	
			var str1 = "1 BEDROOM";
		}else if( $('unit7').checked  ){
			var altval = $('unit7').alt ;
			var str =	"2 BEDROOM (takes “up to 5 persons max”)";	
			var str1 = "2 BEDROOM";
		}else if($('unit8') &&  $('unit8').checked ){
			var altval = $('unit8').alt ;
			var str =	"3 BEDROOM (takes “up to 7 persons max”)";	
			var str1 = "3 BEDROOM";
		}
		
	/*	alert(Math.floor(num_person))
		alert(Math.floor(numberunits))
		alert(Math.floor(altval))*/
		
		if(	Math.floor(num_person) > Math.floor(numberunits)*Math.floor(altval) )
		{
			if(val == 'units' || !val )
			{
				$('unit5').checked = false; 
				$('unit6').checked = false; 
				$('unit7').checked = false; 
				if($('unit8'))
				$('unit8').checked = false; 
				
				window.scrollTo(0,450);
				$('unit_s_div').focus();		 
				$('unit_s_div').className = 'yellowBkg';	
			}else if(val == 'num_person')
			{
					window.scrollTo(0,350);
					$('num_person').focus();
					$('num_person').value="";
					$('num_person_span').className = 'yellowBkg';	
			}
			
		
			if($('unit8') && num_person >= 8  ){
					//alert("Sorry, but density rules & regulation prohibit "+num_person+" persons into a "+single+" "+str1+"  apartment unit (see max allowed per unit listed on this form). If you want us to assist, you must first indicate you would consider renting more than "+num+" apartment, in order to cover your entire group (**also please note that our landlords don't rent anything larger than a 3 BEDROOM).");	
					CUSTOM_ALERT.alert("Warning","Sorry, but density rules & regulation prohibit "+num_person+" persons into a "+single+" "+str1+"  apartment unit (see max allowed per unit listed on this form). If you want us to assist, you must first indicate you would consider renting more than "+num+" apartment, in order to cover your entire group (**also please note that our landlords don't rent anything larger than a 3 BEDROOM).");
			}else if(!$('unit8') && num_person >= 6  ){
					//alert("Sorry, but density rules & regulation prohibit "+num_person+" persons into a "+single+" "+str1+" apartment unit (see max allowed per unit listed on this form). If you want us to assist, you must first indicate you would consider renting more than "+num+" apartment, in order to cover your entire group (**also please note that our landlords don't rent anything larger than a 2 BEDROOM ).");	
					CUSTOM_ALERT.alert("Warning","Sorry, but density rules & regulation prohibit "+num_person+" persons into a "+single+" "+str1+" apartment unit (see max allowed per unit listed on this form). If you want us to assist, you must first indicate you would consider renting more than "+num+" apartment, in order to cover your entire group (**also please note that our landlords don't rent anything larger than a 2 BEDROOM ).");
			}else{
					//alert("Sorry, but density rules & regulations prohibit "+Math.floor(num_person)+" persons into a "+str+". You must choose a larger unit size.");	
					CUSTOM_ALERT.alert("Warning","Sorry, but density rules & regulations prohibit "+Math.floor(num_person)+" persons into a "+str+". You must choose a larger unit size.");	
					return 'fail';
					return 'fail';
			}
			
			return 'fail';
			
		}
		return 'match';
}

function FieldType(obj)
{
	switch (obj.type)
	{
		case "checkbox":
			obj.checked = false;
			break;
		case "text":
			obj.value = "";
			break;
		case "radio":
			obj.checked = false;		
			break;
	}
	
}
function movein_date_validate(obj)
{
		$('moveindate_span').className = '';	
		if($('moveindate').value == '')
		{
			FieldType(obj);
			window.scrollTo(0,350);
			$('moveindate_span').className = 'yellowBkg';	
			//$('btnCalFrom').focus();
			$('moveindate').focus();
			//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the Move-in date');
			CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the Move-in date');	
			return 'fail';	
			
		}			
}
function length_stay_validate(obj)
{
	$('estdate_span').className = '';	
		if(isNaN($('lengthofstay').value) || trim($('lengthofstay').value) == '')
		{
			FieldType(obj);
			window.scrollTo(0,350);
			$('lengthofstay').focus();
			$('estdate_span').className = 'yellowBkg';
			//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the length of stay');
			CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the length of stay.');
			return 'fail';
			
		}		
}

function staylonger_validate(obj)
{
	$('stay_long').className = '';	
	if(!$('stay_long_y').checked && !$('stay_long_n').checked)	
	{
		FieldType(obj);	
		window.scrollTo(0,350);
		$('stay_long_y').focus();
		$('stay_long').className = 'yellowBkg';
		//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us, if is it possible you may stay longer?');	
		CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us, if is it possible you may stay longer?');
		return 'fail';
	}
}

function three_month_lease(obj)
{
	$('spanMonth_lease').className = '';	
	if($('stay_long_y').checked)	
		{
			if(trim($('lengthofstay').value) >= 25 && !$('3_month_lease_y').checked && !$('3_month_lease_n').checked )	
			{
					FieldType(obj);
					window.scrollTo(0,350);
					$('3_month_lease_y').focus();
					$('spanMonth_lease').className = 'yellowBkg';
					//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\n First you must tell us, if you would consider a 3 month lease if it would be lower your rate?');
					CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\n First you must tell us, if you would consider a 3 month lease if it would be lower your rate?');
					return 'fail';
			}
		}
}
function person_stay_validate(obj)
{
	$('num_person_span').className = '';	
	if(isNaN($('num_person').value) || trim($('num_person').value) == '')
	{
		FieldType(obj);
		window.scrollTo(0,350);
		$('num_person').focus();
		$('num_person_span').className = 'yellowBkg';	
		//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the number of persons are staying');
		CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the number of persons are staying.');
		return 'fail';	
	}
}
function dwelling_validate(obj)
{
	$('span_dwe_div').className = '';
	if(!$('unit1').checked && !$('unit2').checked && !$('unit3').checked && !$('unit4').checked)	
	{
		FieldType(obj);
		window.scrollTo(0,350);	
		$('unit1').focus();
		$('span_dwe_div').className = 'yellowBkg';	
		//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the type of dwelling you would consider');
		CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the type of dwelling you would consider.');
		return 'fail';
	}
}
function property_validate(obj)
{
	$('price_cat_span').className = '';
	if(!$('pricecat1').checked && !$('pricecat2').checked && !$('pricecat3').checked && !$('pricecat4').checked)	
	{
		FieldType(obj);
		window.scrollTo(0,350);
		$('pricecat1').focus();		 
		$('price_cat_span').className = 'yellowBkg';
		//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us which class of property you want us to search for');	
		CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us which class of property you want us to search for.');
		return 'fail';
	}
}
function units_validate(obj)
{
	$('unit_s_div').className = '';	
		var con = $('CountryName').value; 
		if(con=='Kuala Lumpur' || con=='Singapore'  || con=='Auckland' || con=='Atlanta & vicinity' || con=='Boston & vicinity' || con=='Chicago & vicinity' || $('FromCountry').value == "US" )
		{
			if(!$('unit5').checked && !$('unit6').checked && !$('unit7').checked && !$('unit8').checked)	
			{
				FieldType(obj);
				window.scrollTo(0,750);
				$('unit5').focus();
				$('unit_s_div').className = 'yellowBkg';	
				//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the size of Unit Needed');	
				CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the size of Unit Needed.');
				return 'fail';
			}
		}
		else
		{
			
			
			if(!$('unit5').checked && !$('unit6').checked && !$('unit7').checked)	
			{
				FieldType(obj);
				window.scrollTo(0,750);
				$('unit5').focus();
				$('unit_s_div').className = 'yellowBkg';
				//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the size of Unit Needed');
				CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the size of Unit Needed.');
				return 'fail';
			}
		}
}
function price_validate(obj)
{
	$('unit_s_div').className = '';	
		var len=document.getElementsByName("nr").length;
		var err=true;
		for(var i=0;i<len;i++)
		{		
			var id= 'nr'+i;  
			if($(id).checked)
			{
				err=false;
				break;
			}		
		}
		if(err)
		{
			FieldType(obj);
			window.scrollTo(0,750);	
			$('nr0').focus();
			$('unit_s_div').className = 'yellowBkg';
			//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us your maximum budget limit you preferred');	
			CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us your maximum budget limit you preferred.');
			return 'fail';
		}	
}
function rentar_validate(obj)
{
	$('u_s_div').className = '';
		
	if($('renter_me').checked)
	{
			var fname = trim($('firstname').value);	
			var lname = trim($('lastname').value);
			
			if(fname == '' || fname.length < 2 || fname.indexOf(".") != -1 )
			{
				FieldType(obj);
				window.scrollTo(0,950);
				$('firstname').focus();
				$('u_s_div').className = 'yellowBkg';
				//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the inquirer\'s first name');
				CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the inquirer\'s first name.');
				return 'fail';
			}
			if(lname == '' || lname.length < 2 || lname.indexOf(".") != -1 )
			{
				FieldType(obj);
				window.scrollTo(0,950);
				$('u_s_div').className = 'yellowBkg';		
				$('lastname').focus();
				alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the inquirer\'s last name');	
				return 'fail';
			}
	}
	if($('renter_else').checked)
	{
		  var fnamep = trim($('firstnamep').value);	
			var lnamep = trim($('lastnamep').value);
			var pfname = trim($('pfirstname').value);	
			var plname = trim($('plastname').value);
			
				if(fnamep == '' && fnamep.length < 2 || fnamep.indexOf(".") != -1 )
				{
					FieldType(obj);
					window.scrollTo(0,950);
					$('u_s_div').className = 'yellowBkg';		
					$('firstnamep').focus();
					//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the inquirer\'s first name');	
					CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the inquirer\'s first name.');
					return 'fail';
				}
				if(lnamep == '' && lnamep.length < 2 || lnamep.indexOf(".") != -1 )
				{
					FieldType(obj);
					window.scrollTo(0,950);
					$('u_s_div').className = 'yellowBkg';		
					$('lastnamep').focus();
					//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the inquirer\'s last name');	
					CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the inquirer\'s last name.');
					return 'fail';
				}
				if(pfname == '' && pfname.length < 2 || pfname.indexOf(".") != -1 )
				{
					FieldType(obj);
					window.scrollTo(0,950);
					//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the occupant\'s first name');
					CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the occupant\'s first name.');	
					$('u_s_div').className = 'yellowBkg';		
					$('pfirstname').focus();
					return 'fail';
				}
				if(plname == '' && plname.length < 2 || plname.indexOf(".") != -1 )
				{
					FieldType(obj);
					window.scrollTo(0,950);	
					//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the occupant\'s last name');	
					CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the occupant\'s last name.');
					$('u_s_div').className = 'yellowBkg';		
					$('plastname').focus();
					return 'fail';
				}
	}
}
function email_validate(obj)
{
	$('email_span').className =  '';
	if(!echeck(trim($('emailaddress').value)))
	{
		FieldType(obj);
		window.scrollTo(0,1200);		
		$('emailaddress').focus();
		$('email_span').className =  'yellowBkg';
		//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the valid email address');
		CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the valid email address.');	
		return 'fail';
	}	
}
function occemail_validate(obj)
{
	$('occemail_span').className =  '';
	if($('renter_else').checked)
	{
		if(!echeck(trim($('occemailaddress').value)))
		{
			FieldType(obj);
			window.scrollTo(0,1200);	
			$('occemailaddress').focus();
			$('occemail_span').className =  'yellowBkg';
			//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the valid occupant\'s email address');
			CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the valid occupant\'s email address.');
			return 'fail';
		}
	}	 
}
function phone_validate(obj)
{
	$('phone_span').className = '';
	//if(trim($('FromCountry').value) == "US")
	//{
			if(trim($('d_phone').value) == '')
			{
				FieldType(obj);
				window.scrollTo(0,1200);		
				$('d_phone').focus();
				$('phone_span').className = 'yellowBkg';
				//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the phone number');	
				CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the phone number.');	
				return 'fail';
			}
	//}
}
function behalf_validate(obj)
{	
	$('search_com_org_span').className = '';
	if(!$('search_com_org_y').checked && !$('search_com_org_n').checked)	
	{
		FieldType(obj);
		window.scrollTo(0,1200);		
		$('search_com_org_y').focus();
		$('search_com_org_span').className = 'yellowBkg';
		//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us this search is for behalf of a company or organization');	
		CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us this search is for behalf of a company or organization.');
		return 'fail';
	}
	
	if($('search_com_org_y').checked && !trim($('com_name').value))
	{
		FieldType(obj);
		window.scrollTo(0,1200);		
		$('search_com_org_y').focus();
		$('search_com_org_span').className = 'yellowBkg';
		//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the name of your company ');	
		CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the name of your company.');
		return 'fail';
	}
}
function lease_signer_validate(obj)
{	
	$('span_sign_lease').className = '';
	
	if(!$('sign_lease_me').checked && !$('sign_lease_s').checked && !$('sign_lease_o').checked && !$('sign_lease_com').checked)	
	{
		FieldType(obj);
		window.scrollTo(0,1200);	
		$('sign_lease_me').focus();
		$('span_sign_lease').className = 'yellowBkg';
		//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us who is going to sign the lease');	
		CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us who is going to sign the lease.');
		return 'fail';
	}
	if($('sign_lease_s').checked && trim($F('sign_lease')) == '')
	{
		FieldType(obj);
		window.scrollTo(0,1200);		
		$('sign_lease').focus();
		$('span_sign_lease').className = 'yellowBkg';
		//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the name of lease signer');
		CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the name of lease signer.');	
		return 'fail';
	}
}
function country_validate(obj)
{	
	$('live_con_span').className = '';	
	if(trim($('live_con').value) == '')
	{
		FieldType(obj);
		window.scrollTo(0,1200);		
		$('live_con').focus();
		$('live_con_span').className = 'yellowBkg';	
		//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the name of country or city in which you live');	
		CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the name of country or city in which you live.');
		return 'fail';
	}
}

function purpose_validate(obj)
{
	$('purpose_span').className = '';
	if(!$('perpose_Business').checked && !$('perpose_Pleasure').checked && !$('perpose_Medical').checked && !$('perpose_School').checked && !$('perpose_relocation').checked && !$('perpose_Other').checked )	
	{
		FieldType(obj);
		window.scrollTo(0,1200);			
		$('perpose_Business').focus();
		$('purpose_span').className = 'yellowBkg';
		//alert('FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the purpose of stay');	
		CUSTOM_ALERT.alert('Warning','FORM REQUIRES ANSWERS ALL BE IN ORDER OF APPEARANCE.\nFirst you must tell us the purpose of stay.');
		return 'fail';
	}
}
function pets_validate(obj)
{
	$('spanPet_Yes').className = '';
	$('spandogweight1').className = '';	
	$('spandogweight2').className = '';		
	$('spandogweight3').className = '';	
	$('spanOtherpettype').className = '';	
	
	if($('bring_pet_y').checked)
	{
			if(!$('pet_type_Dog').checked  && !$('pet_type_Cat').checked  && !$('pet_type_Other').checked)
			{
					$('pet_type_Dog').focus();
				$('spanPet_Yes').className = 'yellowBkg';		
				//alert('If "yes", specify type and number of pet(s)');
				CUSTOM_ALERT.alert('Warning','If "yes", specify type and number of pet(s).');
				return 'fail';
			}
		
			if($('pet_type_Dog').checked)
			{
						if($('HMDogs').value == 1)
					{
						if($('HMDogsWeight1').value == '')
						{
							$('HMDogsWeight1').focus();
							$('spandogweight1').className = 'yellowBkg';		
							//alert('Please enter dog weight');
							CUSTOM_ALERT.alert('Warning','Please enter dog weight.');
							return 'fail';
						}
					}
					if($('HMDogs').value == 2)
					{
						if($('HMDogsWeight1').value == '')
						{
							$('HMDogsWeight1').focus();
							$('spandogweight1').className = 'yellowBkg';		
							//alert('Please enter dog weight');
							CUSTOM_ALERT.alert('Warning','Please enter dog weight.');
							return 'fail';
						}
						if($('HMDogsWeight2').value == '')
						{
							$('HMDogsWeight2').focus();
							$('spandogweight2').className = 'yellowBkg';		
							//alert('Please enter dog weight');
							CUSTOM_ALERT.alert('Warning','Please enter dog weight.');
							return 'fail';
						}
					}
					if($('HMDogs').value == 3)
					{
						if($('HMDogsWeight1').value == '')
						{
							$('HMDogsWeight1').focus();
							$('spandogweight1').className = 'yellowBkg';		
							//alert('Please enter dog weight');
							CUSTOM_ALERT.alert('Warning','Please enter dog weight.');
							return 'fail';
						}
						if($('HMDogsWeight2').value == '')
						{
							$('HMDogsWeight2').focus();
							$('spandogweight2').className = 'yellowBkg';		
							//alert('Please enter dog weight');
							CUSTOM_ALERT.alert('Warning','Please enter dog weight.');
							return 'fail';
						}
						if($('HMDogsWeight3').value == '')
						{
							$('HMDogsWeight3').focus();
							$('spandogweight3').className = 'yellowBkg';		
							//alert('Please enter dog weight');
							CUSTOM_ALERT.alert('Warning','Please enter dog weight.');
							return 'fail';
						}
					}
			}
		
			if($('pet_type_Other').checked)
			{
				if($('Other_Pet_Type').value == '')
				{
					$('Other_Pet_Type').focus();
					$('spanOtherpettype').className = 'yellowBkg';	
					//alert('Please specify other pet type');
					CUSTOM_ALERT.alert('Warning','Please specify other pet type.');
					return 'fail';
				}
			}
	}

}

function FirstValidatelengthofstay(obj)
{
	if(movein_date_validate(obj) == "fail" )
		return false;	
	
	if( Math.floor(obj.value) > 365) 
	{ 
			$('estdate_span').className='yellowBkg'; 
			alert('System does not accept stays of more than 1 year (365 days max)'); 
			obj.value='';  
	}
	
}
function FirstValidateStayLonger(obj)
{
	if(movein_date_validate(obj) == "fail" )
		return false;
	
	if(length_stay_validate(obj) == "fail" )
		return false;	
}
function FirstValidateNoOfPerson(obj)
{
	if(movein_date_validate(obj) == "fail" )
		return false;
	
	if(length_stay_validate(obj) == "fail" )
		return false;	
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
}
function FirstValidateDwellings(obj) 
{
	if(movein_date_validate(obj) == "fail" )
		return false;
	
	if(length_stay_validate(obj) == "fail" )
		return false;	
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
	
	if(person_stay_validate(obj) == "fail")
		return false;
}
function FirstValidateProperty(obj) 
{
	if(movein_date_validate(obj) == "fail" )
		return false;
	
	if(length_stay_validate(obj) == "fail" )
		return false;	
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
	
	if(person_stay_validate(obj) == "fail" )
		return false;
		
	if(dwelling_validate(obj) == "fail" )
		return false;	
}
function FirstValidateUnits(obj) 
{
	if(movein_date_validate(obj) == "fail" )
		return false;
	
	if(length_stay_validate(obj) == "fail" )
		return false;	
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
	
	if(person_stay_validate(obj) == "fail" )
		return false;
		
	if(dwelling_validate(obj) == "fail" )
		return false;	
		
	if(property_validate(obj) == "fail" )
		return false;	
	
	if(!density('units') == "fail") 
			return false;	
}
function FirstValidateRentarName(obj)
{
	if(movein_date_validate(obj) == "fail" )
		return false;
		
	if(length_stay_validate(obj) == "fail" )
		return false;
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
		
	if(person_stay_validate(obj) == "fail" )
		return false;
		
	if(dwelling_validate(obj) == "fail" )
		return false;
		
	if(property_validate(obj) == "fail" )
		return false;
		
	if(units_validate(obj) == "fail" )
		return false;	
		
	if(price_validate(obj) == "fail" )
		return false;
	
}
function FirstValidateEmail(obj)
{		
	if(movein_date_validate(obj) == "fail" )
		return false;
		
	if(length_stay_validate(obj) == "fail" )
		return false;
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
		
	if(person_stay_validate(obj) == "fail" )
		return false;
		
	if(dwelling_validate(obj) == "fail" )
		return false;
		
	if(property_validate(obj) == "fail" )
		return false;
		
	if(units_validate(obj) == "fail" )
		return false;	
		
	if(price_validate(obj) == "fail" )
		return false;
		
	if(rentar_validate(obj) == "fail" )
		return false;
		
	
}
function FirstValidateOccEmail(obj)
{
	if(movein_date_validate(obj) == "fail" )
		return false;
		
	if(length_stay_validate(obj) == "fail" )
		return false;
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
		
	if(person_stay_validate(obj) == "fail" )
		return false;
		
	if(dwelling_validate(obj) == "fail" )
		return false;
		
	if(property_validate(obj) == "fail" )
		return false;
		
	if(units_validate(obj) == "fail" )
		return false;	
		
	if(price_validate(obj) == "fail" )
		return false;
		
	if( ($('firstname').value !='' && $('lastname').value !='') ||  ($('firstnamep').value !='' && $('lastnamep').value !='') || ( $('pfirstname').value !='' && $('plastname').value !='' ) )
	{	
		if($('emailadress').value)
		{
			if(rentar_validate(obj) == "fail" )
				return false;
		}
			
		if(email_validate(obj) == "fail" )
			return false;
	}
	
}
function FirstValidatePhone(obj)
{
	if(movein_date_validate(obj) == "fail" )
		return false;
		
	if(length_stay_validate(obj) == "fail" )
		return false;
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
		
	if(person_stay_validate(obj) == "fail" )
		return false;
		
	if(dwelling_validate(obj) == "fail" )
		return false;
		
	if(property_validate(obj) == "fail" )
		return false;
		
	if(units_validate(obj) == "fail" )
		return false;	
		
	if(price_validate(obj) == "fail" )
		return false;
		
	/*if(rentar_validate(obj) == "fail" )
		return false;*/
		
	if($('emailaddress').value !='' || $('occemailaddress').value !='' )
	{
		if(rentar_validate(obj) == "fail" )
			return false;
	}	
		
	/*if(email_validate(obj) == "fail" )
		return false;
		
	if(occemail_validate(obj) == "fail" )
		return false;*/	
		
	if( ($('firstname').value !='' && $('lastname').value !='') ||  ($('firstnamep').value !='' && $('lastnamep').value !='') || ( $('pfirstname').value !='' && $('plastname').value !='' ) )
	{
		if(email_validate(obj) == "fail" )
			return false;
			
		if(occemail_validate(obj) == "fail" )
			return false;	
	}	
	
	
}
function FirstValidateSearchForCompany(obj)
{
	if(movein_date_validate(obj) == "fail" )
		return false;
		
	if(length_stay_validate(obj) == "fail" )
		return false;
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
		
	if(person_stay_validate(obj) == "fail" )
		return false;
		
	if(dwelling_validate(obj) == "fail" )
		return false;
		
	if(property_validate(obj) == "fail" )
		return false;
		
	if(units_validate(obj) == "fail" )
		return false;	
		
	if(price_validate(obj) == "fail" )
		return false;
		
	if(rentar_validate(obj) == "fail" )
		return false;
		
	if(email_validate(obj) == "fail" )
		return false;
		
	if(occemail_validate(obj) == "fail" )
		return false;	
		
	if(phone_validate(obj) == "fail" )
		return false;		
	
	
}
function FirstValidateLeaseSigner(obj)
{
	if(movein_date_validate(obj) == "fail" )
		return false;
		
	if(length_stay_validate(obj) == "fail" )
		return false;
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
		
	if(person_stay_validate(obj) == "fail" )
		return false;
		
	if(dwelling_validate(obj) == "fail" )
		return false;
		
	if(property_validate(obj) == "fail" )
		return false;
		
	if(units_validate(obj) == "fail" )
		return false;	
		
	if(price_validate(obj) == "fail" )
		return false;
		
	if(rentar_validate(obj) == "fail" )
		return false;
		
	if(email_validate(obj) == "fail" )
		return false;
		
	if(occemail_validate(obj) == "fail" )
		return false;	
		
	if(phone_validate(obj) == "fail" )
		return false;		
		
	if(behalf_validate(obj) == "fail" )
		return false;		
	
	
}
function FirstValidateCountry(obj)
{
	if(movein_date_validate(obj) == "fail" )
		return false;
		
	if(length_stay_validate(obj) == "fail" )
		return false;
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
		
	if(person_stay_validate(obj) == "fail" )
		return false;
		
	if(dwelling_validate(obj) == "fail" )
		return false;
		
	if(property_validate(obj) == "fail" )
		return false;
		
	if(units_validate(obj) == "fail" )
		return false;	
		
	if(price_validate(obj) == "fail" )
		return false;
		
	if(rentar_validate(obj) == "fail" )
		return false;
		
	if(email_validate(obj) == "fail" )
		return false;
		
	if(occemail_validate(obj) == "fail" )
		return false;	
		
	if(phone_validate(obj) == "fail" )
		return false;		
		
	if(behalf_validate(obj) == "fail" )
		return false;		
		
	if(lease_signer_validate(obj) == "fail" )
		return false;		

}
function FirstValidatePurpose(obj)
{
	if(movein_date_validate(obj) == "fail" )
		return false;
		
	if(length_stay_validate(obj) == "fail" )
		return false;
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
		
	if(person_stay_validate(obj) == "fail" )
		return false;
		
	if(dwelling_validate(obj) == "fail" )
		return false;
		
	if(property_validate(obj) == "fail" )
		return false;
		
	if(units_validate(obj) == "fail" )
		return false;	
		
	if(price_validate(obj) == "fail" )
		return false;
		
	if(rentar_validate(obj) == "fail" )
		return false;
		
	if(email_validate(obj) == "fail" )
		return false;
		
	if(occemail_validate(obj) == "fail" )
		return false;	
		
	if(phone_validate(obj) == "fail" )
		return false;		
		
	if(behalf_validate(obj) == "fail" )
		return false;		
		
	if(lease_signer_validate(obj) == "fail" )
		return false;		
		
	if(country_validate(obj) == "fail" )
		return false;					
}
function FirstValidatePets(obj)
{
	if(movein_date_validate(obj) == "fail" )
		return false;
		
	if(length_stay_validate(obj) == "fail" )
		return false;
		
	if(staylonger_validate(obj) == "fail" )
		return false;
		
	if(three_month_lease(obj) == "fail" )
		return false;
		
	if(person_stay_validate(obj) == "fail" )
		return false;
		
	if(dwelling_validate(obj) == "fail" )
		return false;
		
	if(property_validate(obj) == "fail" )
		return false;
		
	if(units_validate(obj) == "fail" )
		return false;	
		
	if(price_validate(obj) == "fail" )
		return false;
		
	if(rentar_validate(obj) == "fail" )
		return false;
		
	if(email_validate(obj) == "fail" )
		return false;
		
	if(occemail_validate(obj) == "fail" )
		return false;	
		
	if(phone_validate(obj) == "fail" )
		return false;		
		
	if(behalf_validate(obj) == "fail" )
		return false;		
		
	if(lease_signer_validate(obj) == "fail" )
		return false;		
		
	if(country_validate(obj) == "fail" )
		return false;		
	
	if(purpose_validate(obj) == "fail" )
		return false;		
		
		
}
function pricerange_uncheck()
{

		if($("div_budgetpriceMessage").style.display != "none")
		{
				
				$('divcontent').show();
				$("div_budgetpriceMessage").hide();
					 	 	 
		}
		if($('nr0') || $('nr1') || $('nr2') || $('nr3'))
		{
				$('nr0').checked = false;
				$('nr1').checked = false;
				$('nr2').checked = false;
				$('nr3').checked = false;
				
		}
}

/*###########################################################
### Show Budget price when click on first price range...       
#############################################################*/
function loadBudgetPriceDiv(objval,flag,checklowbudget)
{
		
		if(checklowbudget)
		{
			if(lowpricelevel() == false)
			{
				 return false;		
			}
		}
		
		if($('b_lim_n').checked)
			var ratebasis = "N";
		else if( $('b_lim_m').checked)
			var ratebasis = "M";
		 
		
	if(flag)
	{
				
				jQuery.alerts.okButton = 'Confirmed';
				jQuery.alerts.cancelButton = 'Change';
				jQuery.alerts.draggable = true;
				jQuery.alerts.horizontalOffset = 0;
				jQuery.alerts.verticalOffset = -300;
				jConfirm('<strong>**Please note that the lowest price range is usually BELOW market averages, and this will likely limit the offers you\'ll receive (especially if you\'re looking in prime locations).<br/><br/>If that\'s OK, confirm your selection of LOWEST PRICE RANGE (if not OK, click "Change").</strong>', 'Please Confirm', function(r) {
					 if(r==true)
					 {
						 	
							if( $('FromCountry').value =='ASIA')
							{
								
							}else
							{
								
									var cur = $("cur").value;
									var url = 'budgetprice.php';	
									var qs = 'pricerange='+ objval+'&ratebasis='+ratebasis+'&cur='+cur;
									ajaxRequest(url,qs,function(reqobj)
									{ 
										var varResponse = trim(reqobj.responseText);				
										$('divMaskImg').hide()
										$('div_budgetprice').show();
										$('div_budgetprice').innerHTML =varResponse ;
										$('unit_s_div').scrollTo();
										
									},null,null,$('divMaskImg').show());
							}
							
					 } 
					 else
					 {
							$("nr0").checked = false;
							$('nr1').checked = true ;
							$('div_budgetprice').hide();
							if($('budgetprice'))
								$('budgetprice').disabled = true;
						
							return false;
					 }
				});
				
				
				//$('#popup_container').width('575px');

				
				
	}else
	{
			$('div_budgetprice').hide();
			if($('budgetprice'))
					$('budgetprice').disabled = true;
	}
	
}

/*###########################################################
### Show Confirmation message when select budget price.... 
#############################################################*/
function ConfirmBudgetPrice(thisObj,startrange,flag)
{
	
	
	if(flag == false)
	{
		
		$('div_budgetpriceMessage').hide();
		if($('budgetprice'))
				$('budgetprice').selectedIndex = -1;
	
	}else
	{
		
		var thisval =  thisObj.value;
		//alert(thisval);
		 if(thisval.indexOf("under")>-1)
		 {
				thisval = thisval.sub('under','');
				var under = "under ";
		}else{
			var under = "";
		}
		
		if( $("cur").value  == "USD")
				 var ShowFPrice = under+"$"+thisval;
		else if($("cur").value  == "CAD")
			   var ShowFPrice = under+thisval+"CAD";	
				
				
		if(under !="")
				var ShowFPrice = '"'+ShowFPrice+'"';
		
		
		jQuery.alerts.okButton = 'Confirmed';
		jQuery.alerts.cancelButton = 'Change'; 
		jQuery.alerts.draggable = true;
		jQuery.alerts.horizontalOffset = 0;
		jConfirm('<strong>Please confirm that you\'ve selected '+ShowFPrice+' as your actual maximum budget price.</strong>', 'Please Confirm', function(r) {
					if(r==true)
					{
							$('divcontent').hide();
							$('div_budgetprice').hide();
							$('div_budgetpriceMessage').show();
							
							var per = Math.round( (thisObj.value*100)/startrange) ;
							if(per > 85 )
									$('div_budgetpriceMessage').update('<span style="color: rgb(255, 0, 0);font-size:14px"><strong>*Note: You requested Budget Price search for '+ShowFPrice+' max</span><br/>(Good news! We can still help you with this search)</strong>')
							else
									$('div_budgetpriceMessage').update('<span style="color: rgb(255, 0, 0);font-size:14px"><strong>*Note: You requested Budget Price search for '+ShowFPrice+' max</span></strong>')
									
							$('price_cat_span').scrollTo();
					} 
					else
					{
							$('budgetprice').selectedIndex = -1;
					}
			});
	}
		
}