//Template 5: Display picture of product on catalog, 
//and the picture will also appear at the product 
//detailed info page. Customizable shipping fees & thankyou page.
//LAYOUT DEFINITION = ISAAC


function makeArray(n){

      this.length = n;

      for(var i = 1; i <= n; i++){

            this[i] = 0;

      }

      return this;

   }





   var orderNum = 0;                                             

   var order = new makeArray(100);                      

   var indexNum = 0;

   var count;

   var formSave;





  function currency(money){

     money = money + ""           

     var monLen = money.length;

     var digPos = money.indexOf(".");

     if(digPos == -1 & monLen < 1){

       money = money.substring(0,digPos+ 1) + "00";
    } else if(digPos == -1 & monLen > 0){
       return money;

    }else{

              cents = money.substring(digPos + 1, monLen + 1);

              if(cents.length == 1){

                  money = money + "0";

             }else if(cents.length > 2){

                      roundVal = cents.charAt(2);

                      if(roundVal  >= 5){

                         money = parseFloat(money) + .01;

                         money = money + "";

                         money = money.substring(0,digPos + 3)

                      }else{

                          money = money.substring(0,digPos + 3)

                      }

               }

      }

     return money;

   }


//////////////////////      1


function Currency(money)
{
	//convert an value into a string
	money =  parseFloat(money);
	money += 0.005;
	money +=  "";           
	var monLen = money.length;
	var digPos = money.indexOf(".");
	if(digPos == -1) {
		if (money <=0) {
			money ="0.00";
		} else {
			money += ".00";
		}
		return money;
	} else {
		if (digPos + 3 > monLen) {
			money += "0";
		} else if (digPos + 3 != monLen) {
			money = money.substring(0, digPos+3);
		} 
		return money;
	}     
}


//////////////////////////////////






function Addword(theForm)
{
	var cWin= parent.frames['catalog'].document;
	var itemName = theForm.itemName.value;
	var basePrice = parseFloat(theForm.basePrice.value);
	var totalPrice = basePrice;
	var totalSubField = parseInt(theForm.totalSubField.value);
	
	
	//now the subfield
	var i;
	var tmpStr;
	for (i=0;i<totalSubField;i++) {
		tmpStr = GetSelection(theForm, i);
		totalPrice += parseFloat(tmpStr);
		//now we need to append the subfield into the item name
		var n= tmpStr.indexOf("::");
		n+=2;
		itemName += ", " + tmpStr.substr(n);
			
	}
	var str="Add this item?\n"+itemName + "\n";
	var unitPrice= totalPrice;
	str += "Unit Price $" + Currency(totalPrice ) +"\n";
	var qty=parseInt(theForm.Qty.value);
	str += "Quantity " + qty +"\n";
	str += "Total Price:$"+Currency(totalPrice*qty);
	if (confirm(str)) {
		AddRecord(itemName, unitPrice, qty);
	} else {
		alert("This item was not placed in your shopping cart.");
		return;
	}

}


function MakeArray(n) {
      this.length = n;
      for(var i = 0; i < n; i++){
            this[i] = 0;
      }
      return this;
}


function RECORD(n)
{
	this.length = n;
	this.curLength = 0;
	this.itemName=new MakeArray(n);
	this.price=new MakeArray(n);
	this.quantity=new MakeArray(n);
	return this;
}



//we temp. make the user able to put up to a max of 250 orderRecords per store
var orderRecord = new RECORD(20000);


function AddRecord(itemName, unitPrice, qty)
{
	var i;
	for (i=0;i<orderRecord.curLength;i++) {
		if (orderRecord.itemName[i] == itemName) {
			orderRecord.quantity[i] += qty;
			return;
		}
	}

	if (orderRecord.curLength < orderRecord.length) {
		orderRecord.itemName[orderRecord.curLength] =itemName;
		orderRecord.quantity[orderRecord.curLength] = qty;
		orderRecord.price[orderRecord.curLength] = unitPrice;
		orderRecord.curLength++;
	} else {
		alert("This order was not placed in your shopping cart because your shopping cart has fill up.\nPlease check out to empty it before continue with next order");
	}
}






//////////////////  2


function GetSelection(theForm, fieldNum)
{
	var subField = eval("theForm.subfield"+fieldNum);
	for (var i = 0; i < subField.length; i++) {
		   if (subField.options[i].selected) {
				return subField.options[i].value;
			}
	}
	return 0;
}




/////////////////////3





function CalUnitPrice(theForm)
{

	var totalPrice = parseFloat(theForm.basePrice.value);
	var totalSubField = parseInt(theForm.totalSubField.value);


	//now the subfield
	var i;
	for (i=0;i<totalSubField;i++) {
		var tmpStr = GetSelection(theForm, i);
		totalPrice += parseFloat(tmpStr);
	}
	theForm.unit.value = Currency(totalPrice) ;


parent.frames['catalog'].document.isaiah.subTotal.value =Currency(totalPrice) ;



}



///////////////////////






   function showProd(form){

       var iter = 0;

       var match = false;

       var oldlen = 1;

       count = 0;

       sWin = parent.frames['catalog'].document

       prodName = parent.frames['toc'].document.searcher.lookup.value;

       sWin.open();

       sWin.write("<HTML><HEAD><TITLE>"+  prodName + " </TITLE></HEAD>");

       sWin.write("<BODY  bgcolor=#ffffff  text=#000000>");

       for (var i = 1; i <= prodID.length; i++){

             //alert(theProd + " " + prodID[i].name.toUpperCase());

             if(prodName.toUpperCase() == prodID[i].name.toUpperCase()){

                indexNum = i;

                prodID[i].show(sWin,i);

                match = true;

             }

       }








       if(!match){
            pTotal = new makeArray(prodID.length);
            for (var i = 1; i <= prodID.length; i++){
                 var pSearch = prodName.toUpperCase();
                 var pInventory = prodID[i].name.toUpperCase();
                 for(var x = 1; x <= pSearch.length; x++){
                     if(pSearch.substring(0,x) == pInventory.substring(0,x)){


                         pTotal[i] = pSearch.substring(0,x);
                     }
                  }
              };

oldlen=0;
              for (var i = 1; i <= prodID.length; i++){
                  // alert(pTotal[i] + " " + i);
                   if(pTotal[i] != "0"){ prodID[i].show(sWin,i);
                       if(pTotal[i].length >= oldlen){
                            oldlen = 1;// pTotal[i].length;
                            olditer = iter;
                            var iter = i;
                        }
                    }
                 }
                if (oldlen!=1){

sWin.write("<center><font face=arial size=+1 color=blue><b>Your Search Got 0 Result!<br>Please try again.</b></font></center>");

}

      }
           sWin.write("</BODY></HTML>");
           sWin.close();
   }






    function searchType(form){

         count = 0;

         prodTypeInfo = form;

         var match = false;

         tWin = parent.frames[2].document

         tWin.open();

        tWin.write("<HTML><HEAD><TITLE>"+  prodTypeInfo + " </TITLE></HEAD>");



        tWin.write("<BODY  background=back_browse.gif  text=#000000> ");

        for (var i = 1; i <= prodID.length; i++){

             if(prodTypeInfo == prodID[i].type){

                indexNum = i;

                prodID[i].show(tWin,i);

                match = true;

              }

       }

       tWin.write("</BODY></HTML>");

       tWin.close();

   }



    function product (name,description,image,price,type,link,url){

        this.name = name;

        this.description = description;
        this.image = image

        this.price = price;

        this.type = type;

        this.show = show;
        if(link != ""){
          this.link = "<center><TABLE BORDER=0><TR><TD><A HREF='" + url + "'><Font face=arial size=-2>" + link + "</font></A></TD></TR></TABLE></center>";
        }else{
          this.link = "";
        }

    }

    

    function show(w,prodIndexNum){

         w.write("</CENTER><center><TABLE BORDER = 0 WIDTH=300><TR><TD BGCOLOR=#d5d5ff><FONT FACE = 'arial' color=blue><b>"  + this.name + "</b></FONT></TD></TR></TABLE></center>");

 //      w.write("</CENTER><center><form><FONT FACE = 'arial' color=blue><b><input type=text size=25 name=s value='"  + this.name + "'></b></FONT></form></center>");



            if(this.image.length > 1){

               w.write("<CENTER><TABLE BORDER=0 COLS=2 WIDTH=300 BGCOLOR=#FFCC00 ><TR BGCOLOR=#00CC00><TD><FONT FACE = 'Arial' SIZE = 2 >Image</FONT></TD><TD><FONT FACE = 'Arial' SIZE = 2 >Description</FONT></TD></TR><TR><TD><IMG SRC='" + this.image + "'></TD>");

 w.write("<TD><FONT FACE = 'Arial' SIZE = 2 >" + this.description + "</TD></TR></Table></CENTER>");

             }
           if(this.link != ""){
              w.write(this.link);
           }




           w.write("<FORM NAME=isaiah>");

            //alert(prodIndexNum);

           orderProd(this,w,prodIndexNum);

           w.write("</FORM><HR SIZE=1 NOSHADE WIDTH=90%><br>");

          // w.write("&nbsp;&nbsp;&nbsp;&nbsp; <INPUT TYPE = 'button' VALUE = 'Go Back' onClick = history.go(-1)>");
          


    }



   function orderProd(obj,win,index){


     win.write("<CENTER><TABLE BORDER=0 COLS=2 WIDTH=300 BGCOLOR=#CCCCCC><TR><TD><FONT FACE = 'arial' size=-1><b>Price Each: $</b>" + obj.price+"</font></CENTER>");

     win.write("&nbsp;&nbsp;<FONT FACE = 'arial' size=-1><b>Enter Quantity:</b></font>  " + "<INPUT TYPE = 'text' SIZE = 3 NAME = 'q' VALUE = '1' onBlur = parent.reTotal("+ parent.count + "," +  obj.price + ") onFocus = parent.reTotal("+ parent.count + "," +  obj.price + ")><br>");



     win.write("&nbsp;&nbsp;<FONT FACE = 'arial' size=-1><b>Total:" + " $</b></font><INPUT TYPE = 'text' SIZE=7 NAME= subTotal VALUE =" + obj.price + ">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;" + "<INPUT TYPE ='button' VALUE = 'SubTotal' onClick = parent.reTotal("+ parent.count + "," +  obj.price + ")></TR></TABLE></CENTER>");



     win.write("<CENTER><IMG SRC=pickit.gif ALIGN=TEXTTOP><A HREF=javascript:parent.add(" + parent.count + "," + index + ")><IMG SRC=addtocart.gif border=0></A>")


   count++;

 }



    function add(id, oIndex){

       var theForm =  parent.frames[2].document.forms[id];

        productName = prodID[oIndex].name;

        totalSum =parent.frames[2].document.forms[id].subTotal.value;

        totalQuantity =  parent.frames[2].document.forms[id].q.value;

     if(totalQuantity == 0){

         alert("You entered a quantity of 0!\n We cannot process this order");


         parent.frames[2].document.forms[id].q.value = 1;

         reTotal(id,prodID[oIndex].price);

     }else{

      if( confirm("You are adding " + totalQuantity + " order/s of " + productName + " \n Subtotal: " + totalSum + " to your shopping cart.")){



          store(oIndex,totalSum,totalQuantity);

        }else{

           alert("\n\nThis order was not placed in your shopping cart.");

        }

    }

   }



      function store(o,ts,tq){

            orderNum++;

           order[orderNum] = new cartGoods(o,ts,tq);

           showTotal = 0;

           for(var i = 1; i <= orderNum;i++){

                 showTotal += parseFloat(order[i].totSum);                

            }

             parent.frames[1].document.forms[0].runningTotal.value = currency(showTotal);



     }





//////////////






function Addmore(theForm)
{
	var cWin= parent.frames['catalog'].document;
	var itemName = theForm.itemName.value;
	var basePrice = parseFloat(theForm.basePrice.value);
	var totalPrice = basePrice;
	var totalSubField = parseInt(theForm.totalSubField.value);
	
	
	//now the subfield
	var i;
	var tmpStr;
	for (i=0;i<totalSubField;i++) {
		tmpStr = GetSelection(theForm, i);
		totalPrice += parseFloat(tmpStr);
		//now we need to append the subfield into the item name
		var n= tmpStr.indexOf("::");
		n+=2;
		itemName += ", " + tmpStr.substr(n);
			
	}
	var str="Add this item?\n"+itemName + "\n";
	var unitPrice= totalPrice;
	str += "Unit Price $" + Currency(totalPrice ) +"\n";
	var qty=parseInt(theForm.Qty.value);
	str += "Quantity " + qty +"\n";
	str += "Total Price:$"+Currency(totalPrice*qty);
	if (confirm(str)) {


		AddRecord(itemName, unitPrice, qty);
             


	} else {
		alert("This item was not placed in your shopping cart.");
		return;
	}
	//ViewCart();
	//PrintCartTotal();
}







    function cartGoods(Indx, totSum, totQ){

         this.Indx = prodID[Indx].name;

         this.totSum = totSum;

         this.totQ = totQ;

   }



    function view(){
          vWin = parent.frames[2].document;
           vWin.open();
         vWin.write("<HTML><BODY BGCOLOR=White text=Black><CENTER>");
       if(orderNum != 0){
         vWin.write("<IMG SRC=updatebasket.gif><FONT COLOR=blue  Size=5><b>" + "Your Shopping Basket Contents</b></FONT><P>");
         vWin.write("<FORM><TABLE BORDER=0>");
         vWin.write("<TD COLSPAN=1 BGCOLOR=#ffcc00><FONT face=arial COLOR=WindowText>Quantity</FONT></TD>");
         vWin.write("<TD COLSPAN=1 BGCOLOR=#ffcc00><FONT face=arial COLOR=WindowText>Product</FONT></TD>");
         vWin.write("<TD COLSPAN=1 BGCOLOR=#ffcc00><FONT face=arial COLOR=WindowText>Price</FONT></TD>");
         vWin.write("<TD COLSPAN=1 BGCOLOR=#ffcc00><FONT face='Arial' size=2 COLOR=WindowText></FONT></TD><TR>");
         for(var i = 1; i <= orderNum; i++){
         vWin.write("<TD COLSPAN=1 align=center BGCOLOR=#D5D5FF><FONT COLOR=WindowText face='Arial' Size=3>"+order[i].totQ+"</FONT></TD>");
         vWin.write("<TD COLSPAN=1 BGCOLOR=#D5D5FF><FONT COLOR=WindowText face='Arial' Size=3>"+order[i].Indx+"</FONT></TD>");
         vWin.write("<TD COLSPAN=1 BGCOLOR=#D5D5FF><FONT COLOR=WindowText face='Arial' Size=3>"+order[i].totSum+"</FONT></TD>");
         vWin.write("<TD VAlign=TOP align=center BGCOLOR=white><input type='checkbox' Name=checkbox"+i+" onclick=parent.remove("+i+")></Font>");
         vWin.write("<FONT COLOR=WindowText face='Arial' Size=1><b>Check here to remove item</b></FONT></TD></TR>");
         }
      


// vWin.write("</TABLE></FONT></FORM><br><br><A HREF=javascript:history.back()><IMG SRC=continueShop.gif border=0></A>");

  vWin.write("</TABLE></FONT></FORM><br><TABLE BORDER=0 COLS=4 WIDTH=100% ><TR><TD><A HREF = javascript:parent.view(); return true;><IMG BORDER=0 SRC=updatebasket.gif ></A><font size=-2 face=arial>View Basket</font></TD><TD><A HREF = javascript:parent.checkOut(); return true;><IMG BORDER=0 SRC=checkout.gif></A><font size=-2 face=arial>Check Out</font></TD><TD><A HREF=catalog.htm><img SRC=Home.gif border=0></A> <font size=-2 face=arial>Store Front</font></TD><TD><A HREF=javascript:history.back(-1)><font face=arial size=-2><img src=exit.gif border=0></font></A><font size=-2 Face=arial>Continue To Shop</font></TD></TR></TABLE>");

      }else{
            vWin.write("<FONT SIZE = 5 FACE = 'arial'><br>" + "<br><IMG SRC=noitem.gif border=0></FONT>");
            if(navigator.appName.indexOf("Netscape") != -1){
               vWin.write("<FORM><INPUT TYPE='button' VALUE='Back to Order Form' onclick='history.go(-1)'>");
            }
            }
            vWin.write("</TABLE></FONT></FORM></BODY></HTML>");
            vWin.close();
    }

    function remove(item){
       var newSum = 0;
       for(var i = item+1; i <= orderNum; i++){
          if(item == orderNum){
                   order[i].Indx = "";
                   order[i].totSum = 0 ;
                   order[i].totQ = "";
                   break;
          }else{
                   order[i-1].Indx = order[i].Indx;
                   order[i-1].totSum = order[i].totSum;
                   order[i-1].totQ = order[i].totQ;
          }
      }
      orderNum--;
      for(var i = 1; i <= orderNum;i++){
          newSum += parseFloat(order[i].totSum);
      }
      parent.frames[1].document.forms[0].runningTotal.value = currency(newSum);

      view();

     }
    function checkOut(){
        if(orderNum != 0){
        cWin = parent.frames[2].document;
        cWin.open();
        cWin.write("<HTML><BODY background=back_invoice.gif text=Black><Center>");
        cWin.write("<center><IMG SRC=checkout.gif><Font COLOR=Blue Size=5><b>Check Out At Cash Register</b></Font></center><br><Table border=0><tr>");
         grandTotal = 0;
        // cWin.write("<FORM NAME = 'orderfor'>");
         cWin.write("<TD COLSPAN=1 BGCOLOR=#ffcc00><FONT face=arial COLOR=WindowText>Quantity</FONT></TD>");
         cWin.write("<TD COLSPAN=1 BGCOLOR=#ffcc00><FONT face=arial COLOR=WindowText>Product</FONT></TD>");
         cWin.write("<TD COLSPAN=1 BGCOLOR=#ffcc00><FONT face=arial COLOR=WindowText>Price</FONT></TD>");
         cWin.write("<TD COLSPAN=1 BGCOLOR=#ffcc00><FONT face=arial COLOR=WindowText>Total Price</FONT></TD></TR>");
         for(var i = 1; i <= orderNum; i++){
         cWin.write("<TD COLSPAN=1 align=center BGCOLOR=#d5d5ff><FONT COLOR=WindowText face='Arial' Size=2>"+order[i].totQ+"</FONT></TD>");
         cWin.write("<TD COLSPAN=1 align=center BGCOLOR=#d5d5ff><FONT COLOR=WindowText face='Arial' Size=2>"+order[i].Indx+"</FONT></TD>");
         cWin.write("<TD COLSPAN=1 align=center BGCOLOR=#d5d5ff><FONT COLOR=WindowText face='Arial' Size=2>"+parent.currency(order[i].totSum/order[i].totQ)+"</FONT></TD>");
         cWin.write("<TD COLSPAN=1 align=center BGCOLOR=#d5d5ff><FONT COLOR=WindowText face='Arial' Size=2>"+parent.currency(order[i].totSum)+"</FONT></TD></TR>");
                   grandTotal += parseFloat(order[i].totSum); 
         }
 

// EDIT SALES TAX IN THE LINE BELOW. 8.25% SALES TAX 
// IF NOT TAX APPLIED, CHANGE THE LINE TO     finalSum = currency(grandTotal);


finalSum = currency((grandTotal * 25.00/100) + grandTotal);
                   cWin.write("<TD COLSPAN=3 ALIGN=CENTER bgcolor='#009933'><font face=arial COLOR=#ffcc00><b>Total:</b></font></TD>");

                   cWin.write("<TD COLSPAN=1 ALIGN=CENTER bgcolor='#009933'><font face=arial COLOR=#ffcc00><b>$ " + finalSum + " </b><SMALL>(excluded tax)</SMALL></font></TD>");

                   cWin.write("</TR></TABLE></CENTER>");
         // cWin.write("<br><br><b>Total:  $" + finalSum + " </b><b>");
          cWin.write("</b></form><br><br><font face=arial size =-1>If this is correct please fill out and submit the form below.<br>");

      cWin.write("If there is an error in your order or something you wish" + " to change, click \"View Basket\" to make the changes.</font><br>");
//THE FOLLOWING FORM POST EXAMPLE IS ACCOUNT OF GREATSHOP IN CGI-FREE.
//YOU CAN REGISTER AND APPLY FOR YOUR OWN FREE ACCOUNT IN CGI-FREE.COM
//CHANGE YOUR E-MAIL HERE! 

  cWin.write("<FORM NAME=orderform METHOD='POST' " );  
cWin.write(" ACTION='http://www.cgi-free.com/mailer.cgi?");

cWin.write("jfarkas4@matavnet.hu");


//YOU CAN CHANGE THE THANKYOU PAGE DISPLAY WITH YOUR COMPANY HYPERLINK IN THE FOLLOWING LINE...

cWin.write(" onSubmit=return false> <INPUT Type = 'hidden' Name = 'companyname' Value ='My Company Inc.'><INPUT Type = 'hidden' Name = 'Thanks' Value ='Please visit our store at: <br><br><h1><A HREF=http://www.mycompany.com target=_top>http://www.mycompany.com</A></h1><br><br>(To customize this ThankYou page part, please use Wordpad to open file _Display_ShipFee_Shop.js, <br>search for THANKYOU and you will find the code line to change.)<br><br>'>");

 
         
          cWin.write("Billing Address :<br>");           
          cWin.write("Your Email:<INPUT TYPE = 'text' SIZE = 50 NAME = 'email'><br>");           
          cWin.write("NAME:<INPUT TYPE = 'text' SIZE = 50 NAME = 'orderee'><br>");           
          cWin.write("Telephone: <INPUT TYPE = 'text' SIZE = 20 NAME = 'homephone'><br>"); 
  
   

          cWin.write("Street Address: <INPUT TYPE = 'text' SIZE = 43 NAME = 'address'><br>"); 


          cWin.write("City: <INPUT TYPE = 'text' SIZE = 52 NAME = 'city'><br>"); 

          cWin.write("State:<INPUT TYPE = 'text' SIZE = 2 NAME = 'state'> &nbsp; &nbsp;"); 

          cWin.write("Zip Code: <INPUT TYPE = 'text' SIZE = 5 NAME = 'zip'><br><br>"); 

          cWin.write("Telephone: <INPUT TYPE = 'text' SIZE = 20 NAME = 'phone'><br>"); 
          cWin.write("Fax: <INPUT TYPE = 'text' SIZE = 20 NAME = 'fax'><p>"); 
          cWin.write("Shipping Address(Optional) :<br>");           
          cWin.write("NAME:<INPUT TYPE = 'text' SIZE = 50 NAME = 'orderee'><br>");           
          cWin.write("Street Address: <INPUT TYPE = 'text' SIZE = 43 NAME = 'address'><br>"); 
          cWin.write("City: <INPUT TYPE = 'text' SIZE = 52 NAME = 'city'><br>"); 
          cWin.write("State:<INPUT TYPE = 'text' SIZE = 2 NAME = 'state'> &nbsp; &nbsp;"); 
          cWin.write("Zip Code: <INPUT TYPE = 'text' SIZE = 5 NAME = 'zip'><br><br>"); 
          cWin.write("Shipping Method:<SELECT NAME = 'shipSelection' onChange = 'parent.shipping(this.form," +  finalSum + ")'>");


//EDIT SHIPPING METHOD HERE! DO NOT REDUCE OR ADD LINE.

          cWin.write("<OPTION VALUE = '0'>Select Method");
          cWin.write("<OPTION VALUE = '20.95'>Same Day($20.95)");
          cWin.write("<OPTION VALUE = '10.95'>Next Day($10.95)");
          cWin.write("<OPTION VALUE = '7.95'>2nd Day($7.95)");
          cWin.write("<OPTION VALUE = '3.95'>3 Days($3.95)</Select><p>");


// EDIT THE LINE BELOW. ASK IF INCLUDED CALIFNORNIA OR OTHER STATE SALES TAX AS APPLICABLE.

 cWin.write("Purchase Total = $<INPUT TYPE =text SIZE = 15 NAME =finalTot> included Hungary sales tax & shipping fee.<br>"); 
          cWin.write("Credit Card Type: <INPUT TYPE = 'text' SIZE = 19 NAME = 'ccType'>** <br>"); cWin.write("Credit Card #: <INPUT TYPE = 'text' SIZE = 19 NAME = 'ccNum'>** <br>"); 


          cWin.write("Expiration Date: <INPUT TYPE = 'text' SIZE = 17 NAME = 'exDate'>");
          cWin.write("&nbsp;&nbsp;<INPUT TYPE = 'hidden' NAME='order'" + " VALUE = ''>");


          cWin.write("<CENTER><INPUT TYPE = 'submit' VALUE = 'Please, send me quotation' onClick = 'parent.formData(this.form)'>");


          cWin.write("&nbsp;&nbsp;<INPUT TYPE = 'reset' VALUE = 'Reset'>");
          cWin.write("</FORM>");
          cWin.write("</b></FONT><p></CENTER></BODY></HTML>");
          cWin.close();
      }else{
         alert("\n\nYour shopping cart is empty!\n\n");
      }
    }

    function formData(form){

         var formElems = form.elements.length;
         formSave = new makeArray(formElems-3);
         for(var i = 1; i <= formElems; i++){
              formSave[i] = form.elements[i-1].value;
         }
         for(var i = 1; i <= orderNum; i++){
               form.elements[21].value += "Quantity:" + order[i].totQ

               form.elements[21].value += " " + order[i].Indx
               form.elements[21].value += " at " + order[i].totSum/order[i].totQ + " |"
         }
        form.submit();           
    }
              

      function reTotal(c,totalPrice){
             totalPrice = totalPrice * parent.frames[2].document.forms[c].q.value;


             newTotal = currency(totalPrice) 
             parent.frames[2].document.forms[c].subTotal.value = newTotal;
      }

     function shipping(form, fSum){
          shipCost = form.shipSelection.options[form.shipSelection.selectedIndex].value;


          form.finalTot.value =currency( parseFloat(shipCost) + parseFloat(fSum));


    }


	function withTax(form){
          form.finalTax.value =currency(grandTotal * 8.25/100);
	}
	
	function withoutTax(form){
          form.finalTax.value =0;
	}


    function empty(){
       if(orderNum == 0){
          alert("\n\nYour cart is already empty!\n\n");
       }else{
           orderNum = 0;
           alert("\nYour cart has been emptied!\n");
       }
   }


