
function samecopy(frm)
{		
	document.frm.ShipToFirstName.value=document.frm.FirstName.value;
	document.frm.ShipToLastName.value=document.frm.LastName.value;
	document.frm.ShipToStreet1.value=document.frm.Street1.value;
	document.frm.ShipToStreet2.value=document.frm.Street2.value;
	document.frm.ShipToCityName.value=document.frm.city.value;
	document.frm.ShipToStateOrProvince.value=document.frm.StateOrProvince.value;
	document.frm.ShipToCountry.value=document.frm.Country.value;
	document.frm.ShipToPostalCode.value=document.frm.PostalCode.value;
	return true; 
}   

function check(){
	var brtyp=document.agentfrm.broker.value;
	if(brtyp=="t")
		document.getElementById('binfo').style.display="";
}


function changefoc1()
{	
	//alert(val1);
	if(frm.areacode.value.length=="3")
	{
		frm.agentmobile.focus();
		return true;
	}
	return true;
}
function changefoc2()
{	
	//alert(val1);
	if(frm.agentoffice_phonecode.value.length=="3")
	{
		frm.agentoffice_phone.focus();
		return true;
		
	}
	return true;
}

function changefoc3()
{	
	//alert(val1);
	if(frm.agentoffice_faxcode.value.length=="3")
	{
		frm.agentoffice_fax.focus();
		return true;
		
	}
	return true;
}
function phonechk(str){

var re10digit= /^\d{3}-\d{4}$/;
if (str.search(re10digit)==-1) {
return false;
} 

return true;
}

function phonechk1(str){

var re10digit= /^\d{3}-\d{3}-\d{4}$/;
if (str.search(re10digit)==-1) {
return false;
} 

return true;
}
var v="a";

function updatevalid(agentfrm)
{	
	if(v=="a"){
		if(agentfrm.agentemail.value=="")
		{	
			alert("Please enter your email address");
			agentfrm.agentemail.focus();
			return false;
		}
		if(echeck(agentfrm.agentemail.value)==false)
		{
			alert("Invalid Email-id");
			agentfrm.agentemail.focus();
			return false;
		}
		if(agentfrm.agentpassword.value=="")
		{
			alert("Please enter your password, password must be at least 8 characters in length");
			agentfrm.agentpassword.focus();
			return false;
		}
		if(agentfrm.agentpassword.value.length<8)
		{
			alert("Password must be atleast 8 characters in length");
			agentfrm.agentpassword.focus();
			return false;
		}
		if(agentfrm.confpassword.value=="")
		{	
			alert("Please confirm your password");
			agentfrm.confpassword.focus();
			return false;
		}
		if((agentfrm.confpassword.value!="")&&(agentfrm.agentpassword.value!=""))
		{
			if(agentfrm.confpassword.value!=agentfrm.agentpassword.value)
			{	
				alert("Password mismatch.Please check");
				agentfrm.confpassword.focus();
				return false;
			}
		}
		if(agentfrm.agentid.value=="")
		{	
			alert("Please enter your Agent ID");
			agentfrm.agentid.focus();
			return false;
		}
	   if(agentfrm.agentid.value.length<5)
		{	
			alert("Agent ID must be atleast 5 character long");
			agentfrm.agentid.focus();
			return false;
		}
	}
	if(v=="b" && agentfrm.agentpassword.value!="")
	{
		if(agentfrm.agentpassword.value.length<8)
		{
			alert("Password must be at least 8 characters in length");
			agentfrm.agentpassword.focus();
			return false;
		}
		if(agentfrm.confpassword.value=="")
		{	
			alert("Please confirm your password");
			agentfrm.confpassword.focus();
			return false;
		}
		if((agentfrm.confpassword.value!="")&&(agentfrm.agentpassword.value!=""))
		{
			if(agentfrm.confpassword.value!=agentfrm.agentpassword.value)
			{	
				alert("Password mismatch.Please check");
				agentfrm.confpassword.focus();
				return false;
			}
		}
	}
	if(agentfrm.agentfname.value=="")
	{
		alert("Please enter your First Name");
		agentfrm.agentfname.focus();
		return false;
	}
	if(agentfrm.agentlname.value=="")
	{
		alert("Please enter your Last Name");
		agentfrm.agentlname.focus();
		return false;
	}
	if(agentfrm.agentaddress.value=="")
	{
		alert("Please enter address");
		agentfrm.agentaddress.focus();
		return false;
	}
	if(agentfrm.agentcity.value=="")
	{	
		alert(" Please enter city");
		agentfrm.agentcity.focus();
		return false;
	}
	if(agentfrm.agentzip.value=="")
	{
		alert("Please enter zip");
		agentfrm.agentzip.focus();
		return false;
	}
	if((agentfrm.agentzip.value.length<5) || isNaN(agentfrm.agentzip.value))
	{	
		alert("Zipcode must be 5 character long, it has to be numeric");
		agentfrm.agentzip.focus();
		return false;
	}
	
	if(isNaN(agentfrm.agentmobile_ext.value) || (agentfrm.agentmobile_ext.value.length<3))
	{	
		alert("Direct/mobile area code must be numeric and 3 characters long");
		agentfrm.agentmobile_ext.focus();
		return false;
	}
	
	if(agentfrm.agentmobile.value=="")
	{	
		alert("Sorry, the phone field is blank.");
		agentfrm.agentmobile.focus();
		return false;
	}
	if(phonechk(agentfrm.agentmobile.value)==false)
	{
		alert("Please make sure your phone number is the correct format 'xxx-xxxx'");
		agentfrm.agentmobile.focus();
		return false;
	}
	if(agentfrm.agentoffice_code.value!="") 
	{
		if(isNaN(agentfrm.agentoffice_code.value) || (agentfrm.agentoffice_code.value.length<3))
		{	
			alert("Office phone area code must be numeric and 3 characters long");
			agentfrm.agentoffice_code.focus();
			return false;
		}
	}
	if(agentfrm.agentoffice_phone.value!="")
	{
		if(phonechk(agentfrm.agentoffice_phone.value)==false)
		{
			alert("Please make sure your office phone number is the correct format 'xxx-xxxx'");
			agentfrm.agentoffice_phone.focus();
			return false;
		}

	}
	if(agentfrm.agentoffice_ext.value!="") 
	{
		if(isNaN(agentfrm.agentoffice_ext.value) || (agentfrm.agentoffice_ext.value.length<5))
		{	
			alert("Office phone extention must be numeric and alteast 5 characters long");
			agentfrm.agentoffice_ext.focus();
			return false;
		}
	}
	if(agentfrm.agentoffice_fax.value!="")
	{
		if(phonechk(agentfrm.agentoffice_fax.value)==false)
		{
			alert("Please make sure your office FAX number is the correct format 'xxx-xxxx'");
			agentfrm.agentoffice_fax.focus();
			return false;
		}

	}
	if(agentfrm.faxcode_ext.value!="") 
	{
		if(isNaN(agentfrm.faxcode_ext.value) || (agentfrm.faxcode_ext.value.length<3))
		{	
			alert("Office fax area code must be numeric and 3 characters long");
			agentfrm.faxcode_ext.focus();
			return false;
		}
	}
	if(v=="a"){
		
		if(document.agentfrm.broker.value=="t")
		{
			if(agentfrm.brokername.value=="")
			{	
				alert(" Please enter Agency Name");
				agentfrm.brokername.focus();
				return false;
			}
			if(agentfrm.brokercode.value=="")
			{	
				alert(" Please enter Broker MRIS ID");
				agentfrm.brokercode.focus();
				return false;
			}
			if(agentfrm.brokerphone.value=="")
			{	
				alert("Sorry, the phone field is blank.");
				agentfrm.brokerphone.focus();
				return false;
			}
			if(phonechk1(agentfrm.brokerphone.value)==false)
			{
				alert("Please make sure your broker phone number is the correct format '#*$!-xxx-xxxx'");
				agentfrm.brokerphone.focus();
				return false;
			}
			if(agentfrm.brokerfax.value!="")
			{
				if(phonechk1(agentfrm.brokerfax.value)==false)
				{
					alert("Please make sure broker Fax number is the correct format '#*$!-xxx-xxxx'");
					agentfrm.brokerfax.focus();
					return false;
				}

			}

		}
		
		if(agentfrm.chk.checked==false)
		{
			window.alert("Please Accept terms and conditions:")
			agentfrm.chk.focus();
			return false;
		}
	}
}


function hupdatevalid(agentfrm)
{	
	if(v=="a"){
		if(agentfrm.agentemail.value=="")
		{	
			alert("Please enter your email address");
			agentfrm.agentemail.focus();
			return false;
		}
		if(echeck(agentfrm.agentemail.value)==false)
		{
			alert("Invalid Email-id");
			agentfrm.agentemail.focus();
			return false;
		}
		if(agentfrm.agentpassword.value=="")
		{
			alert("Please enter your password, password must be at least 8 characters in length");
			agentfrm.agentpassword.focus();
			return false;
		}
		if(agentfrm.agentpassword.value.length<8)
		{
			alert("Password must be atleast 8 characters in length");
			agentfrm.agentpassword.focus();
			return false;
		}
		if(agentfrm.confpassword.value=="")
		{	
			alert("Please confirm your password");
			agentfrm.confpassword.focus();
			return false;
		}
		if((agentfrm.confpassword.value!="")&&(agentfrm.agentpassword.value!=""))
		{
			if(agentfrm.confpassword.value!=agentfrm.agentpassword.value)
			{	
				alert("Password mismatch.Please check");
				agentfrm.confpassword.focus();
				return false;
			}
		}
		
	}
	if(v=="b" && agentfrm.agentpassword.value!="")
	{
		if(agentfrm.agentpassword.value.length<8)
		{
			alert("Password must be at least 8 characters in length");
			agentfrm.agentpassword.focus();
			return false;
		}
		if(agentfrm.confpassword.value=="")
		{	
			alert("Please confirm your password");
			agentfrm.confpassword.focus();
			return false;
		}
		if((agentfrm.confpassword.value!="")&&(agentfrm.agentpassword.value!=""))
		{
			if(agentfrm.confpassword.value!=agentfrm.agentpassword.value)
			{	
				alert("Password mismatch.Please check");
				agentfrm.confpassword.focus();
				return false;
			}
		}
	}
	if(agentfrm.agentfname.value=="")
	{
		alert("Please enter your First Name");
		agentfrm.agentfname.focus();
		return false;
	}
	if(agentfrm.agentlname.value=="")
	{
		alert("Please enter your Last Name");
		agentfrm.agentlname.focus();
		return false;
	}
	if(agentfrm.agentaddress.value=="")
	{
		alert("Please enter address");
		agentfrm.agentaddress.focus();
		return false;
	}
	if(agentfrm.agentcity.value=="")
	{	
		alert(" Please enter city");
		agentfrm.agentcity.focus();
		return false;
	}
	if(agentfrm.agentzip.value=="")
	{
		alert("Please enter zip");
		agentfrm.agentzip.focus();
		return false;
	}
	if((agentfrm.agentzip.value.length<5) || isNaN(agentfrm.agentzip.value))
	{	
		alert("Zipcode must be 5 character long, it has to be numeric");
		agentfrm.agentzip.focus();
		return false;
	}
	
	if(isNaN(agentfrm.agentmobile_ext.value) || (agentfrm.agentmobile_ext.value.length<3))
	{	
		alert("Direct/mobile area code must be numeric and 3 characters long");
		agentfrm.agentmobile_ext.focus();
		return false;
	}
	
	if(agentfrm.agentmobile.value=="")
	{	
		alert("Sorry, the phone field is blank.");
		agentfrm.agentmobile.focus();
		return false;
	}
	if(phonechk(agentfrm.agentmobile.value)==false)
	{
		alert("Please make sure your phone number is the correct format 'xxx-xxxx'");
		agentfrm.agentmobile.focus();
		return false;
	}
	if(v=="a"){
		if(agentfrm.chk.checked==false)
		{
			window.alert("Please Accept terms and conditions:")
			agentfrm.chk.focus();
			return false;
		}
	}
}

function checkstate(str)
{
	var lstr=str.length
	if (lstr>2)
	return false
	else return true
}

function validtour(frm)
{	
	if(frm.cameratype.value=="d")
	{
		if(frm.propmls.value=="")
		{
			alert("Please fill up Property MLS");
			frm.propmls.focus();
			return false;
		}
	}
	if(frm.descriptivetitle.value=="")
	{
		alert("Please fill up Descriptive Title");
		frm.descriptivetitle.focus();
		return false;
	}
	if(frm.cameratype.value=="p")
	{
		if(frm.ofname.value=="")
		{
			alert("Please fill up Owner First Name");
			frm.ofname.focus();
			return false;
		}
		if(frm.olname.value=="")
		{
			alert("Please fill up Owner Last Name");
			frm.olname.focus();
			return false;
		}
		if(isNaN(frm.areacode1.value) || (frm.areacode1.value.length<3))
		{	
			alert("Owner phone area code must be numeric and 3 characters long");
			frm.areacode1.focus();
			return false;
		}

		if(frm.agentmobile1.value=="") 
		{
			alert("Please enter owner phone no");
			frm.agentmobile1.focus();
			return false;
		}

		if(phonechk(frm.agentmobile1.value)==false)
		{
			alert("Please make sure owner phone number is the correct format 'xxx-xxxx'");
			frm.agentmobile1.focus();
			return false;
		}
		if(frm.agentmobile2.value!="")
		{
			if(phonechk(frm.agentmobile2.value)==false)
			{
				alert("Please make sure owner phone number 2 is the correct format 'xxx-xxxx'");
				frm.agentmobile2.focus();
				return false;
			}

		}
	}
	if(frm.streetadd.value=="")
	{
		alert("Please fill up Street Address");
		frm.streetadd.focus();
		return false;
	}
	if(frm.city.value=="")
	{
		alert("Please fill up City");
		frm.city.focus();
		return false;
	}
	if(frm.state.value=="")
	{
		alert("Please fill up State");
		frm.state.focus();
		return false;
	}
	if(frm.zip.value=="")
	{
		alert("Please fill up Zip code");
		frm.zip.focus();
		return false;
	}
	if(isNaN(frm.zip.value))
	{
		alert("Please enter digit value in zip");
		frm.zip.focus();
		return false;
	}
	if (frm.proptype.selectedIndex == 0)
	{
		alert("Please select your Listing Type");
		frm.proptype.focus();
		return (false);
	}
   if((frm.proptype.value=='r')&&(frm.bedroom.selectedIndex==0))
	{
		alert("Please select your Bedroom Combination");
		frm.bedroom.focus();
		return false;
	}
	if((frm.proptype.value=='r')&&(frm.fullbath.selectedIndex==0))
	{
		alert("Please select your Bathroom Combination");
		frm.fullbath.focus();
		return false;
	}
	if((frm.proptype.value=='r')&&(frm.askingprice1.value==""))
	{
		alert("Please enter your Askng Price");
		frm.askingprice1.focus();
		return false;
	}
	if((frm.proptype.value=='c')&&(frm.commproptype.selectedIndex==0))
	{
		alert("Please select your Property Type");
		frm.commproptype.focus();
		return false;
	}
	if((frm.proptype.value=='c')&&(frm.askingprice2.value==""))
	{
		alert("Please enter your Price/Base rent");
		frm.askingprice2.focus();
		return false;
	}
	if((frm.proptype.value=='c')&&(frm.renttype.selectedIndex==0))
	{
		alert("Please select your Rent Type");
		frm.renttype.focus();
		return false;
	}	   
	return true;
}
function checkenable1(obj)
{	
	if(obj=="")
	{
		document.getElementById('restype').style.display = "none";
		document.getElementById('comtype').style.display = "none";
	}
	else if(obj=="r")
	{
		document.getElementById('restype').style.display = "";
		document.getElementById('comtype').style.display = "none";
	}
	else
	{
		document.getElementById('comtype').style.display = "";
		document.getElementById('restype').style.display = "none";
	}
	
}
function changefoc1()
{	
	if(frm.areacode1.value.length=="3")
	{
		frm.agentmobile1.focus();
		return true;
	}
	return true;
}
function changefoc2()
{	
	if(frm.areacode2.value.length=="3")
	{
		frm.agentmobile2.focus();
		return true;
	}
	return true;
}
function check(){
	var brtyp=document.agentfrm.broker.value;
	if(brtyp=="t")
		document.getElementById('binfo').style.display="";
	else
		document.getElementById('binfo').style.display="none";
}
function changecoupon() {
var btyp=document.agentfrm.broker.value;
var at=document.agentfrm.servicetype.value;
if(at!="")
{
	if(at!="f")
		document.getElementById('couponid').style.display="";
	else
		document.getElementById('couponid').style.display="none";
}
if(at=="")
{
	document.getElementById('couponid').style.display="none";
}
if(btyp=="other" && at=="s")
	document.getElementById('entcoupon').style.display="";
else
	document.getElementById('entcoupon').style.display="none";
}