// The US Dollar conversion rate.  Edit this at will

var DollarConversionRate     =   1.6;


// Edit the next variable if they wish to use more price breaks in the future..
var maxpricebreaks	  =   4;

var maxitems          =   100;
var maxquant          =   10000;
var minimumquantity   =   1;
var VAT           =   0.175;
var deliveryRate      =   3.5;
var pricing           =   "consumer";
var tradeDiscount     =   12/100;
var novatticked;

// What happens when the user adds to the shopping basket?

var alertAfterAdding  =   0;
var basketAfterAdding =   1;
var grand_total = 0;

// Variable to hold the last page visited before viewing the basket or the checkout
var lastPage;
lastPage              =   "/home/";

// The name of the document which will hold the shopping basket details - 
// N.B. IN RELATION TO FRAME WHICH HOLDS THIS SCRIPT

jwstring              =   "parent.frames['mainwin']";

jsfunctionlocation    =   "parent.jsframe";

noVatOption           =   "No";

var vatrate				  = VAT;

// for live site
paymenturl="https://secure2.webxpress.co.uk/cgi-bin/thermofrostcryo/takecarddetails.cgi";

//test secure url
// var paymenturl="http://testsec.intranet.webxpress/cgi-bin/thermofrostcryo/takecarddetails.cgi";

// *********************************************
// Look & Feel Stuff
// *********************************************

/*** Variables ***/
var indentTable 	   =   true;  // Puts the basket in blockquotes

/*** Outer Table ***/
var outerTable 		   =   true;  // Puts the basket within another table to give it an outline
var outerPadding       =   1;
var outerColour        =   "#666666";

/*** Basket Layout ***/
var basketPadding      =   "4";
var basketSpacing      =   "1"; // 1 is recommended when combined with outerTable true.
var basketBorder       =   "0"; // Use only for debugging
var basketWidth        =   "450" // Use integers or percentile

/*** Fonts & Colours ***/

/*** Main Table Header ***/
var headerColour       =   "#336699";
var headerFontTag      =   '<font face="Verdana, Arial, Helvetica, Sans-serif" size="2" color="white"><b>';
var headerFontEndTag   =   '</b></font>';

/*** Table Field Headings ***/
var fieldHeaderColour  =   "#EBEFF3";
var fieldHeaderFontTag      =   '<font face="Verdana, Arial, Helvetica, Sans-serif" size="2" color="black"><b>';
var fieldHeaderFontEndTag   =   '</b></font>';

/*** Table Footer ***/
var footerColour       =   "#EBEFF3";
var fieldFooterFontTag      =   '<font face="Verdana, Arial, Helvetica, Sans-serif" size="1" color="black">';
var fieldFooterFontEndTag   =   '</font>';

/*** Basket Items ***/
var basketItemColour   =   "#ffffff";
var basketItemFontTag       =   '<font face="Verdana, Arial, Helvetica, Sans-serif" size="1">';
var basketItemFontEndTag    =   '</font>';

/*** Page Footer ***/
var pageFooterFontTag       =   '<font face="Verdana, Arial, Helvetica, Sans-serif" size="2">';
var pageFooterFontEndTag    =   '</font>';

var pageFooterSmallFontTag       =   '<font face="Verdana, Arial, Helvetica, Sans-serif" size="1">';
var pageFooterSmallFontEndTag    =   '</font>';


/*** Empty Basket ***/
var emptyFontTag       =   '<font face="Verdana, Arial, Helvetica, Sans-serif" size="2">';
var emptyFontEndTag    =   '</font>';


/*** Body Tag Attributes ***/
var linkColour         =   "#003366";
var alinkColour        =   "#003366";
var vlinkColour        =   "#003366";
var textColour         =   "#333333";
var backgroundColour   =   "#EDEDED";
var extraBodyTags      =   'background="/images/back.gif" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0"';
var bodyTag            =   '<body text="' + textColour + '" bgcolor="' + backgroundColour + '"link="' + linkColour + '" vlink="' + vlinkColour + '" alink="' + alinkColour + '" ' + extraBodyTags + '>';


/*** Define the style sheet ***/
var styleSheet         =   '<style type="text/css">' +
                           '<!--' +
                           '.menu {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px}'+
                           '.submenu {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px}'+
                           'li {  list-style-image: url(/images/bullet.gif); list-style-type: circle}'+
                           'p {font-family: Verdana, Arial, Helvetica, sans-serif}'+
                           '-->'+
                           '</style>';

/*** Defines the html to head each page ***/                           
var PageHead           =   '<html><head>' + styleSheet +'</head>' + bodyTag;

/*** Defines the appearance of the basket page title - Eg. "Your Shopping Basket" ***/
var basketPageTitle    =   '<blockquote><p><br><img src="/images/banner.gif" width="470" height="60"><br><br>'+
							'<img src="/images/basket.gif" width="470" height="33"></p></blockquote>';
                           
/*** Defines the appearance of the checkout page title - Eg. "The Checkout" ***/
var checkoutPageTitle  =   '<blockquote><p><br><img src="/images/banner.gif" width="470" height="60"><br><br>'+
							'<img src="/images/checkout.gif" width="470" height="33"></p></blockquote>';
                       
var basketPageHead     =   PageHead + basketPageTitle;
var checkOutPageHead   =   PageHead + '<form onSubmit="if (self.document.OrderForm.chkTerms.checked==false) {alert (\'You must tick the box to confirm that you have read the Terms and Conditions of Sales before continuing\');return false;}" name="OrderForm" method="POST" action="'+paymenturl+'" TARGET="_top">' +checkoutPageTitle;

var deliveryMessage = '<p><hr>'+pageFooterFontTag+'* <i>Delivery is free of charge to delivery addresses in England, Wales and Scotland except for the Scottish Highlands (the cities of Dundee, Aberdeen, Inverness and Peterhead are included in the free of charge service), Northern Ireland, the Scilly Isles, the Channel Islands, the Isle of Man and all destinations outside of the United Kingdom including the Republic of Ireland. If delivery is required to a chargeable destination you should not PROCEED TO PAYMENT. Instead please <a href=\"/contact\">contact us</a> during normal office hours to obtain a quotation. Approved credit account customers may PROCEED TO PAYMENT as delivery charges will be made in accordance with the normal terms of your account. Please see <a href="/company/delivery.php">delivery options</a> for more details about our delivery service.</i> </font>';

function getNotEmptyFootContent()
{
notEmptyFootContent = "";
	if (noVatOption == "yes")
	{
		notEmptyFootContent += '<p>'+pageFooterFontTag +'If you are not ordering from the UK, please check this box to use non-VAT prices.</font></p>' +
		'<input type="checkbox" name="novat" '+novatticked+' onClick="'+jsfunctionlocation+'.novat()"></p>';
	}
notEmptyFootContent += '<p>'+pageFooterFontTag +'When you wish to order the above items, click the &quot;Proceed to Checkout&quot; button below..</font></p>';

notEmptyFootContent += pageFooterFontTag+'<input type="button" name="Checkout" value="Proceed to Checkout >>" onClick="javascript: '+ jsfunctionlocation + '.processorder();">' + pageFooterFontEndTag+
'<p><hr>'+pageFooterFontTag+'<a href="'+lastPage+'">&lt;&lt; Continue Shopping </a></font></p>';

return notEmptyFootContent;
}


function emptyBasketPageFoot()
{ return (pageFooterFontTag + '<p><a href="'+lastPage+'">Back</a></p>' + pageFooterFontEndTag +"</body></html>" );}

currentlyEmpty = '<p>Your shopping basket is currently empty.</p>';

basketTitle = 'Your Shopping Basket Contains:';
checkoutTitle = 'Your Final Order:';


var invoicestring="";



var sb_code = new Array(maxitems);
fillArray('sb_code',' ');

var sb_productName = new Array(maxitems);
fillArray('sb_productName',' ');


// In this particular shopping basket, we need various price breaks.  Each price is held in an multidimensional array, in the format
// sb_price[#itemNumber#][#pricebreakno#]=#price#;
// sb_break[#itemNumber#][#pricebreakno#]=#quantity#;

// where #pricebreakno# is a sequential number from 0 to maxpricebreaks (initially 4, but could change in the future)

// The next bit sets up these multidimensional arrays (as javascript cannot do this in a simple manner)

var sb_price = new Array(maxitems);

for (count=0; count < maxitems; count++) 
{	
	sb_price[count] = new Array(maxpricebreaks-1);
	fillArray('sb_price['+count+']',0);
}

var sb_price_break = new Array(maxitems);


for (count=0; count < maxitems; count++) 
{	
	sb_price_break[count] = new Array(maxpricebreaks-1);
	fillArray('sb_price_break['+count+']',0);
}



var sb_quant = new Array(maxitems);
fillArray('sb_quant','0');



// Fill *ArrayName* with the value *value*


function fillArray(ArrayName, value)
{
	eval ("var length = " + ArrayName + ".length;");
	for (i=0; i<=length; i++)
	{
		eval(ArrayName+"["+i+"] = '" + value +"'");
	}
}	

function getCookie (name) {
     var dcookie = document.cookie; 
     var cname = name + "=";
     var clen = dcookie.length;
     var cbegin = 0;
     while (cbegin < clen) 
     {
         var vbegin = cbegin + cname.length;
         if (dcookie.substring(cbegin, vbegin) == cname) 
         { 
         	var vend = dcookie.indexOf (";", vbegin);
            if (vend == -1) vend = clen;
            return unescape(dcookie.substring(vbegin, vend));
         }
         cbegin = dcookie.indexOf(" ", cbegin) + 1;
         if (cbegin == 0) break;
     }
     return null;
}


function novat() 
{
	vatrate=0;
	if ( novatticked=="checked" ) 
	{
		novatticked="";
		vatrate=VAT;
	}
	else 
	{
		novatticked="checked";
		vatrate=0;
	}
	viewbasket();
}


// This function sets trade pricing or turns it off: Call with either "trade" or "consumer"

// The price breaks MUST come through in increasing order.

function addtobasket(code, productName, price_break0, price0, price_break1, price1, price_break2, price2, price_break3, price3,  quant,referrer) 
{
	var emptyslotfound=0;		
	var cont = 0;
	
	lastPage = referrer;
	
	if (quant > maxquant)
		alert("Sorry - the quantity must be less than "+maxquant);
	else if (quant < 1) 
		alert("Sorry - the quantity must be at least 1");
	else
		cont = 1;
			
	quant=parseInt(quant);

	if (cont==1)
	{
		 for ( i=0;i<maxitems;i++) 
	  	 {
		    	if ( sb_quant[i] < 1 && emptyslotfound == 0 ) 
		  		{
		  			emptyslotfound=1; 
		  		 	sb_code[i] = code;
		  	     	sb_productName[i] = productName;
					sb_price[i][0] = price0;
					sb_price[i][1] = price1;
					sb_price[i][2] = price2;
					sb_price[i][3] = price3;
					
					sb_price_break[i][0] = price_break0;
					sb_price_break[i][1] = price_break1;
					sb_price_break[i][2] = price_break2;
					sb_price_break[i][3] = price_break3;
					
					sb_quant[i] = quant;
		  			
			     	if (alertAfterAdding==1)
						alert(quant+" x Item "+ num+" added to shopping bag");
		  			
					if (basketAfterAdding==1)
						//setTimeout('viewbasket(null, sb_productName[i])',100);
			     		viewbasket(null, sb_productName[i]);
				 }
  	  	  } 
  		if ( emptyslotfound == 0 ) 
  			alert( " Sorry - shopping basket full " );
  	}
}	

function decimal(x) 
{
	var n=0,s="";
	n = x * 100;
	n = Math.round(n);
	s = "" + n;
	return s = s.substring(0,s.length-2)+"."+s.substring(s.length-2,s.length);
}



// ***********************************************************************
// These functions display components of the shopping basket and the checkout
// ***********************************************************************

// Just Added Message - Displays the message e.g. 1X Kyolic 600 added to the basket

function preTable(type, product)
{
	preTableString = '<table width="450" border="0" cellspacing="0" cellpadding="0"><tr><td>';
	
	if (type == 'basket' & !(product == null))
	preTableString += '<p>'+pageFooterFontTag+'<b>1 x '+product+'</b> added to your basket'+pageFooterFontTag+'</p><p><b>Note: </b>If you wish to order more that one of these items, please alter the figure in the "Qty." box and click "Update Quantities".</p>';
	
	if (type == 'checkout')
	preTableString += '<p>'+pageFooterFontTag+'When you are ready to order the items listed below, click the "Proceed to Payment Details" button below to transfer to a secure server where you can give us your account or credit card details.'+pageFooterFontTag+'</p>';
	
	preTableString += '<p>'+pageFooterFontTag+'<a href="'+lastPage+'"><< Continue Shopping</a></a>'+pageFooterFontTag+'</p>'+
	'</td></tr></table><br>';
	
	return preTableString;
	
} 

// Table Header - 

function tableHeader(type)
{
	if(type == 'basket')
	{
		headerHTML ='<form name=detailForm>';
		tableTitle = basketTitle;
	}
	else
	{
		headerHTML ="";
		tableTitle = checkoutTitle;
	}
	
	//if(indentTable) headerHTML += '<blockquote>';
	
	if(outerTable)
	{
		headerHTML +=   '<table cellpadding="' + outerPadding + '" cellspacing="0" bgcolor="' + outerColour + '" border="0">'+
						'<tr bgcolor="' + outerColour +'"><td>';
	
	}
	headerHTML += 	'<table cellpadding="' + basketPadding +'" cellspacing="' + basketSpacing + '" border="' + basketBorder + '" width="' + basketWidth + '">'+
					'<tr bgcolor="' + headerColour + '">'+
					'<td colspan="7">'+
					headerFontTag +
					'&nbsp;' +
					tableTitle +
					headerFontEndTag +
					'</td>'+
					'</tr>';
					
	return headerHTML;
}




// Field headers - Displays the bar containing code, price etc.
// Type should be either 'basket' or 'checkout'

function fieldHeaders(type)
{

	headerHTML = 
	'<tr bgcolor="'+fieldHeaderColour+'">'+
	'<td>' + fieldHeaderFontTag + 'Code' + fieldHeaderFontEndTag + '</td>'+
	'<td>' + fieldHeaderFontTag + 'Qty.' + fieldHeaderFontEndTag + '</td>'+
	'<td nowrap colspan=2>' + fieldHeaderFontTag + 'Description' + fieldHeaderFontEndTag + '</td>'+
	'<td align="right">' + fieldHeaderFontTag + 'Price Each' + fieldHeaderFontEndTag + '</td>'+
	'<td align="right">' + fieldHeaderFontTag + 'Item Total' + fieldHeaderFontEndTag + '</td>'+
	'<td>' + fieldHeaderFontTag;
	
	if (type == 'basket')
		headerHTML += "Remove";
	else
		headerHTML += "&nbsp;";
	
	headerHTML += fieldHeaderFontEndTag + '</td>'+
	'</tr>';
	
	return headerHTML;

}

// This function takes an array of price breaks and decides from the quantity which one to use
// All it does is go through each one to find the first one that the quantity is larger than.

function whichPriceBreak(priceBreaks, quantity)
{	
	for (count=maxpricebreaks-1; count>-1; count--)
	{
		if (quantity >= priceBreaks[count] && !(priceBreaks[count] == 0))
			return count;
	}
	alert ("Error - The order amount is too low");
}

// Item details - All of the details about the items (code, price etc)

function itemDetails(type)
{
	total=0;
	invoicestring= "";
	for (i=0;i<maxitems;i++) 
	
	{
		
		if (sb_quant[i] > 0 ) 
		{
		
		pricing = getCookie('ckQV');
		
		// Get the line total.. Need to work out which price break to use
		
		priceBreakToUse = whichPriceBreak(sb_price_break[i], sb_quant[i]);
		
		priceToUse = sb_price[i][priceBreakToUse];
		
		line_total = sb_quant[i]*priceToUse;
					
	    rv ='<tr bgcolor="' + basketItemColour + '" align="left">'+
		'<td valign="top">' + basketItemFontTag + sb_code[i] + basketItemFontEndTag + '</td>'+
		'<td align="left" valign="top">' + basketItemFontTag;
		
		if (type == 'basket')
		{
			rv += '<input type="Text" size=2 name="newQuant'+i+'" value="'+sb_quant[i]+'">';
			
			// We may need this again..
			// onchange="'+jsfunctionlocation+'.changequantity('+i+',self.document.detailForm.newQuant'+i+'.value);"
		}
		else
		{
			rv += sb_quant[i];
		}
		rv +=
	    basketItemFontEndTag + '</td>'+
		'<td align="left" valign="top" nowrap colspan=2>' + basketItemFontTag + sb_productName[i] + basketItemFontEndTag + '</td>'+
		'<td align="right" valign="top" nowrap>' + basketItemFontTag +"&pound;" + decimal(priceToUse)+ '' + basketItemFontEndTag + '</td>'+
		'<td align="right" valign="top" nowrap>' + basketItemFontTag +"&pound;" + decimal(line_total) + ''+ basketItemFontEndTag +'</td>'+
		'<td align="center" valign="top"><a href="javascript:' + jsfunctionlocation + '.removefrombasket('+i+')">';
			
		if (type == "basket")
		{
			rv += basketItemFontTag + 'Remove' + basketItemFontEndTag;
		}
		else
		{
			rv += "&nbsp;";
		}
		rv += '</a></td></tr>';
		
		invoicestring += rv;
		total +=line_total; 
	    }
	}
	return invoicestring;
}



// Table footer - The bottom part of the table, displaying totals, discount, vat etc..

function tableFooter(type)
{	
	// Add VAT and work out net total
	vat=total*vatrate;
		
	//shipping=workOutShipping(total+vat);
	shipping =0;
	
	// Add the vat to make the final price
	grand_total=total+vat;
	
	footerHTML='<tr bgcolor="'+footerColour+'"><td colspan="3" nowrap>';
	
	if (type=='basket')
		footerHTML+=  fieldFooterFontTag +'<input type="Button" name="" value="Update Quantities" onClick="'+jsfunctionlocation+'.changeAllQuantities();"><br><font size=1>(Click after changing any quantity</font>)'+fieldFooterFontEndTag;
	else
		footerHTML+= "&nbsp;";
	
	footerHTML+=  '</td><td nowrap colspan="2" align="right" valign="top">' + fieldFooterFontTag;
	
	if (novatticked == "checked"){
	footerHTML+='<b>Total:<br><font size=1>(inc. delivery*)</font></b>';
	}else{
	footerHTML+=	'Subtotal:<br>'+
					'Vat:<br>'+
					'<b>Total:<br><font size=1>(inc. delivery*)</font></b>';
	}
					
	footerHTML+=	fieldFooterFontEndTag + '</td>';
			

	footerHTML+=	'<td align="right" bgcolor="#FFFFFF" valign="top" colspan="1" nowrap>' + fieldFooterFontTag;
	

	if (novatticked == "checked"){
	footerHTML+=	'<font size=-2>&pound;'+decimal(grand_total) + fieldFooterFontEndTag;
	}else{
	footerHTML+=	'<font size=-2>&pound;'+decimal(total)+ '<br>'+
					'<font size=-2>&pound;'+decimal(vat)+ '<br>'+
					'<font size=-2>&pound;'+decimal(grand_total)+ fieldFooterFontEndTag;
	}
	
	
	footerHTML+=    '</td><td>&nbsp;</td></tr>'+
		            '</table>'; 
	
	if(outerTable)
	{
		footerHTML +=   '</td></tr></table>';
	
	}
	
	//if(indentTable) footerHTML += "</blockquote>";
	
	
	
	return footerHTML;
}

function pageFooter(type)
{
	
	if (type=='checkout')
	{
		footerHTML="";
		
		if(indentTable) footerHTML += '<blockquote>';
		
		footerHTML +=
		'<table width="' + basketWidth + '" border="0" cellspacing="0" cellpadding="0"><tr><td>'+
		pageFooterFontTag+

		//'<p align="right"><A href="javascript: parent.jsframe.viewbasket();">Change Contents of your basket</A><br><a href="'+lastPage+'">Back to the products</a></P>'+
		//'<p>When you are ready to order the above items, click the "Continue" button below to transfer to a secure server where you can give us your payment details.<p>'+
	   '<p><i>Note: Before continuing please make sure your order is correct, as you will not be able to change the contents of your basket after you leave this page.</i> <a href="javascript: parent.jsframe.viewbasket();">Change Quantities Now</a></p>'+
		'<p>I confirm that I have read the <a href="/company/terms_and_conditions.php">Terms and Conditions</a> of Sales and accept them&nbsp;&nbsp;<input type="Checkbox" name="chkTerms" value="checked"> <i>(Tick this box)</i></p>'+
		'<p><input type="Submit" value="Proceed to Payment Details >>">&nbsp;&nbsp;'+
		'<p><hr>'+pageFooterFontTag+'<a href="'+lastPage+'">&lt;&lt; Continue Shopping </a></font></p>'+
		deliveryMessage +
		'<input type=hidden name=invoice_string value=\''+checkoutTable+'\'>'+
		'<input type=hidden name=payment_amount value=\''+grand_total+'\'>'+
		pageFooterFontEndTag +
		'</td></tr></table>';
		
		if(indentTable) footerHTML += '</blockquote>';
		footerHTML +=
		
		'</form></body></html>';
	}
	else if(type=='basket')
	{
		footerHTML="";
		
		if(indentTable) footerHTML += '<blockquote>';
				
		footerHTML +=
		'<table width="' + basketWidth + '" border="0" cellspacing="0" cellpadding="0"><tr><td>'+
		getNotEmptyFootContent()+
		deliveryMessage +
		'</td></tr></table>';
		
		if(indentTable) footerHTML += '</blockquote>';
		
		footerHTML +=
		'</form></body></html>';
	}
	return footerHTML;
}





function closeDocument()
{
	var jw, jwd;
	eval("jw= " +  jwstring);
	jwd = jw.document;
	//alert("Closing");
	jwd.close();
	
}


function removefrombasket(x) 
{
     sb_code[x] =' ';
     sb_productName[x] = 0;
	 for (count=0; count<maxpricebreaks; count++)
	 {
	 	sb_price[x][count] = 0;
	 	sb_price_break[x][count] = 0;
	 }
	 
	 sb_quant[x] = 0;
     viewbasket();
}

function changeAllQuantities()
{
	var i=0;
	
	for (i=0;i<maxitems;i++) 
	{
		if (sb_quant[i] > 0 ) 
		{
			
			eval("newquant="+jwstring+".document.detailForm.newQuant"+i+".value;");
			changequantity(i, newquant);
		}
	}
	
	// I haven't a clue why this setTimeout needs to be here, but it does otherwise IE5 crashes every time the user updates a quantity.  Such is life.
		setTimeout('viewbasket()', 100);
}

function changequantity(i, newquant) 
{
	if ( newquant == 0 )
	{
		removefrombasket(i);
	}
	else
	{
		if ( newquant > maxquant )
		{
		alert("Sorry - the quantity must be less than "+maxquant);
		}
		
		else if ( newquant < minimumquantity )
		{
			alert("Sorry - the quantity must be at least "+(minimumquantity));
		}
		
		 else
		{
			//Convert to an integer just in case someone types in something silly..
			sb_quant[i] =  parseInt(newquant);
	    }
		
		
     }
	
}


function processorder(referrer) 
{

	// Remember where the user came from
	// lastPage = referrer;
	if (!(referrer == null))
		lastPage = referrer;
		
	display_order();
	// The below is not necessary for Thermofrost as users are allowed to checkout even if their basket is empty

	//var notempty=0;
	//for (i=0;i<maxitems;i++) 
	//{
	//	if (sb_quant[i] > 0 ) 
	//	{
	//		notempty=1;
	//	}
	//}		
	//if ( notempty == 1 ) 
	//{
    //   	display_order();
	//}
	//else 
	//{
	//	alert("You cannot checkout, your basket is empty" );
	//}  
}



function display_order() 
{
	//Need to blow away frames here as we are switching to the secure server and
	// we need to seethe secure padlock icon close at the bottom of the browser

	eval("jw= " +  jwstring);
	jwd = jw.document;


	//var i,rv,vat,grand_total;
	
	total=0;
	
	itemDetailsString = itemDetails('checkout');
	

	// Write Page!
	
	
	checkoutTable = tableHeader('checkout')+	
					fieldHeaders('checkout')+
					itemDetailsString+
					tableFooter('checkout');
	
	jwd.write(		checkOutPageHead);
	if(indentTable)jwd.writeln("<blockquote>");
	jwd.writeln(preTable('checkout'));
	jwd.write(		checkoutTable);
	if(indentTable)jwd.writeln("</blockquote>");
	jwd.write(		pageFooter('checkout'));
	
	jwd.close();
}


// Viewbasket - Display the contents of the shopping basket

function viewbasket(referrer, justAdded) 
{
	
	// Remember where the user came from
	// lastPage = referrer;
	if (!(referrer == null))
		lastPage = referrer;
		
	// Create Variables
	var i,rv,jw, jwd;
	total = 0;
	
	// Sort out where to print to 
	eval("jw= " +  jwstring);
	jwd = jw.document;
	
	itemDetailsString = itemDetails('basket');
	  
	// Now write!!    
	if (total > 0) 
	{			
		//vat=total*vatrate;
	 	jwd.writeln(	basketPageHead);
	 	if(indentTable)jwd.writeln("<blockquote>");
		
		jwd.writeln(preTable('basket', justAdded));

		jwd.writeln(	tableHeader('basket')+
						fieldHeaders('basket')+
						itemDetailsString+
						tableFooter('basket'));
		if(indentTable)jwd.writeln("</blockquote>");
		jwd.writeln(	pageFooter('basket'));
	}
	else 
	{
		jwd.writeln(	basketPageHead);
		
		if(indentTable)jwd.writeln("<blockquote>");
						
		jwd.writeln(	emptyFontTag +
						currentlyEmpty + 
						emptyFontEndTag);
		if(indentTable)jwd.writeln("<blockquote>");
		jwd.writeln(	emptyBasketPageFoot() ) ;
	}
	setTimeout("closeDocument()",100);
}
