// showItems() - displays quote basket in a table

	function showItems() {

		index = document.cookie.indexOf("TheBasket");

		countbegin = (document.cookie.indexOf("=", index) + 1);

        	countend = document.cookie.indexOf(";", index);

        	if (countend == -1) {

            		countend = document.cookie.length;

        	}
		
		fulllist = document.cookie.substring(countbegin, countend);
		subtotal = 0;
    
		document.writeln('<font class="CobaltFormHeaderFont" >Items in Your Rental Quote List</font><table class="CobaltFormTABLE" cellpadding="3" border="0" width="660"><tr>');

		document.writeln('<FORM NAME="updateform">');

		document.writeln('<td class="CobaltColumnTD" nowrap><p align="center">Quantity</p></td><td class="CobaltColumnTD" nowrap><p align="left">Description</p></td><td class="CobaltColumnTD" nowrap><p align="left">Product Code</p></td><td class="CobaltColumnTD" nowrap><p align="center">Remove</p></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 = (thequantity);
				

				temptotal = itemtotal * 0;

				subtotal = subtotal + itemtotal;

				itemlist=itemlist+1;





		document.write('<tr><p align="center"><td class="CobaltDataTD"><INPUT NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=3 onchange="amendItem('+itemlist+',document.updateform.quant'+itemlist+'.value)"></font></td><td class="CobaltDataTD">&nbsp;<FONT SIZE="-1" FACE="Geneva,Arial">'+thedescript+'</FONT></td>');
		document.write('</td><td class="CobaltDataTD"><font size="-1" face="Geneva,Arial">'+theitem+'</font></td><td class="CobaltDataTD"><p align="center"><a href="javascript:removeItem('+itemlist+')"><img border="0" src="http://www.techrentals.com.au/images/remove.gif" width="24" height="24" alt="Delete Item"></a>');
		document.writeln('<INPUT TYPE="hidden" NAME="Division '+itemlist+'" VALUE="'+thediv+'" SIZE="40">');
			} else if (fulllist.substring(i,i+1) == '|') {

				if (thisitem==1) theitem = fulllist.substring(itemstart, i);

				if (thisitem==2) thedescript = fulllist.substring(itemstart, i);

				if (thisitem==3) thediv = fulllist.substring(itemstart, i);

				thisitem++;

				itemstart=i+1;

			}

		}
		document.writeln('</p></td></tr><tr><td class="CobaltDataTD" colspan="5">&nbsp;</td></tr><tr><td class="CobaltFooterTD" nowrap colspan="5"><center><form><input class="CobaltButton" type="button" value="< Add more items" onclick="history.go(-1)"><input class="CobaltButton" type="button" name="checkout" value="Finish Quote >" onclick="goOrder()"></form></center></td></tr></table>');

		document.writeln('</FORM>');
		
		

	}


		
  


	function amendItem(itemno, newquant) {



                if (newquant >= 0) {


		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 + '['+theitem+'|'+thedescript+'|'+thediv+'|'+newquant+']';

				}

			} else if (fulllist.substring(i,i+1) == '|') {

				if (thisitem==1) theitem = fulllist.substring(itemstart, i);

				if (thisitem==2) thedescript = fulllist.substring(itemstart, i);

				if (thisitem==3) thediv = fulllist.substring(itemstart, i);

				thisitem++;

				itemstart=i+1;

			}

		}

	}

		index = document.cookie.indexOf("TheBasket");

		document.cookie="TheBasket="+newItemList;

		location = "Products_ViewQuotes.asp";




	}




	function removeItem(itemno) {

		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;

				theitem = fulllist.substring(itemstart, itemend);

				itemlist=itemlist+1;

				if (itemlist != itemno) {

					newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']';

				}

			}

		}

		index = document.cookie.indexOf("TheBasket");

		document.cookie="TheBasket="+newItemList;

		self.location = "Products_ViewQuotes.asp";

	}



	// clearBasket() - removes all items from the basket

	function clearBasket() {

		if (confirm('Clear quote basket?')) {

			index = document.cookie.indexOf("TheBasket");

			document.cookie="TheBasket=.";

			location = "Products_ViewQuotes.asp";
			

		}

	}