// shopmastery 1.0 Copyright 1999-2005 Andrew EordoghURL = 'http://www.sportsgearonline.com.au/';var secure_server = "";var COLOR='';var SIZE = '';var theorder = '';var page;var RRP='';var TOTSAVE = 0;var CODE='';var size = '';function goBasket() {	if (document.cookie.indexOf("[") == -1) {		alert('Your shopping basket is empty!!');		} else {		file = URL +'shopmastery_basket.php';		mywindow=open(file,"","height=450,width=750,top=20,left=250,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no");			}}function goCheckout() {	if (document.cookie.indexOf("[") == -1) {		alert("You have not ordered any items.\nYou must place an order for an item before you can proceed to the checkout.");		} else {// --------------- Limit orders to $50+showTotal();if (totprice < 50) {	alert("Your order total is $" +cent(totprice)+ "\nUnfortunately we can only accept orders of $50 or more.");	return;}				thecookie = document.cookie;						location.href = secure_server + URL +'shopmastery_checkout.php?cookie=' +thecookie;	}}function goCheckout2() {	if (document.cookie.indexOf("[") == -1) {		alert("You have not ordered any items.\nYou must place an order for an item before you can proceed to the checkout.");		} else {// --------------- Limit orders to $50+showTotal();if (totprice < 50) {	alert("Your order total is $" +cent(totprice)+ "\nUnfortunately we can only accept orders of $50 or more.");	return;}			thecookie = document.cookie;		parent.opener.location.href = secure_server + URL +'shopmastery_checkout.php?cookie=' +thecookie;		self.close();	}}function recalc() {	history.go(0);}function addBasket(DESC,PRICE,RRP,CODE,QTY) {// alert(document.cookie);// --------------------------- check colorif (document.shopmastery.size) {	if (document.shopmastery.size.selectedIndex == 0) {	alert('Please select a size for this item.');	return false;	}SIZE = document.shopmastery.size.value;}// --------------------------- check colorif (document.shopmastery.colors) {	if (document.shopmastery.colors.selectedIndex == 0) {	alert('Please select a colour for this item.');	return false;	}COLOR = document.shopmastery.colors.value;}// --------------------------- check qty	if (QTY =="") { 		QTY=0;		}			QTY=parseInt(QTY)		TOTAL = cent(QTY * PRICE);		PRICE = cent(PRICE);		if (QTY <= 0) {			rc = alert('Please tell us how many \\r' +DESC+ '\\r you need.');			} else {if (SIZE) { size ="Size: " +SIZE; }var msg = 'Add '+QTY+' x '+COLOR+ ' '+DESC+ ' @ \$'+PRICE+' '+size+' for a total of \$'+TOTAL+' to your order?';						if (confirm(msg)) {			index = document.cookie.indexOf("myBasket");			countbegin = (document.cookie.indexOf("=", index) + 1);			countend = document.cookie.indexOf(";", index);				if (countend == -1) {					countend = document.cookie.length;	        	}//path="/";document.cookie="myBasket="+document.cookie.substring(countbegin, countend)+'[' +DESC+ '|' +PRICE+'|' +COLOR+'|' +SIZE+'|' +RRP+'|'+CODE+'|'+QTY+ "]" + (("/" == null)    ? "" : "; path=" + "/") ;			}	}}	function cent(amount) {     amount -= 0;     amount = (Math.round(amount*100))/100;     return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount); }function showBasket() {index = document.cookie.indexOf("myBasket");countbegin = (document.cookie.indexOf("=", index) + 1);countend = document.cookie.indexOf(";", index);	if (countend == -1) {		countend = document.cookie.length;	}fulllist = document.cookie.substring(countbegin, countend);totprice = 0;document.writeln('<FORM NAME="updateform">');document.writeln('<CENTER><TABLE border=0 cellspacing=0 cellpadding=0 BGCOLOR="#B21108" width=95%><TR><TD>');document.writeln('<CENTER><TABLE border=0 cellspacing=1 cellpadding=3 bgcolor=black class="w10" width=100%>');document.writeln('<TR BGCOLOR="#B21108" align=center height=30><td class="w10"><b>Qty</TD>');document.writeln('<td class="w10"><b>Code</TD>');document.writeln('<td class="w10"><b>Description</TD>');document.writeln('<td class="w10"><b>Size</TD>');document.writeln('<td class="w10"><b>Colour</TD>');document.writeln('<td class="w10" NOWRAP><b>Retail<br>Price</b></td>');document.writeln('<td class="w10" NOWRAP><b>Our<br>Price</b></td>');document.writeln('<td class="w10"><b>Sub Total</b></td>');document.writeln('<td class="w10" NOWRAP><b>Save</b></td>');if (page != 'checkout') {document.writeln('<td width=20 class="w10"><B>Delete</TD></TR>');}		itemlist = 0;		for (var i = 0; i <= fulllist.length; i++) {			if (fulllist.substring(i,i+1) == '[') {				itemstart = i+1;				thisitem = 1;			} else if (fulllist.substring(i,i+1) == ']') {				itemend = i;				thequantity = fulllist.substring(itemstart, itemend);				itemtotal = 0;			itemtotal = (eval(PRICE * thequantity));				temptotal = itemtotal * 100;				totprice = totprice + itemtotal;				itemlist=itemlist+1;if (page == 'checkout') {document.write('<tr bgcolor=white><td align=center><font color=black>' +thequantity+ '</td>');} else {document.write('<tr bgcolor=white><td align=center><INPUT TYPE=TEXT NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=2 onchange="changeItem('+itemlist+',document.updateform.quant'+itemlist+'.value)" class="qty"></td>');}SAVE = thequantity * (RRP - PRICE);TOTSAVE = TOTSAVE + SAVE;document.write('<td align=left class="f10">'+CODE+'</td>');document.write('<td align=left width=300 class="f10">'+DESC+'</td>');document.write('<td align=center class="f10">'+SIZE+'</td>');document.write('<td align=center class="f10">'+COLOR+'</td>');document.write('<td align=center class="f10">'+RRP+'</td>');document.write('<td align=center class="f10">'+PRICE+'</td>');document.write('<td align="right" bgcolor="#EFECEC" class="f10"><B>\$'+cent(itemtotal)+'</td>');document.write('<td align=right class="f10"  bgcolor="#FEE8EA">\$'+cent(SAVE)+'</td>');if (page != 'checkout') {document.write('<td align=center><a href="javascript:removeItem('+itemlist+')"><img src="admin/images/trash.gif" border=0 width=15 height=21></td></tr>');}theorder = theorder+DESC+'|'+PRICE+'|'+COLOR+'|'+SIZE+'|'+RRP+'|'+CODE+'|'+thequantity+']';			} else if (fulllist.substring(i,i+1) == '|') {				if (thisitem==1) DESC = fulllist.substring(itemstart, i);				if (thisitem==2) PRICE = fulllist.substring(itemstart, i);				if (thisitem==3) COLOR = fulllist.substring(itemstart, i);				if (thisitem==4) SIZE = fulllist.substring(itemstart, i);				if (thisitem==5) RRP = fulllist.substring(itemstart, i);				if (thisitem==6) CODE = fulllist.substring(itemstart, i);				thisitem++;				itemstart=i+1;			}		}delivery = parseFloat(document.shopmastery.delivery.value);// alert(delivery);if (delivery) {document.writeln('<tr BGCOLOR="#EFECEC"><td colspan=7 align=right><font color=black><B>DELIVERY</b>&nbsp;</td><td align=right colspan=1 class="f10" bgcolor="#EFECEC"><B>\$'+cent(delivery)+ '</td><td bgcolor="#FEE8EA" class="f10">');totprice = totprice + delivery;}document.writeln('<tr BGCOLOR="#B21108"><td colspan=7 align=right><font color=white><B>TOTAL</b>&nbsp;</td><td align=right colspan=1 class="f10" bgcolor="#EFECEC"><B>\$'+cent(totprice)+ '</td><td bgcolor="#FEE8EA" class="f10"><font color="black">\$' +cent(TOTSAVE));if (page != 'checkout') {document.writeln('</td><td bgcolor=white>&nbsp;</td>');}document.writeln('</TR></TABLE>');document.writeln('</TD></TR></TABLE>');}	function changeItem(itemno, newquant) {		newItemList = null;		itemlist = 0;		for (var i = 0; i <= fulllist.length; i++) {			if (fulllist.substring(i,i+1) == '[') {				thisitem = 1;				itemstart = i+1;				fullstart = i+1;			} else if (fulllist.substring(i,i+1) == ']') {				itemend = i;				itemlist=itemlist+1;				if (itemlist != itemno) {					newItemList = newItemList+'['+fulllist.substring(fullstart, itemend)+']';				} else {					newItemList = newItemList + '['+DESC+ '|' +PRICE+'|' +COLOR+'|' +SIZE+'|'+RRP+'|'+CODE+'|' +newquant+']';				}			} else if (fulllist.substring(i,i+1) == '|') {				if (thisitem==1) DESC = fulllist.substring(itemstart, i);				if (thisitem==2) PRICE = fulllist.substring(itemstart, i);				if (thisitem==3) COLOR = fulllist.substring(itemstart, i);				if (thisitem==4) SIZE = fulllist.substring(itemstart, i);				if (thisitem==5) RRP = fulllist.substring(itemstart, i);				if (thisitem==6) CODE = fulllist.substring(itemstart, i);				thisitem++;				itemstart=i+1;			}		}		index = document.cookie.indexOf("myBasket");		document.cookie="myBasket="+newItemList  + (("/" == null)    ? "" : "; path=" + "/");		history.go(0);	}function removeItem(itemno) {	DESC = fulllist.substring(itemstart, itemend);			if (confirm('Are you sure you want to delete this item from your order?')) {		newItemList = null;		itemlist = 0;		for (var i = 0; i <= fulllist.length; i++) {			if (fulllist.substring(i,i+1) == '[') {				itemstart = i+1;			} else if (fulllist.substring(i,i+1) == ']') {				itemend = i;				DESC = fulllist.substring(itemstart, itemend);				itemlist=itemlist+1;				if (itemlist != itemno) {					newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']';				}			}		}		index = document.cookie.indexOf("myBasket");		document.cookie="myBasket="+newItemList + (("/" == null)    ? "" : "; path=" + "/") ;		history.go(0);	}}function goPop(id) {location.href = URL +'shopmastery_pop.php?id=' +id;				}function showTotal() {index = document.cookie.indexOf("myBasket");countbegin = (document.cookie.indexOf("=", index) + 1);countend = document.cookie.indexOf(";", index);	if (countend == -1) {		countend = document.cookie.length;	}fulllist = document.cookie.substring(countbegin, countend);totprice = 0;		itemlist = 0;		for (var i = 0; i <= fulllist.length; i++) {			if (fulllist.substring(i,i+1) == '[') {				itemstart = i+1;				thisitem = 1;			} else if (fulllist.substring(i,i+1) == ']') {				itemend = i;				thequantity = fulllist.substring(itemstart, itemend);				itemtotal = 0;			itemtotal = (eval(PRICE * thequantity));				temptotal = itemtotal * 100;				totprice = totprice + itemtotal;				itemlist=itemlist+1;			} else if (fulllist.substring(i,i+1) == '|') {				if (thisitem==1) DESC = fulllist.substring(itemstart, i);				if (thisitem==2) PRICE = fulllist.substring(itemstart, i);				if (thisitem==3) COLOR = fulllist.substring(itemstart, i);				if (thisitem==4) SIZE = fulllist.substring(itemstart, i);				if (thisitem==5) RRP = fulllist.substring(itemstart, i);				if (thisitem==6) CODE = fulllist.substring(itemstart, i);				thisitem++;				itemstart=i+1;			}		}}