// Copyright 2000 - 2010 Imagine GPS Ltd.


function submit() {
 document.searchbox.submit();
};


function textCounter(field,cntfield,maxlimit) { // text box character counter

	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	cntfield.value = maxlimit - field.value.length;
}


function copyBillToShip() {  // used in the create account script

	document.getElementById("ship_country").value = document.getElementById("bill_country").value;
	document.getElementById("ship_first_name").value = document.getElementById("bill_first_name").value;
	document.getElementById("ship_middle_name").value = document.getElementById("bill_middle_name").value;
	document.getElementById("ship_last_name").value = document.getElementById("bill_last_name").value;
	document.getElementById("ship_company").value = document.getElementById("bill_company").value;
	document.getElementById("ship_address1").value = document.getElementById("bill_address1").value;
	document.getElementById("ship_address2").value = document.getElementById("bill_address2").value;
	document.getElementById("ship_address3").value = document.getElementById("bill_address3").value;
	document.getElementById("ship_city").value = document.getElementById("bill_city").value;
	document.getElementById("ship_state").value = document.getElementById("bill_state").value;
	document.getElementById("ship_zipcode").value = document.getElementById("bill_zipcode").value;
	document.getElementById("ship_homephone").value = document.getElementById("bill_homephone").value;
	document.getElementById("ship_homephone_ext").value = document.getElementById("bill_homephone_ext").value;
	document.getElementById("ship_cellphone").value = document.getElementById("bill_cellphone").value;
	document.getElementById("ship_cellphone_ext").value = document.getElementById("bill_cellphone_ext").value;

	document.getElementById("shippingsame").setAttribute("value","Clear Fields");
	document.getElementById("shippingsame").setAttribute("onclick","unCopyBillToShip();");
	};


function unCopyBillToShip() {  // used in the create account script
	document.getElementById("ship_country").value = "";
	document.getElementById("ship_first_name").value = "";
	document.getElementById("ship_middle_name").value = "";
	document.getElementById("ship_last_name").value = "";
	document.getElementById("ship_company").value = "";
	document.getElementById("ship_address1").value = "";
	document.getElementById("ship_address2").value = "";
	document.getElementById("ship_address3").value = "";
	document.getElementById("ship_city").value = "";
	document.getElementById("ship_state").value = "";
	document.getElementById("ship_zipcode").value = "";
	document.getElementById("ship_homephone").value = "";
	document.getElementById("ship_homephone_ext").value = "";
	document.getElementById("ship_cellphone").value = "";
	document.getElementById("ship_cellphone_ext").value = "";

	//change the checkbox back into what it was originally - a copyData() link
	document.getElementById("shippingsame").setAttribute("value","Copy Billing to Shipping");
	document.getElementById("shippingsame").setAttribute("onclick","copyBillToShip();");
	};


function copyShipToBill() {  // used in the checkout script

	document.getElementById("bill_country").value = shipCountry;
	document.getElementById("bill_first_name").value = shipFirstName;
	document.getElementById("bill_middle_name").value = shipMiddleName;
	document.getElementById("bill_last_name").value = shipLastName;
	document.getElementById("bill_company").value = shipCompany
	document.getElementById("bill_address1").value = shipAddress1;
	document.getElementById("bill_address2").value = shipAddress2;
	document.getElementById("bill_address3").value = shipAddress3;
	document.getElementById("bill_city").value = shipCity;
	document.getElementById("bill_state").value = shipState;
	document.getElementById("bill_zipcode").value = shipZipCode;
	document.getElementById("bill_homephone").value = shipHomePhone;
	document.getElementById("bill_homephone_ext").value = shipHomePhoneExt;
	document.getElementById("bill_cellphone").value = shipCellPhone;
	document.getElementById("bill_cellphone_ext").value = shipCellPhoneExt;

	//turn the checkbox into a clear form button
	document.getElementById("sameasshipping").setAttribute("value","Clear Fields");
	document.getElementById("sameasshipping").setAttribute("onclick","uncopyShipToBill();");
	document.getElementById("email").setAttribute("class","redtext");
	};


function uncopyShipToBill() {  // used in the checkout script

	document.getElementById("bill_country").value = "";
	document.getElementById("bill_first_name").value = "";
	document.getElementById("bill_middle_name").value = "";
	document.getElementById("bill_last_name").value = "";
	document.getElementById("bill_company").value = "";
	document.getElementById("bill_address1").value = "";
	document.getElementById("bill_address2").value = "";
	document.getElementById("bill_address3").value = "";
	document.getElementById("bill_city").value = "";
	document.getElementById("bill_state").value = "";
	document.getElementById("bill_zipcode").value = "";
	document.getElementById("bill_homephone").value = "";
	document.getElementById("bill_homephone_ext").value = "";
	document.getElementById("bill_cellphone").value = "";
	document.getElementById("bill_cellphone_ext").value = "";

	//change the checkbox back into what it was originally - a copyData() link
	document.getElementById("sameasshipping").setAttribute("value","Copy Data");
	document.getElementById("sameasshipping").setAttribute("onclick","copyShipToBill();");
	document.getElementById("email").setAttribute("class","");
	};


/*function CopyFromShipping() {
	if (document.registerform.x_copy_bill.checked) {
		document.registerform.ssn.value = document.registerform.firstname.value + ' ' + document.registerform.lastname.value;
	    copyField(document.registerform.phone, document.registerform.s_phone);
	    copyField(document.registerform.b_address, document.registerform.s_address);
	    copyField(document.registerform.b_city, document.registerform.s_city);
	    copyField(document.registerform.b_state, document.registerform.s_state);
	    copyField(document.registerform.b_zipcode, document.registerform.s_zipcode);
	    copyField(document.registerform.b_country, document.registerform.s_country);
	}
}*/

/*function copyField(from, to) {
	if (typeof(from)  != 'undefined') {
		if (typeof(to) != 'undefined') {
    		to.value = from.value;
    	}
	}
}*/

// JavaScript Document for visible sections
function viewSection(vID){
	var tabObj,sctObj,i,imgSrc,tmpObj;
	for (i=1;i<=10;i++){
		sctObj = "sctCont"+i;
		tabObj = "sctTab"+i;
		if (document.getElementById(sctObj)){
			tmpObj = document.getElementById(tabObj);
			imgSrc = tmpObj.className;
			if (vID==i){
				tmpObj.className = imgSrc.replace("off","on")
				showPageObj(sctObj);

			}
			else
			{
				tmpObj.className = imgSrc.replace("on","off")
				hidePageObj(sctObj);
			}
		}
	}
}


/*function showPageObj(item)
{
	obj = document.getElementById(item);
	obj.style.display = 'block';
}*/


/*function hidePageObj(item)
{
	obj = document.getElementById(item);
	obj.style.display = 'none';
}*/

<!--//--><![CDATA[//><!--

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//--><!]]>
