function instantMessage(){
	var w = window.open('https://server.iad.liveperson.net/hc/70187860/?cmd=file&amp;file=visitorWantsToChat&amp;site=70187860&amp;imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/&amp;referrer='+escape(document.location),'instantMessage','width=475,height=400,resizable=yes');
	w.focus();
}

//-----------------------------------------------

function instantCallback(){
	var w = window.open('https://server.iad.liveperson.net/hc/70187860/?cmd=file&amp;file=visitorWantsToTalk&amp;site=70187860&amp;imageUrl=https://server.iad.liveperson.net/hcp/Gallery/CallButton-Gallery/English/General/1b&amp;referrer='+escape(document.location),'instantCallback','width=472,height=320,resizable=yes');
	w.focus();
}

//-----------------------------------------------

function Start(page){
	OpenWin = this.open(page, "CtrlWindow","toolbar=No,menubar=No,location=No,scrollbars=No,resizable=Yes,status=No,width=450,height=650,left=50,top=50,");
}

//-----------------------------------------------

function CallMeNowOpenSizedWindow(){
	var w=window.open('','callmenow','height=650,width=450,titlebar=no,statusbar=no,resizable=no,scrollbars=no');
	w.focus();
}

//-----------------------------------------------

function swapDiv(vID){
		if(document.getElementById(vID).style.display == 'inline')
			document.getElementById(vID).style.display = 'none';
		else
			document.getElementById(vID).style.display = 'inline';
}

//-----------------------------------------------

function Swap(v)
{
	tempSrc = v.src;
	tempExt = tempSrc.substring(tempSrc.length-4)
	if (tempSrc.substring(tempSrc.length-6,tempSrc.length-4) == '01')
		v.src = tempSrc.substring(0,tempSrc.length-6) + tempExt;
	else
		v.src = tempSrc.substring(0,tempSrc.length-4) + '01' + tempExt;
}

//-----------------------------------------------

function PreLoadPics(){
	var vObj = document.getElementsByName('swappableImage');
	if(vObj!=null){
	  for(var i=0; i<vObj.length; i++){
			strImagePath = vObj[i].src;
			eval('var imgDummy' + i + ' = new Image(5, 5)');
			eval("imgDummy" + i + ".src = '" + strImagePath.substr(0, strImagePath.length - 4) + "01" + strImagePath.substr(strImagePath.length - 4, 4) + "'");
		}	
	}
}

//-----------------------------------------------

function isEmail(str){
	// are regular expressions supported?
	var supported = 0;
	if(window.RegExp){
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if(tempReg.test(tempStr))
			supported = 1;
	}
	if (!supported)
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

//-----------------------------------------------

function Trim(StrValue)
{
  var st = StrValue;
  while ((st.length > 0) && (st.charAt(0) == " ")) 
	st = st.substring(1, st.length);
  while ((st.length > 0) && (st.charAt(st.length-1) == " "))
    st = st.substring(0, st.length-1);
  return st	
}

//-----------------------------------------------

function frmRateQuoteSubmit(vParam){
	if(Trim(document.frmRateQuote.txtRateQuoteName.value) == ''){
		alert('Please type your Name');
		document.frmRateQuote.txtRateQuoteName.focus();
		return false;
	}
	if(Trim(document.frmRateQuote.txtRateQuoteDate.value) == ''){
		alert('Please select the move date');
		document.frmRateQuote.txtRateQuoteDate.focus();
		return false;
	}
	if(Trim(document.frmRateQuote.txtRateQuotePhone.value) == ''){
		alert('Please type your Phone');
		document.frmRateQuote.txtRateQuotePhone.focus();
		return false;
	}
	if(Trim(document.frmRateQuote.txtRateQuoteBedrooms.value) == ''){
		alert('Please type the number of Bedrooms');
		document.frmRateQuote.txtRateQuoteBedrooms.focus();
		return false;
	}
	if(document.frmRateQuote.txtRateQuoteEmail.value == ""){
		alert('Please type your Email Address');
		document.frmRateQuote.txtRateQuoteEmail.focus();
		return false;
	}
	else{
		if(!isEmail(document.frmRateQuote.txtRateQuoteEmail.value)){
			alert('Please type a valid Email Address');
			document.frmRateQuote.txtRateQuoteEmail.focus();
			return false;
		}
	}
	if(Trim(document.frmRateQuote.txtRateQuoteZipFrom.value) == ''){
		alert('Please type the From Zip code');
		document.frmRateQuote.txtRateQuoteZipFrom.focus();
		return false;
	}
	if(Trim(document.frmRateQuote.txtRateQuoteZipTo.value) == ''){
		alert('Please type the To Zip code');
		document.frmRateQuote.txtRateQuoteZipTo.focus();
		return false;
	}
	if((!document.getElementById('rdbtnRateQuoteMileage1').checked) && (!document.getElementById('rdbtnRateQuoteMileage2').checked)){
		alert('Please select your Move Type');
		return false;
	}
	if(document.getElementById('rdbtnRateQuoteMileage2').checked){
		if((!document.getElementById('rdbtnRateQuoteFillType1').checked) && (!document.getElementById('rdbtnRateQuoteFillType2').checked)){
			alert('Please select the way you want to fill the table of measurements');
			return false;
		}
	}
	if(document.getElementById('rdbtnRateQuoteFillType1').checked)
		alert('I understand that in order for me to receive a proper Long Distance quote, I will need to fill out the Table of Measurements with my sales rep over the phone.');
	if((document.getElementById('rdbtnRateQuoteMileage2').checked) && (document.getElementById('rdbtnRateQuoteFillType2').checked)){
		alert('In order for us to better serve you with a proper Long Distance quote, please fill out the table of measurements as accurately as possible.');
		document.frmRateQuote.action = vParam+'forms/tom/index.php';
	}
	return true;
}
//-----------------------------------------------

function frmRateQuoteMileageChange(vParam){
	if(vParam == 2){
		document.getElementById('divFillTypeText').style.display = 'inline';
		document.getElementById('divFillType').style.display = 'inline';
	}
	else{
		document.getElementById('divFillTypeText').style.display = 'none';
		document.getElementById('divFillType').style.display = 'none';
	}
}
//-----------------------------------------------

