// JavaScript Document
//litems = new Array('MOBILE SHELL SHAPE LOUDSPEAKER Red','MOBILE SHELL SHAPE LOUDSPEAKER Yellow','MOBILE SHELL SHAPE LOUDSPEAKER Blue','MOBILE SHELL SHAPE LOUDSPEAKER Green', 'Pack OFFER with Mobiles Shell Shape Loudspeakers Blue', 'Pack OFFER with Mobiles Shell Shape Loudspeakers Yellow', 'Pack OFFER with Mobiles Shell Shape Loudspeakers Red', 'Pack OFFER with Mobiles Shell Shape Loudspeakers Green','amplifier NADC325');
//lprices = new Array(464, 464, 464, 464, 1499, 1499, 1499, 1499,520);
litems = new Array('MOBILE SHELL SHAPE LOUDSPEAKER Red','MOBILE SHELL SHAPE LOUDSPEAKER Yellow','MOBILE SHELL SHAPE LOUDSPEAKER Blue','MOBILE SHELL SHAPE LOUDSPEAKER Green');
lprices = new Array(299, 299, 299, 299);

var dataCount=0;//.....no recorded data

var dataMax=25; //.........entries

var Cookies; var strCookie='';
var tt=0; var i;
var exp = new Date(); 
var Cdays = 30; //........days

exp.setTime(exp.getTime() + (Cdays*24*60*60*1000));
var i; var item; var num=0; var items; var tot; var listitems = "";var listitems2 = "";
function write_order() { //------------------------------- 

  if (document.cookie !='') {   //....search cookie, extract the list of items 
  
      Cookies = document.cookie.split('; ');
      for (i=0; i<Cookies.length; i++) {
            if ('ckItem' == Cookies[i].split('=')[0]) {
               strCookie = Cookies[i].split('=')[1];
               strCookie = unescape(strCookie);}}
  }
  if (strCookie !='') {   //...........extract each item
      tot = 0;
      items = strCookie.split(':::');  
      dataCount = items.length; //alert(dataCount);
	  
      for (i=1; i<items.length; i++) {
            k = parseInt(items[i]);
			listitems = listitems+litems[k]+"\n";
			listitems2 = listitems2+litems[k]+"<br>";
            tot = parseFloat(tot + lprices[k]);
            print_item(i, litems[k], lprices[k], tot);}
document.write("<tr> <TD COLSPAN=3 align=right>Total = " + tot + " Euros</td></tr>" );}
else {document.write("</tr>");}
}
function print_item (count, item, price, tot) { //-------------------------------  

  if (tt == 0) {
      tt=1; color = "bgcolor='blue'";}
  else {
      tt=0; color = "bgcolor='blue'";}
document.write("<tr " + color + ">");
document.write("<td width=5% align=left><small>" + count + "</td>");
document.write("<td width=75% align=left>" + item + "</td>");
document.write("<td align=left><small>" + price +" euros" + "</td>");
document.write("</tr>");
}
function delete_Cookie () { //-------------------------------  
  var exp = new Date();  
  exp.setTime (exp.getTime() - 1);  
  strCookie = ''; 
  document.cookie ="ckItem=" + strCookie + ";expires=" + exp.toGMTString() + ";";
dataCount = 0;
alert('Your shopping cart is currently empty');
}

function print_order() { //------------- 

   var bV = parseInt(navigator.appVersion);
   if (bV >= 4) window.print();
}
function initialize() { //--delete all items

   var exp = new Date();  
   exp.setTime (exp.getTime() - 1);  
   strCookie = ''; 
   document.cookie ="ckItem=" + strCookie + ";expires=" + exp.toGMTString() + ";";
alert('Your shopping cart is currently empty');
}
function send_order() { //--------------

   //use the (submit) button
   
   alert('Sorry...\nfunction not implemented...');
}
function write_date() {
   document.write(new Date());
}
function go_back(url) { //--------------
  window.location=url;
}
