
/*function err() {
  return true;
}
window.onerror = err;*/

function YY_checkform() { //v4.66
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  var f=document.forms.online_estimate;
  var fdd=f.date.value;
  if(fdd=='choose date' | '') myErr+='* Please choose your Estimated Move Date.'; else f.date.value=fdd;
  if (myErr!=''){alert('We\'re sorry - We cannot process your request because of the following errors:\t\t\t\n\n'+myErr); sub(0);};
  document.MM_returnValue = (myErr=='');
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

/*function dt() {
	var f = document.forms.online_estimate;
	var fdd = f.ddate.value;
	if(fdd="click to choose" | fdd="") {alert("Please choose your Estimated Move Date.")} else {f.date.value=fdd};
}*/

function sub(x) {
	var f=document.forms.online_estimate.B1;
	if (x==1) {f.disabled=true; f.value='Processing... Please wait...';}
	else {f.disabled=false; f.value=' SUBMIT ';}
}

function chuz(x) {
	if(x.value=='') x.value=0;
	x.value=parseInt(x.value)+1;
	x.className="req";
	x.select(); x.focus();
}

function oph(x) {
	x.style.className="";
}

/*function ctmv(t,x) {
	if (t.value.length==x) alert(t.form.length); //document.forms[0].length fields.this.name document.forms[0].fields[this+1].focus()
}*/

// BEGIN AutoTab
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function AT(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
	input.value = input.value.slice(0, len);
	input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
	var found = false, index = 0;
	while(!found && index < arr.length)
	if(arr[index] == ele)
	found = true;
	else
	index++;
	return found;
}
function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
	if (input.form[i] == input)index = i;
	else i++;
	return index;
}
return true;
}

function reed(x) {
	var qstring = location.href.split("?");
	if (!qstring[1]) return false; 
	var q=qstring[1];
	if(x==1) {if(q.indexOf('est')!=-1) top.frames.bdy.location.href=q+".asp"; else top.frames.bdy.location.href=q+".htm";}
	if(x==2) {
		var name_val = qstring[1].split("&");
		var destFlds = new Array("P_Zip","Notes");
		for (i=0;i<2;i++)	{
			tmp = name_val[i].split("=");
			eval("document.forms.online_estimate." + destFlds[i] + ".value = tmp[1]");
		}
	}
}

function aff(x) {
	var d=document.getElementById('affnm');
	if(x.selectedIndex==3) {d.disabled=false; d.focus();} else {d.disabled=true; x.focus();}
}

function xtr(x) {
	var d=document.getElementById('xtr').style;
	if(x.checked==true) {d.display='block'; document.getElementById('xtrA').focus();} else d.display='none';
}

/***********************************************
* Switch Content script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated April 2nd, 2005.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablepersist="off" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)

var contractsymbol='<input type=button value=\"  -  \" disabled style=\"font-size:xx-small\">'
var expandsymbol='<input type=button value=\" + \" disabled style=\"font-size:xx-small\">'

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}

function sweeptoggle(ec){
var thestate=(ec=="expand")? "block" : "none"
var inc=0
while (ccollect[inc]){
ccollect[inc].style.display=thestate
inc++
}
revivestatus()
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(curobj, cid){
var spantags=curobj.getElementsByTagName("SPAN")
var showstateobj=getElementbyClass(spantags, "showstate")
if (ccollect.length>0){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0){ //if "showstate" span exists in header
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="block")
statecollect[inc].innerHTML=contractsymbol
else
statecollect[inc].innerHTML=expandsymbol
inc++
}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && ccollect.length>0){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate

function reed() {
	var q=location.href.split("?")[1];
	if(!q) return false;
	if(document.forms.ccontact) {var d=document.forms.ccontact; d.About.value=spaces(q); d.Cust_Name.focus(); return;}
	if(q.charAt(q.length-1)=="&") q=q.substring(0,q.length-1);
	if(q.indexOf("&")!=-1) sp="&"; else sp="%26";
	var name_vals=q.split(sp);
	var name, val;
	for (i=0;i<name_vals.length;i++) {
		name = name_vals[i].split("=")[0];
		val = name_vals[i].split("=")[1];
		if(val.indexOf("%40")!=-1) at="%40"; else if(val.indexOf("%2540")!=-1) at="%2540"; else at="@";
		if(val.indexOf(at)!=-1) {val=val.split(at)[0]+"@"+val.split(at)[1];}
		if(location.href.indexOf("removed.htm")!=-1) {document.write(val); return;}
		val=spaces(val);
		if(name=="countryTo") {if(document.forms[0].externalNotes) {document.forms[0].externalNotes.value="International: "+val;} return;}
		var formz=document.getElementsByTagName("form");
		var el=eval("document.forms[" + (formz.length-1) + "]." + name);
		el.value=val;
		if(name=="Ord_Num" || name=="A_Code") {document.getElementById("idme").style.display="block"; el.readOnly="readonly"; el.className="ro";}
	}
}

function spaces(str) {
	var intIndexOfMatch = str.indexOf("%20");
	while (intIndexOfMatch != -1) {
	 str=str.replace("%20"," ")
	 intIndexOfMatch = str.indexOf("%20");
	}
	return str;
}