
//
// Functions included in main cart display page
//
// (c)2001 Electronic Media Group - www.emgnet.co.uk
//

// function to display current cart contents. Will probably need changing for
// different uses for different format output etc.
//
// Also, various settings in the form need changing to send the form to the
// Relevant formmailer, and set the recipient, subject etc.

function newShowCart() {
	var FF1="<FONT FACE='ARIAL' SIZe='5'><B>";
	var FF2="<FONT FACE='ARIAL' SIZE='-1'>";
	var FF3=FF2;
	var temphead='top.leftFrame.updateHeader("'+top.leftFrame.lastimg+'")';
	var strBasket = '';
	var intCount = 0;
	document.writeln("<HTML><HEAD><TITLE>test</TITLE>");
	document.writeln('<style type="text/css">');
	document.writeln('body {  background-attachment: fixed; background-image: url(images/corner.gif); background-repeat: no-repeat; background-position: left top}');
	document.writeln('</style>');
	document.writeln("<script type='text/javascript'>");
  document.writeln("var _gaq = _gaq || [];");
  document.writeln("_gaq.push(['_setAccount', 'UA-16900394-1']);");
  document.writeln("_gaq.push(['_trackPageview']);");
  document.writeln("(function() {");
  document.writeln("var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;");
  document.writeln("ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';");
  document.writeln("var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);");
  document.writeln("})();");
	document.writeln("</script>");
	document.writeln("</head>");
	document.write("<BODY");
	if (top.leftFrame.shopback)
	{
		document.write(" BACKGROUND='"+top.leftFrame.shopback+"'");
	}
	if (top.leftFrame.shoplink)
	{
		document.write(" LINK='"+top.leftFrame.shoplink+"'");
	}
	if (top.leftFrame.shopalink)
	{
		document.write(" ALINK='"+top.leftFrame.shopalink+"'");
	}
	if (top.leftFrame.shopvlink)
	{
		document.write(" VLINK='"+top.leftFrame.shopvlink+"'");
	}
	if (top.leftFrame.shoptcol)
	{
		document.write(" TEXT='"+top.leftFrame.shoptcol+"'");
	}
	if (top.leftFrame.shopbcol)
	{
		document.write(" BGCOLOR='"+top.leftFrame.shopbcol+"'");
	}
	document.writeln(">");
	document.writeln("<CENTER>");
	document.writeln("<TABLE width='75%'><TR><TD>");
	document.writeln("<cENTER>");
	document.writeln("<A href='"+top.leftFrame.getUrl()+"' OnClick='"+temphead+"'>"+FF2+"Back to previous product page.</a><P>");
	document.writeln("</cENTER>");
        document.writeln(FF1+"Current Shopping Cart: </B>");
	

	// action needs changing to local version of formmailer or whatever.


	document.writeln("<FORM action='http://www.scaffold-towers.net/confirm2.php' method='post'>");
	
        document.writeln("<TABLE width='500px' BORDER=2><TR align=center>");

        // Header defs for shopping list table.

        var headers = new Array("Product","Quan","&nbsp;","Price &pound;<BR><SMALL>Sterling</SMALL>","&nbsp;","Total &pound;<BR><SMALL>Sterling</SMALL>");

	// Relevant widths to use for columns defined in headers Array

	var widths = new Array("58%","5%","4%","15%","2%","18%");
        var tcart = top.leftFrame.cart;
        var total = 0.00;
        var ttot = 0.00;

        // Display the headers for the table.

        for (co in headers)
        {
                document.writeln("<TD width='"+widths[co]+"'>"+FF2+headers[co]+"</TD>");
        }
	document.writeln("</TR>");

        // Cycle through the items.

        for ( co in tcart )
        {
		// Displayed Section for each Item

		temphead2='top.leftFrame.updateHeader("'+tcart[co].headerimg+'")';
                document.writeln("<TR>");
                document.writeln("<TD><A href='"+tcart[co].url+"'>"+FF2+tcart[co].name+"</A></td>");
		if ( (tcart[co].size>-1) || (tcart[co].colour>-1))
		{
		   document.write("<BR>");
		   if (tcart[co].size>-1)
		   {
			document.writeln(FF2+"<SMALL>(Size:"+tcart[co].sizeval+")</SMALL>");
		   }
		   if (tcart[co].colour>-1)
		   {
			document.writeln(FF2+"<SMALL>(Colour:"+tcart[co].colval+")</SMALL>");
		   }
		}
                document.writeln("<TD align=center>"+FF2+tcart[co].quan+"</TD>");
                document.writeln("<TD align=center>"+FF2+"@</TD>");
                document.writeln("<TD align=right>"+FF2+top.leftFrame.tdv(tcart[co].price)+"</TD>");
                document.writeln("<TD align=center>"+FF2+"=</TD>");
                ttot =tcart[co].price*tcart[co].quan;
                document.writeln("<TD align=right>"+FF2+top.leftFrame.tdv(ttot)+"</TD>");
                total+=eval(ttot);
	
		// Hidden Fields for formmailer to send
		strBasket += co+' - '+tcart[co].name;
		if (tcart[co].size > -1) {
			strBasket += "\n"+tcart[co].sizeval;
		}
		if (tcart[co].colour > -1) {
			strBasket += "\n"+tcart[co].colval;
		}
		
		strBasket += ':'+tcart[co].quan+':&pound;'+top.leftFrame.tdv(tcart[co].price)+':&pound;0.00:&pound;'+top.leftFrame.tdv(tcart[co].price)+':&pound;'+top.leftFrame.tdv(ttot)+':';
		intCount++;
        }
        intCount++;
        document.writeln('<input type="hidden" name="basket" value="'+intCount+':'+strBasket+'">');
        document.writeln('<input type="hidden" name="amount" value="'+top.leftFrame.tdv(total)+'">');


        document.writeln("<TR><TD align=right colspan=4>"+FF2+"Total (including VAT @ 20%)&nbsp;</TD>");
	document.writeln("<TD align=center>=</TD><TD align=right>"+FF2+top.leftFrame.tdv(total)+"</TD>");

	document.writeln("<INPUT TYPE='HIDDEN' NAME='OverallTotal' Value='"+top.leftFrame.tdv(total)+"'>");

        document.writeln("</table><P></CENTER>");
       document.writeln(FF2+"Have you remembered to order your platform? Have you remembered to order your wheels?</B><BR>");
        document.writeln(FF1+"Customer Details:</B><BR>");
	document.writeln(FF2+"<I>Please Note All sections with a * are required to submit an order.</I><P>");
	document.writeln("<TABLE width='400px'>");
	document.writeln("<TR><TD Align='right'>"+FF3+"* Name:<TD>");
	document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='name' value='"+top.leftFrame.get_cname()+"' onChange='top.leftFrame.set_cname()'>");
	document.writeln("<TR><TD Align='right'>"+FF3+"* Address:<TD>");
	document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='address' value='"+top.leftFrame.get_caddr1()+"' onChange='top.leftFrame.set_caddr1()'>");
	document.writeln("<TR><TD Align='right'>"+FF3+"* Town/City:<TD>");
	document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='town' value='"+top.leftFrame.get_caddr2()+"' onChange='top.leftFrame.set_caddr2()'>");
	document.writeln("<TR><TD Align='right'>"+FF3+"County:<TD>");
	document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='county' value='"+top.leftFrame.get_caddr3()+"' onChange='top.leftFrame.set_caddr3()'>");
	document.writeln("<TR><TD Align='right'>"+FF3+"* Postcode:<TD>");
	document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='postcode' value='"+top.leftFrame.get_postcode()+"' onChange='top.leftFrame.set_post()'>");
	document.writeln("<TR><TD><TR><TD Align=right>"+FF3+"Country:<TD>");
	document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='country'>");
	document.writeln("<TR><TD>&nbsp;<TR><TD Align=right>"+FF3+"* Landline Number:<TD>");
	document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='telephone'>");	
	document.writeln("<TR><TD>&nbsp;<TR><TD Align=right>"+FF3+"Mobile:<TD>");
	document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='mobile'>");
	document.writeln("<TR><TD><TR><TD Align=right>"+FF3+"* E-mail:<TD>");
	document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='email'>");
			document.writeln("<TR><TD><TR><TD Align=right>"+FF3+"Delivery Address(if different)<TD>");
	document.writeln("<TR><TD><TR><TD Align=right>"+FF3+"Address:<TD>");
		document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='del_address'>");
			document.writeln("<TR><TD><TR><TD Align=right>"+FF3+"Town/City<TD>");
		document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='del_town'>");
			document.writeln("<TR><TD><TR><TD Align=right>"+FF3+"County<TD>");
		document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='del_county'>");
			document.writeln("<TR><TD><TR><TD Align=right>"+FF3+"Postcode<TD>");
		document.writeln("<INPUT TYPE='TEXT' SIZE=30 NAME='del_postcode'>");
	document.writeln("</TABLE>");

	document.writeln("<P>");

	document.writeln("<CENTER>");
	
	document.writeln("<TABLE border=0 width=500><TR><TD colspan=2>");
	document.writeln(FF2+"Please Select:</TD></TR>");
	document.writeln('<TR><TD><input type="radio" name="delivery" value="1" checked></TD>');
	document.writeln("<TD>"+FF2+"3 Working Day Delivery, <b>FREE</b> for orders &pound;100 and over - mainland UK only. (&#163;20 charge for orders under &pound;100)</TD></TR>");
	document.writeln('<TR><TD><input type="radio" name="delivery" value="2"></TD>');
	document.writeln("<TD>"+FF2+"Next Working Day Delivery &pound;30 - MUST BE ORDERED BEFORE 1PM - CHARGE WILL BE ADDED TO TOTAL</TD></TR>");
	//document.writeln('<TR><TD><input type="radio" name="delivery" value="3"></TD>');
	//document.writeln("<TD>"+FF2+"2-3 Working Day Delivery for orders &pound;50 & under - &pound;15.00 -CHARGE WILL BE ADDED TO TOTAL</TD></TR>");
	document.writeln("</TABLE>");

	document.writeln("<P>");

	// Need buttons in here to submit order, and to clear all orders.
	document.writeln("<INPUT TYPE='SUBMIT' NAME='Status' VALUE='Send Order'>");
	document.writeln("<A href='#' onClick='document.shopform.submit()'></A><P>");
	
	document.writeln("<CENTER>By clicking on submit you agree to the ");
	document.writeln("<A href='termsconditions.html'>Terms & Conditions</A>");
	document.writeln(" layed out by Quickfit Scaffolding Towers.<P>");

	// Fields for formmailer go here. Would usually also include 
	// A recipient line etc.

	document.writeln("<A href='"+top.leftFrame.getUrl()+"' onClick='"+temphead+"'>"+FF2+"Back to previous product page.</a><BR>");
	document.writeln("</CENTER></FORM>");
	document.writeln("</TD></TR></TABLE></BODY></HTML>");
}


