
String.prototype.RTrim = function() {return this.replace(/\s+$/, "");}
String.prototype.LTrim = function() {return this.replace(/^\s+/, "");}
String.prototype.Trim  = function() {return this.RTrim().LTrim();}


function fUpdateBasketQty(iOrderline, iProdId, iOldQty, iNewQty) {
	var iComboValue;
	
	if (iOrderline == "") 													alert("Error: Could not Alter Item\'s Quantity");
	if (iProdId == "") 														alert("Error: Could not Alter Item\'s Quantity");
	if ((iComboValue = iNewQty.options[iNewQty.selectedIndex].value) < 1)	alert("Error: Cannot Update Basket Quantity");
	
	document.frmBasket.hfOrderline.value 		= iOrderline;
	document.frmBasket.hfProdId.value 			= iProdId;
	document.frmBasket.hfOldProdQty.value 		= iOldQty;
	document.frmBasket.hfNewProdQty.value 		= iComboValue;
	
	document.frmBasket.hfReturn.value = location.href
	document.frmBasket.action = "updateBasket.asp"
	document.frmBasket.submit();
}

function fRemoveFromBasket(iOrderline) {
	var iComboValue;
	
	if (iOrderline == "") 													alert("Error: Could not Remove Item");
	document.frmBasket.hfOrderline.value 		= iOrderline;
	
	document.frmBasket.hfReturn.value = location.href
	document.frmBasket.action = "../cart/updateBasket.asp?action=remove"
	document.frmBasket.submit();
}

function fUpdatePostageRegion(iRegionID) {
	document.frmBasket.hfReturn.value = location.href
	document.frmBasket.hfPostageRegion.value 	= iRegionID;
	document.frmBasket.action = "updateBasketRegion.asp"
	document.frmBasket.submit();
}

function fUpdateVoucher() {
	var oEle									= document.frmBasket;
	if (oEle.voucherCode.value == "") {
		alert("Please enter a voucher code");
		oEle.voucherCode.focus();
		return false;
	} else {	
		oEle.action									= "updateBasketVoucher.asp?action=add"
		oEle.submit();
	}
}

function fRemoveVoucher() {
	var oEle									= document.frmBasket;
	oEle.action									= "updateBasketVoucher.asp?action=remove"
	oEle.submit();
}
