
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 SubmitToBasket(strProdId, strProdCode, strProdPrice, strProdDesc, iProdQty, strProdWeight) {
	if ((strProdCode.Trim() == "") || (strProdPrice.Trim() == "") || (strProdDesc.Trim() == "")) {
		alert("Error: Could not Add Item To Basket");
	} else {
		document.AddToBasket.hfCurrentPage.value	= location.href
		
		document.AddToBasket.hfProdId.value			= strProdId
		document.AddToBasket.hfProdCode.value		= strProdCode.Trim();
		document.AddToBasket.hfProdPrice.value		= strProdPrice.Trim();
		document.AddToBasket.hfProdDesc.value		= strProdDesc.Trim();
		//document.AddToBasket.hfProdQty.value		= document.DataForm.elements["cboQty"+strProdId.Trim()].value;
		//document.AddToBasket.hfProdWeight.value	= strProdWeight.Trim();
		document.AddToBasket.submit();
	}
}

function SubmitToBasketAJAX(strProdId, strProdCode, strProdPrice, strProdDesc, iProdQty, strProdWeight) {
	//SubmitToBasket Function using AJAX to post data - to be used in conjunection with the quick basket
	if ((strProdCode.Trim() == "") || (strProdPrice.Trim() == "") || (strProdDesc.Trim() == "")) {
		alert("Error: Could not Add Item To Basket");
	} else {
		
		urlToPost = "../cart/addToBasketAJAX.asp";
		urlToPost += "?hfProdId=" + strProdId;
		urlToPost += "&hfProdCode=" + escape(strProdCode.Trim());
		urlToPost += "&hfProdPrice=" + escape(strProdPrice.Trim());
		urlToPost += "&hfProdDesc=" + escape(strProdDesc.Trim());
		//urlToPost += "&hfProdQty=" + escape(document.DataForm.elements["cboQty"+strProdId.Trim()].value);
		//urlToPost += "&hfProdWeight=" + escape(strProdWeight.Trim());

		msg = postAjax(urlToPost);
		
		if (Left(msg,7) == "Success") {
			document.getElementById("basket_summary").innerHTML = Right(msg,((msg.length)-8));
			document.getElementById("basket_item_desc").innerHTML = strProdDesc;
			document.getElementById("basket_item_price").innerHTML = "£" + strProdPrice;
			
			qb_show();
		} else {
			alert("There has been a problem adding this item to the basket, \nPlease wait a moment and try again.\nIf the problem persists please contact us.")
		}
	}
}

function BuyNow() {
	document.AddToBasket.submit();
}

function ShoppingAction(PageName) {
	if (PageName != undefined) {
		if (PageName == "Home") {
			document.frmNavigation.action = document.frmNavigation.Normal.value + "index.asp";
		} else if (PageName == "Shopping") {
			if (document.frmNavigation.Continue.value != "") {
				//If we have a contiunue shopping url
				document.frmNavigation.action = document.frmNavigation.Continue.value;
			} else {
				document.frmNavigation.action = document.frmNavigation.Normal.value + "index.asp";
			}
		} else if (PageName == "Basket") {
			document.frmNavigation.action = document.frmNavigation.Normal.value + "cart/basket.asp";
		} else if (PageName == "GoogleCheckout") {
			document.frmNavigation.action = document.frmNavigation.Secure.value + "cart/include/google/googleprocess.asp";
		} else if (PageName == "Details") {
			document.frmNavigation.action = document.frmNavigation.Secure.value + "cart/personal.asp";
		} else if (PageName == "Payment") {
			document.frmNavigation.action = document.frmNavigation.Secure.value + "cart/payment.asp";
		} else if (PageName == "Confirm") {
			document.frmNavigation.action = document.frmNavigation.Secure.value + "cart/confirm.asp";
		}
		document.frmNavigation.submit();
	} else {
		document.frmNavigation.action = document.frmNavigation.Home.value; 
		document.frmNavigation.method = "";
		document.frmNavigation.submit();
	}
}

function limitText(limitField, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
		alert("You can only enter a maximum of " + limitNum + " characters in this field");
	} 
}



// Quick Basket Functions - needed if we are using an in page add to basket - this file then needs to be added to site wide header.asp

qb_delay			= 1000;
qb_duration		= 4000;

function qb_show() {
	qb_container = document.getElementById('basket_notify');
	qb_container.style.display = 'block';
}
function qb_hide() {
	qb_container.style.display = 'none';
}
function qb_delayShowHide() {
	setTimeout("qb_show()", qb_delay);
	setTimeout("qb_hide()", (qb_delay + qb_duration) );
}


/*
<style>

#container {
	position: relative;
}
#basket_notify {
	display: none;
	padding: 30px 60px 15px 15px;
	position: absolute;
	top: 102px;
	left: 390px;
	z-index: 99;
	width: 259px;
	height: 105px;
	background-image: url('../content/layout/basket_notify_bg.gif');
	background-repeat: no-repeat;
	font-size: 13px;
	text-align: center;
}
#basket_notify_icon {
	float: left;
	margin: 0 10px 5px 10px;
}
#basket_notify_close {
	float: right;
	cursor: pointer;
}
#basket_notify div {
	float: left;
	width: 175px;
	height: 40px;
}
#basket_notify .red {
	color: #D12E31;
}
</style>

<div id="basket_notify">
	<img src="../content/layout/basket_notify_icon.gif" width="60" height="45" alt="" title="" id="basket_notify_icon" >
	<img src="../content/layout/basket_notify_close.gif" width="10" height="10" alt="close" title="close" id="basket_notify_close" onclick="qb_hide();" >
	<div>This item has been <br />added to your basket.</div>
	<br clear="all" />
	<b id="basket_item_desc">&nbsp;</b> <br />
	<b class="red" id="basket_item_price">&nbsp;</b><br />
</div>

*/