
// NOTE: basically filtered list of previous functions moved into new file, and new ones added at bottom...

// Move cursor to fields that need attention
function formfocus(id,form) {
	document.getElementById(form)[id].focus();
	
}


// IE 6.0 has a problem checking the DOM so I needed to revert back to typing out the form name.
function Country_Change(){
	var d = document;
	if ((d.forms.frmInquiry)["Country"].value == "92") {
		d.getElementById("state_display").style.display = "block";
		d.getElementById("Zip").className = "REQUIRED";
	} else if ((d.forms.frmInquiry)["Country"].value == "13") {
		d.getElementById("state_display").style.display = "block";
		d.getElementById("Zip").className = "REQUIRED";
	
	} else {
		((d.forms.frmInquiry)["Country"].value != "92")
		d.getElementById("state_display").style.display = "none";
		d.getElementById("Zip").className = "FIELD";
	}	
}

// Functions used mainly for the parts and service pages
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) 
		curleft += obj.x;
alert (obj.id);			
	return curleft;
}
function findPosY(obj){var curtop = 0;if (obj.offsetParent) {while (obj.offsetParent) {curtop += obj.offsetTop;obj = obj.offsetParent;}}else if (obj.y) curtop += obj.y;return curtop;}

function showPartKits(){
	if (document.getElementById("kits").style.display == "block") {
		document.getElementById("kits").style.display = "none";
	}else {
		document.getElementById("kits").style.display = "block";
	}
}

function showManuals(){
	if (document.getElementById("manuals").style.display == "block") {
		document.getElementById("manuals").style.display = "none";
	}else {
		document.getElementById("manuals").style.display = "block";
	}
}

function showParts(){
	if (document.getElementById("parts").style.display == "block") {
		document.getElementById("parts").style.display = "none";
	}else {
		document.getElementById("parts").style.display = "block";
	}
}

function showRegisterBox(parent) {
	var elm = document.getElementById(parent);
	var sb = document.getElementById('authorize');
	sb.style.display = 'block';
	sb.style.left = (elm.offsetLeft + 5) + "px";
	sb.style.top = (elm.offsetTop + 10) + "px";
//	sb.style.left = (findPosX(elm) + 5) + "px";
//	sb.style.top = (findPosY(elm) + 10) + "px";
}


		function subAddRetro(intI) {
			document.frmRetroKit.partID.value = intI;
			document.frmRetroKit.hdnAction.value = 'addItem';
			//var partIDfield = document.getElementById("partID");
			//var hdnActionfield = document.getElementById("hdnAction");
			//partIDfield.value = intI;
			//hdnActionfield.value = 'addItem';
			document.frmRetroKit.submit()
			}
		function subAddPart(intI) {
			document.frmShoppingCart.partID.value = intI;
			document.frmShoppingCart.hdnAction.value = 'addItem';
			//var partIDfield = document.getElementById("partID");
			//var hdnActionfield = document.getElementById("hdnAction");
			//partIDfield.value = intI;
			//hdnActionfield.value = 'addItem';
			document.frmShoppingCart.submit()
			}
		function subAdjust() {
			document.frmCart.hdnAction.value = 'adjust'
			document.frmCart.submit()}
		function subChange(intI) {
			document.frmCart.hdnItem.value = intI
			document.frmCart.hdnAction.value = 'change'
			document.frmCart.submit()}			
		function subCustomerInfo() {
			document.frmCustomerInfo.hdnAction.value = 'customerinfo'
			document.frmCustomerInfo.submit()}
		function subCheckout(intI) {
			document.frmCart.hdnItem.value = intI
			document.frmCart.hdnAction.value = 'checkout'
			document.frmCart.submit()}	
		function subRemove(intI) {
			document.frmCart.hdnItem.value = intI
			document.frmCart.hdnAction.value = 'remove'
			document.frmCart.submit()}


// ==================================
		function subRemoveALL() {
			document.frmCart.hdnAction.value = 'removeALL'
			document.frmCart.submit() }
		function subORemove(intI) {
		  var answer = confirm("Are you sure you want to completely delete this pending order?\n\nClick OK if you're sure.\n");
		  if (!answer){
			  //window.location = '/admin/users/pending_carts/';
			  //return false;
			}
		else {
			document.frmCart.hdnItem.value = intI
			document.frmCart.hdnAction.value = 'remove'
			document.frmCart.submit()
		}
			}
		function invalidDiscount() {alert("Invalid discount!\n Please enter a valid promo or discount code.");}
		function usedDiscount() {alert("Invalid discount!\n This discount is already in use.");}
		function validDiscount() {alert("Discount has been added to your order!\n Please continue to shop or check out.");}
		function signinDiscount() {alert("Please Sign In to use your discount code.");}
		
