window.onload = function() {
	if (document.startViewCartFlashing == true) {
		flashViewCart();
	}
}
	
function copyBillingInformation() {
	theForm = document.DisplayAccountInformation;
	theForm.ShippingFirstName.value = theForm.BillingFirstName.value;
	theForm.ShippingLastName.value = theForm.BillingLastName.value;
	theForm.ShippingAddress.value = theForm.BillingAddress.value;
	theForm.ShippingAddress2.value = theForm.BillingAddress2.value;
	theForm.ShippingCity.value = theForm.BillingCity.value;
	theForm.ShippingZip.value = theForm.BillingZip.value;
	theForm.ShippingDaytimePhone.value = theForm.BillingDaytimePhone.value;
	theForm.ShippingEveningPhone.value = theForm.BillingEveningPhone.value;
	theForm.ShippingState.selectedIndex = theForm.BillingState.selectedIndex;
	theForm.ShippingCountry.selectedIndex = theForm.BillingCountry.selectedIndex;
}

function updateShippingMethod() {
	document.getElementById("updateShippingMethodSpan").innerHTML = '<input name="ControlActionUpdateShippingMethod" type="hidden" value="Update Shipping Method">';
	document.PaymentInformation.submit();
}

function controlAction(theForm,theAction) {
	theForm.ControlActionHidden.value = theAction;
	theForm.submit();
}

var flashCount = 0;
var flasherID;
var flasherDelay = 1;
var flasherDelayInc = 0;;
function flashViewCart() {
	flasherID = setInterval(flashViewCart2,flasherDelay);
}
function flashViewCart2() {
	if(flasherDelay>200) {
		clearInterval(flasherID);
		document.getElementById("viewCartFlashing").className = "flashViewCart";
	}
	else {
		flasherDelayInc = flasherDelayInc + 1;
		flasherDelay=flasherDelay + flasherDelayInc;
		if (document.getElementById("viewCartFlashing").className == "flashViewCart") {
			document.getElementById("viewCartFlashing").className = "flashViewCart2";
			document.getElementById("cartImage").src = "images/iconShoppingCartHover.gif";		
		}
		else {
			document.getElementById("viewCartFlashing").className = "flashViewCart";
			document.getElementById("cartImage").src = "images/iconShoppingCart.gif";		
		}
		clearInterval(flasherID);
		flasherID = setInterval(flashViewCart2,flasherDelay);
	}
}

function changeQuantity(amt) {
	ref = document.getElementById("shoppingCartQuantityInput");
	tempAmt = ref.value * 1;
	if (IsNumeric(tempAmt) && (tempAmt+amt)>0) {
		ref.value = tempAmt + amt;
	}
	else {
		ref.value = 1;
		alert("You must enter a quantity of 1 or more!\n\nThe quantity has been changed to 1");
	}
}
function checkQuantity(amt) {
	ref = document.getElementById("shoppingCartQuantityInput");
	if (!IsNumeric(amt) || amt<1) {
		ref.value = 1;
		alert("You must enter a quantity of 1 or more!\n\nThe quantity has been changed to 1");
	}
}	
function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}
function paymentSubmitDisable() {
	var theIDs = "BtnEditBilling,BtnEditShipping,BtnApplyCode,BtnCancelOrder,BtnMakePayment".split(",");
	for (var z=0;z<theIDs.length;z++) {
			theOriginalElement=document.getElementById(theIDs[z]);
			if (theOriginalElement) {
				var btn = document.createElement('button');
				btn.disabled = true;
				btn.style.backgroundImage = "none";
				btn.style.backgroundColor = "#E0E0E0";
				btn.style.color = "#999999";
				btn.style.cursor = "default";
				btn.style.fontWeight = "bold";
				btn.style.fontSize = "14px";
				btn.style.border = "1px solid #999999";
				btn.style.verticalAlign = "top";
				btn.value = "Processing...";
				btn.innerHTML = "Processing...";
				theOriginalElement.parentNode.insertBefore(btn, theOriginalElement);
				theOriginalElement.style.display = 'none';
			}
	}
}