
// change hover colors for input fields for IE
onload=function(){var f=document.forms[0],fx=f.length;
while(fx--){
if((f[fx].type=="text") || (f[fx].type=="password") || (f[fx].type=="file")){
f[fx].onfocus=function(){this.style.backgroundColor='#F2F9FF'};
f[fx].onblur=function(){this.style.backgroundColor='#DEEFFF'};
}}}

// and for td rows
var over = '#F2F9FF'; 
var out = '#FFFFFF';

// toggle visiblity of div
function Toggle( secid ) {
   var sectionId = document.getElementById(secid);
	if (sectionId == null) return;
    if (sectionId.style.display == '') {
        sectionId.style.display = 'none';
    } else {
        sectionId.style.display = '';
    }
}
	
function Hide( obj ) {
    var oDiv = document.getElementById(obj);
    if (oDiv != null) oDiv.style.display = 'none';
}

function Display( obj ) {
    var oDiv = document.getElementById(obj);
    if (oDiv != null) oDiv.style.display = '';
}

function displayContent() {
   var sectionId = document.getElementById("content");
   sectionId.style.display = '';
}

function enable(obj) {
	var oDiv = document.getElementById(obj);
    if (oDiv != null) oDiv.disabled=false;
}

function disable(obj) {
	var oDiv = document.getElementById(obj);
    if (oDiv != null) oDiv.disabled=true;
}


// --- ShippingAndPaymentForm related ---
var firstName = "";
var lastName = "";
var company = "";
var address1 = "";
var address2 = "";
var city = "";
var state = "";
var stateIndex = 0;
var zip = "";
var country = "";
var countryIndex = 0;
var phone = "";

function InitAndSaveVariables() {
		firstName = document.shippingAndPaymentForm.firstNameShipTo.value;
		lastName = document.shippingAndPaymentForm.lastNameShipTo.value;
		company = document.shippingAndPaymentForm.companyShipTo.value;
		address1 = document.shippingAndPaymentForm.address1ShipTo.value;
		address2 = document.shippingAndPaymentForm.address2ShipTo.value;
		city = document.shippingAndPaymentForm.cityShipTo.value;
		stateIndex = document.shippingAndPaymentForm.stateShipTo.selectedIndex;
		state = document.shippingAndPaymentForm.stateShipTo[stateIndex].value;
		zip = document.shippingAndPaymentForm.zipShipTo.value;
		countryIndex = document.shippingAndPaymentForm.countryShipTo.selectedIndex;
		country = document.shippingAndPaymentForm.countryShipTo[countryIndex].value;
		phone = document.shippingAndPaymentForm.phoneShipTo.value;
}

function cloneAddressAndToggle() {
	InitAndSaveVariables();
	if (document.shippingAndPaymentForm.copyAddress.checked == true) {
		document.shippingAndPaymentForm.firstNameShipTo.value = document.shippingAndPaymentForm.firstNameBillTo.value;
		document.shippingAndPaymentForm.lastNameShipTo.value = document.shippingAndPaymentForm.lastNameBillTo.value;
		document.shippingAndPaymentForm.companyShipTo.value = document.shippingAndPaymentForm.companyBillTo.value;
		document.shippingAndPaymentForm.address1ShipTo.value = document.shippingAndPaymentForm.address1BillTo.value;
		document.shippingAndPaymentForm.address2ShipTo.value = document.shippingAndPaymentForm.address2BillTo.value;
		document.shippingAndPaymentForm.cityShipTo.value = document.shippingAndPaymentForm.cityBillTo.value;
		//document.shippingAndPaymentForm.stateShipTo.value = document.shippingAndPaymentForm.stateBillTo.value;
		document.shippingAndPaymentForm.stateShipTo.selectedIndex = document.shippingAndPaymentForm.stateBillTo.selectedIndex;
		document.shippingAndPaymentForm.zipShipTo.value = document.shippingAndPaymentForm.zipBillTo.value;
		//document.shippingAndPaymentForm.countryShipTo.value = document.shippingAndPaymentForm.countryBillTo.value;
		document.shippingAndPaymentForm.countryShipTo.selectedIndex = document.shippingAndPaymentForm.countryBillTo.selectedIndex;
		document.shippingAndPaymentForm.phoneShipTo.value = document.shippingAndPaymentForm.phoneBillTo.value;

		//document.shippingAndPaymentForm.firstNameShipTo.readonly = true;
		//document.shippingAndPaymentForm.lastNameShipTo.readonly = true;
		//document.shippingAndPaymentForm.companyShipTo.readonly = true;
		//document.shippingAndPaymentForm.address1ShipTo.readonly = true;
		//document.shippingAndPaymentForm.address2ShipTo.readonly = true;
		//document.shippingAndPaymentForm.cityShipTo.readonly = true;
		//document.shippingAndPaymentForm.stateShipTo.readonly = true;
		//document.shippingAndPaymentForm.zipShipTo.readonly = true;
		//document.shippingAndPaymentForm.countryShipTo.readonly = true;
		//document.shippingAndPaymentForm.phoneShipTo.readonly = true;
		
  	} else {
    document.shippingAndPaymentForm.firstNameShipTo.value = firstName;
		document.shippingAndPaymentForm.lastNameShipTo.value = lastName;
		document.shippingAndPaymentForm.companyShipTo.value = company;
		document.shippingAndPaymentForm.address1ShipTo.value = address1;
		document.shippingAndPaymentForm.address2ShipTo.value = address2;
		document.shippingAndPaymentForm.cityShipTo.value = city;
		document.shippingAndPaymentForm.stateShipTo.selectedIndex = stateIndex;
		document.shippingAndPaymentForm.zipShipTo.value = zip;
		document.shippingAndPaymentForm.countryShipTo.selectedIndex = countryIndex;
		document.shippingAndPaymentForm.phoneShipTo.value = phone;
		
  		//document.shippingAndPaymentForm.firstNameShipTo.readonly = false;
		//document.shippingAndPaymentForm.lastNameShipTo.readonly = false;
		//document.shippingAndPaymentForm.companyShipTo.readonly = false;
		//document.shippingAndPaymentForm.address1ShipTo.readonly = false;
		//document.shippingAndPaymentForm.address2ShipTo.readonly = false;
		//document.shippingAndPaymentForm.cityShipTo.readonly = false;
		//document.shippingAndPaymentForm.stateShipTo.readonly = false;
		//document.shippingAndPaymentForm.zipShipTo.readonly = false;
		//document.shippingAndPaymentForm.countryShipTo.readonly = false;
		//document.shippingAndPaymentForm.phoneShipTo.readonly = false;
  	}
  
}


function toggleCopyAndDisable(secId) {
  	if (secId == "1") {
  		//document.forms[0].readsMultiplier.readonly = false;
  		//document.forms[0].readsMultiplierEffectiveDate.readonly = false;
		enable('readsMultiplier');
		enable('readsMultiplierEffectiveDate');
	}
	if (secId == "0") {
		//document.forms[0].readsMultiplier.readonly = true;
  		//document.forms[0].readsMultiplierEffectiveDate.readonly = true;
		disable('readsMultiplier');
		disable('readsMultiplierEffectiveDate');
	}
}