	var $item_desc_ = new Array();
	var $item_number_ = new Array();
	var $amount_ = new Array();
	
	var $quantity_ = new Array();
	
	var $shipping_ = new Array();
	var $shipping2_ = new Array();
	var $handling_ = new Array();
	var $on0_ = new Array();
	var $os0_ = new Array();
	var $on1_ = new Array();
	var $os1_ = new Array();
	
var $worknum, $subtotal, $carriage, $total, $wholedesc;

var count = 0;

$pp_varnum = 0;

$worknum = 0;
$subtotal = 0;
$carriage = 0;
$total = 0;
$wholedesc = " ";

function view_order() {
   mycookies=new Array(20);
   var i=0;
   var startpoint=0;
   
   if (document.cookie == "")
   {
   		$orderdata = ""; 

		printnoitems();
	    printtotals();
   }
   else
{	   
   
   whole_len=document.cookie.length;
   while(whole_len!=startpoint && i< 20)
   {
     if ((temlen=document.cookie.indexOf(";",startpoint))!=-1)
     {
	mycookies[i]=document.cookie.substring(startpoint,temlen);
	i++;
	startpoint=temlen+1
     }
     else if (startpoint != whole_len)
     {
        mycookies[i]=document.cookie.substring(startpoint,whole_len);
        i++;
        startpoint=whole_len;
     }
   }
    for (j=0;j<i;j++)
     {
//filter out cookies that are not used by YOES
	if((mycookies[j].substring(0,2)=="YE")||(mycookies[j].substring(0,3)==" YE"))
	   getCookie(mycookies[j]);
     }
}     
}


function getCookie (acookie) {
    clen = acookie.length;
    //get rid of the "YE" at the beginning, thus start at 4
    
    data= acookie.substring(3,clen);
    
    
   	items = data.split("endofitem");
   			
	// how many items? store in count
		
	start = 0;
	end = data.length - 8;
	count = 0;
		
	while (items[count] != "")
	{
			count++;
	}
		
	if (count > 0)
	{
		$orderdata = ""; 
  		for (j=0; j<clen; j++)
		{
			$char = data.substr(j,1);
			if ($char == "+")
			{
				if (j == 0)
				{
					$char = "";
				}
				else
				{
					$char = "break";
				}
			}
			$orderdata = $orderdata + $char;
		} 
		$orderdata = $orderdata + "break";
		
	} 
	
	
// 200g is the weight of cardboard box	
	
	
	$orderweight = 200;
	$subtotal = 0;
	$carriage = 0;
    $itemcount = count - 1;
	
	for (i=0; i<count; i++)
	{
		$pp_varnum = i + 1;
	
		newdata = items[i].split("+");
		$quantity = newdata[0];
		$description = newdata[1];
		$price = newdata[2];


// add up carriage according to weight

	if ($description == "Sweet Chilli Sauce 375ml")
	{
		$orderweight = $orderweight + (760 * $quantity);
	}
	if ($description == "Hot Chilli Sauce 375ml")
	{
		$orderweight = $orderweight + (760 * $quantity);
	}
	if ($description == "Chilli Sauce with Garlic 375ml")
	{
		$orderweight = $orderweight + (760 * $quantity);
	}
	if ($description == "Sweet Chilli Sauce 150ml")
	{
		$orderweight = $orderweight + (380 * $quantity);
	}
	if ($description == "Hot Chilli Sauce 150ml")
	{
		$orderweight = $orderweight + (380 * $quantity);
	}
	if ($description == "Chilli Sauce with Garlic 150ml")
	{
		$orderweight = $orderweight + (380 * $quantity);
	}


	if ($description == "Satay Sauce 250ml")
	{
		$orderweight = $orderweight + (534.6 * $quantity);
	}
	if ($description == "Hot Bean Sauce 250ml")
	{
		$orderweight = $orderweight + (496.6 * $quantity);
	}
	if ($description == "Hoi Sin Sauce 250ml")
	{
		$orderweight = $orderweight + (541.6 * $quantity);
	}
	if ($description == "Plum Sauce 250ml")
	{
		$orderweight = $orderweight + (546.6 * $quantity);
	}
	if ($description == "Szechuan Kung-Po Sauce 250ml")
	{
		$orderweight = $orderweight + (496.6 * $quantity);
	}
	if ($description == "Sweet and Sour Sauce 250ml")
	{
		$orderweight = $orderweight + (486.6 * $quantity);
	}
	if ($description == "Black Bean Sauce 250ml")
	{
		$orderweight = $orderweight + (481.6 * $quantity);
	}
	if ($description == "Sambal Oelek Sauce 250ml")
	{
		$orderweight = $orderweight + (496.6 * $quantity);
	}
	if ($description == "Singapore Chilli Sauce 250ml")
	{
		$orderweight = $orderweight + (481.6 * $quantity);
	}



	if ($description == "Laksa Paste 185g Jar")
	{
		$orderweight = $orderweight + (359.3 * $quantity);
	}
	if ($description == "Mee Siam Paste 190g Jar")
	{
		$orderweight = $orderweight + (364.3 * $quantity);
	}
	if ($description == "Nasi Goreng Paste 190g Jar")
	{
		$orderweight = $orderweight + (364.3 * $quantity);
	}


	if ($description == "Dark Soy Sauce 150ml")
	{
		$orderweight = $orderweight + (360 * $quantity);
	}
	if ($description == "Light Soy Sauce 150ml")
	{
		$orderweight = $orderweight + (360 * $quantity);
	}
	if ($description == "Oyster Sauce 150ml")
	{
		$orderweight = $orderweight + (360 * $quantity);
	}


	if ($description == "Rice Vermicelli 375g")
	{
		$orderweight = $orderweight + (375 * $quantity);
	}
	if ($description == "Ezy Cook Noodles 400g")
	{
		$orderweight = $orderweight + (400 * $quantity);
	}
	if ($description == "Ezy Cook Noodles Fat Free 400g")
	{
		$orderweight = $orderweight + (400 * $quantity);
	}



	if ($description == "Singapore Hot Curry Sauce")
	{
		$orderweight = $orderweight + (410 * $quantity);
	}
	if ($description == "Malaysian Mild Curry Sauce")
	{
		$orderweight = $orderweight + (410 * $quantity);
	}
	if ($description == "Malaysian Mild Curry Powder")
	{
		$orderweight = $orderweight + (50 * $quantity);
	}













// start paypal code	
	
		
		$item_desc_[$pp_varnum] = $description;
		$item_number_[$pp_varnum] = $pp_varnum;
		$quantity_[$pp_varnum] = $quantity;
		$amount_[$pp_varnum] = $price;
		$shipping_[$pp_varnum] = 0;
		$shipping2_[$pp_varnum] = 0;
		$handling_[$pp_varnum] = 0;


		$on0_[$pp_varnum] = " ";

		$os0_[$pp_varnum] = " ";
		$on1_[$pp_varnum] = " ";
		$os1_[$pp_varnum] = " ";
	
	
// end paypal code	



		$subtotal = $subtotal + ($quantity * $price);
		
		
		$wholedesc = $wholedesc + $description + " X" + $quantity + " ";
				
		if (i < $itemcount)
		{
		    $wholedesc = $wholedesc + " + ";
		}
		
		printcontent();
	}
	
		if ($orderweight < 1000)
		{
			$carriage = 3.5;
		}
		else
		{
			if ($orderweight < 2000)
			{
				$carriage = 4.2;
			}
			else
			{
				if ($orderweight < 4000)
				{
					$carriage = 6.85;
				}
				else
				{
					if ($orderweight < 6000)
					{
						$carriage = 9.3;
					}
					else
					{
						if ($orderweight < 8000)
						{
							$carriage = 11.4;
						}
						else
						{
							if ($orderweight < 10000)
							{
								$carriage = 12.24;
							}
							else
							{
								if ($orderweight < 20000)
								{
									$carriage = 14.26;
								}
								else
								{
									if ($orderweight < 30000)
									{
										$carriage = 16.50;
									}
									else
									{
										if ($orderweight < 40000)
										{
											$carriage = 19.50;
										}	
									}
								}
							}
						}
					}
				}
			}
		}


	
	printtotals();
}

function printnoitems()
{
	document.write("<table width=586><tr>");
	document.write("<td width='10'>&nbsp;</td>");
	document.write("<td width='20'  valign=middle>&nbsp;</td>");
	document.write("<td width='370' valign=middle >No items placed on the order so far</td>");
	document.write("<td width='200'  valign=middle>&nbsp;</td>");
	document.write("</tr></table>");
}

function printcontent()
{
	document.write("<table width=586><tr>");
	document.write("<td width='10'>&nbsp;</td>");
	document.write("<td width='20'  valign=middle>&nbsp;</td>");
	document.write("<td width='370' valign=middle >"+$description+"</td>");
		
// explicitly add decimal places for printing 
	
	$string_price = $price.toString();
	$decimal = ".";
	if ($string_price.indexOf($decimal) == -1)
	{
		$string_price = $string_price + ".00";
	}
	else
	{
		$stringlength = $string_price.length;
		$decdotplace = $stringlength - 2;
		if ($string_price.indexOf($decimal,$decdotplace) != -1)
		{
			$string_price = $string_price + "0";
		}
		
	}	
	
	
	document.write("<td width='100'  valign=middle>"+$string_price+"</td>");
	document.write("<td width='100'  valign=middle><input type='text' name='ORDQTY' onKeyUp=\"changeq(this.value,\'"+$description+"\')\" size='10' value="+$quantity+" maxlength='10'></td>");
	document.write("</tr></table>");
}

function printtotals()
{




// round to 2 decimal places


	$worknum = $subtotal * 100;
	$subtotal = (Math.round($worknum)) / 100;
	
	$worknum = $carriage * 100;
	$carriage = (Math.round($worknum)) / 100;
	
	
	$total = 0;
	$total =  $carriage + $subtotal;
	
	$worknum = $total * 100;
	$total = (Math.round($worknum)) / 100;
	
	
// explicitly convert to string and add zeros to display as monetary values
	
	$string_subtotal = $subtotal.toString();
	$decimal = ".";
	if ($string_subtotal.indexOf($decimal) == -1)
	{
		$string_subtotal = $string_subtotal + ".00";
	}
	else
	{
		$stringlength = $string_subtotal.length;
		$decdotplace = $stringlength - 2;
		if ($string_subtotal.indexOf($decimal,$decdotplace) != -1)
		{
			$string_subtotal = $string_subtotal + "0";
		}
		
	}
	
	$string_carriage = $carriage.toString();
	$decimal = ".";
	if ($string_carriage.indexOf($decimal) == -1)
	{
		$string_carriage = $string_carriage + ".00";
	}
	else
	{
		$stringlength = $string_carriage.length;
		$decdotplace = $stringlength - 2;
		if ($string_carriage.indexOf($decimal,$decdotplace) != -1)
		{
			$string_carriage = $string_carriage + "0";
		}
		
	}	
	
	$string_total = $total.toString();
	$decimal = ".";
	if ($string_total.indexOf($decimal) == -1)
	{
		$string_total = $string_total + ".00";
	}
	else
	{
		$stringlength = $string_total.length;
		$decdotplace = $stringlength - 2;
		if ($string_total.indexOf($decimal,$decdotplace) != -1)
		{
			$string_total = $string_total + "0";
		}
		
	}
	
	
	// create unique reference number
	
	$today = new Date();
	var $refno;
	$refno = "YEO" + $today.getMonth() + $today.getDate() + $today.getHours()+ $today.getMinutes()+ $today.getSeconds();	
	
	
	document.write("</table>");



	document.write("<br>&nbsp;<br><table width='586' border='0' cellspacing='0' cellpadding='0'>");
	document.write("<tr><td>");
	
	
	
	document.write("<table width='300' border='0' cellspacing='0' cellpadding='0'>");
	
	document.write("<tr>");
	document.write("<TD width=30>&nbsp;</TD>");
	document.write("<td valign='bottom'> <font face='Arial, Helvetica, sans-serif' size='2' color='#333333'>");
	document.write("<td width='95'><font face='Arial, Helvetica, sans-serif' size='2'>Sub Total &pound;</font></td>");
	document.write("<td width='95'><div align='right'><font face='Arial, Helvetica, sans-serif' size='2'>"+$string_subtotal+"</font></div></td>");
	document.write("<td >&nbsp;</td></tr>");
	document.write("<tr>");
 	document.write("<TD width=30>&nbsp;</TD>");
	document.write("<td valign='bottom'> <font face='Arial, Helvetica, sans-serif' size='2' color='#333333'>");
	document.write("<td width='95'><font face='Arial, Helvetica, sans-serif' size='2'>Carriage &pound;</font></td>");
	document.write("<td width='95'><div align='right'><font face='Arial, Helvetica, sans-serif' size='2'>"+$string_carriage+"</font></div></td>");
	document.write("<td >&nbsp;</td></tr>");
   
	document.write("<tr>");
	document.write("<TD width=30>&nbsp;</TD>");
	document.write("<td valign='bottom'>&nbsp;</td>");
	document.write("<td colspan='2' height='1' bgcolor='#FE0000'>&nbsp;</td>");
	document.write("<td height='1'>&nbsp;</td></tr>");
	
	document.write("<tr>");
	document.write("<TD width=30>&nbsp;</TD>");
	document.write("<td valign='bottom'> <font face='Arial, Helvetica, sans-serif' size='2' color='#333333'>");
	document.write("<td width='95'><font face='Arial, Helvetica, sans-serif' size='2'><b>TOTAL &pound;</b></font></td>");
	document.write("<td width='95'><div align='right'><font face='Arial, Helvetica, sans-serif' size='2'>"+$string_total+"</font></div></td>");
	document.write("<td >&nbsp;</td></tr>");
	document.write("<tr>");
	document.write("<TD width=30>&nbsp;</TD>");
	document.write("<td valign='bottom'>&nbsp;</td>");
	document.write("<td colspan='2'  bgcolor='#FE0000'>&nbsp;</td>");
	document.write("<td height='1'>&nbsp;</td></tr>");
	
	





// paypal start code 
	
document.write("<form action='https://www.paypal.com/cgi-bin/webscr' method='post'>");
document.write("<input type='hidden' name='cmd' value='_cart'>");
document.write("<input type='hidden' name='upload' value='1'>");
document.write("<input type='hidden' name='business' value='info@d-ga.com'>");
document.write("<input type='hidden' name='currency_code' value='GBP'>");

// one set for each item in the basket

	for (i=0; i<count; i++)	{
		$pp_varnum = i + 1;

		$item_name = "item_name_" + $pp_varnum;
		document.write("<input type='hidden' name='"+$item_name+"' value='"+$item_desc_[$pp_varnum]+"'>");

		
		$item_number = "item_number_" + $pp_varnum;
		document.write("<input type='hidden' name='"+$item_number+"' value=' '>");
	
		$quantity = "quantity_" + $pp_varnum;
		document.write("<input type='hidden' name='"+$quantity+"' value='"+$quantity_[$pp_varnum]+"'>");
	
		$amount = "amount_" + $pp_varnum;
		document.write("<input type='hidden' name='"+$amount+"' value='"+$amount_[$pp_varnum]+"'>");
	
		$shipping2 = "shipping2_" + $pp_varnum;
		document.write("<input type='hidden' name='"+$shipping2+"' value='0.00'>");
		
		$handling = "handling_" + $pp_varnum;
		document.write("<input type='hidden' name='"+$handling+"' value='0.00'>");
		
		$on0 = "on0_" + $pp_varnum;
		document.write("<input type='hidden' name='"+$on0+"' value='"+$on0_[$pp_varnum]+"'>");
		
		$os0 = "os0_" + $pp_varnum;
		document.write("<input type='hidden' name='"+$os0+"' value=' '>");
		
		$on1 = "on1_" + $pp_varnum;
		document.write("<input type='hidden' name='"+$on1+"' value=' '>");
		
		$os1 = "os1_" + $pp_varnum;
		document.write("<input type='hidden' name='"+$os1+"' value=' '>");

	
	}

		$shipping = "shipping_" + $pp_varnum;
		document.write("<input type='hidden' name='"+$shipping+"' value='"+$carriage+"'>");
	
	
	
	
	document.write("<tr>");
	document.write("<TD width=30>&nbsp;</TD>");
	document.write("<td valign='bottom'>&nbsp;</td>");
	document.write("<td colspan='2''>&nbsp;</td>");
	document.write("<td height='1'>&nbsp;</td></tr>");
	
	document.write("</table>");


	document.write("<table><tr>");
	document.write("<TD width=55>&nbsp;</TD>");
	document.write("<td valign='bottom'>&nbsp;</td>");
	document.write("<td colspan='2''><input type='image' src='images/checkout.gif' name='submit' alt='Make payments with PayPal - its fast, free and secure!'></td>");
	document.write("<td height='1'>&nbsp;</td></tr></table>");
document.write("</form>");
	

// paypal end code
}


