/*******************************************************
						SPARE PARTS
*******************************************************/
//add a part to the shopping cart from the spare parts page
function AddProdToCart(intSparePartID, guidCart) {
	//required vars
	var oHTTP = new ActiveXObject("Microsoft.XMLHTTP"); 
	var oResponse = document.getElementById('tdResponse');
	var intQuantity = parseInt(document.getElementById('intQty_'+intSparePartID).value);
	if (isNaN(intQuantity) || (intQuantity <= 0)) {
		alert('Please enter a valid quantity.');
		return;
	};
	var strUrl = 'SparePartAdd.asp?intSparePartID=' + intSparePartID.toString() + 
								 '&guidCart=' + guidCart + 
								 '&intQuantity=' + intQuantity;
	var strResult;

	//get states
	oHTTP.open("GET", strUrl, false); 
	oHTTP.send();
	strResult = '' + oHTTP.ResponseText;
	oResponse.innerHTML = strResult;
	document.location.hash = '#top';

	//cleanup
	delete oHTTP;
};


//update the quantity of a part in the shopping cart
function UpdateQuantityInCart(intSparePartID) {
	var intQuantity = parseInt(document.getElementById('intQty_'+intSparePartID).value);
	if (isNaN(intQuantity) || (intQuantity <= 0)) {
		alert('Please enter a valid quantity.');
		return;
	};

	document.location.href = 'SparePartUpdate.asp?intSparePartID=' + intSparePartID + '&intQuantity=' + intQuantity;
};


// Remove a part from the shopping cart
function RemovePartFromCart(intSparePartID) {
	document.location.href = 'SparePartRemove.asp?intSparePartID=' + intSparePartID;
};


// Open the spare part popup window
function OpenSparePartsPopup(intSparePartID) {
	window.open('SparePartsPopup.asp?intSparePartID=' + intSparePartID, 'SparePartsPopup', 'width=575,height=555,top=150,left=150,resizable=0,scrollbars=yes');
};

