//Template 10: Display picture of product on catalog, 
//and the picture will also appear at the product 
//info page. Shipping fees editable. GreatShop Secure Form.
//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:&euro; "+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['head'].document.searcher.lookup.value;

       sWin.open();

       sWin.write("<HTML><HEAD><link rel=stylesheet href=style.css><TITLE>"+  prodName + " </TITLE></HEAD>");

       sWin.write("<BODY  bgcolor=#ffffff>");

       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><span class=newform><b>Your Search Got 0 Result!<br>Please try again.</b></span></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><link rel=stylesheet href=style.css><TITLE>"+  prodTypeInfo + " </TITLE></HEAD>");



        tWin.write("<BODY>");

        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 class=newformlink HREF='" + url + "'>" + link + "</A></TD></TR></TABLE></center>";
        }else{
          this.link = "";
        }

    }

    

    function show(w,prodIndexNum){

         w.write("</CENTER><center><TABLE BORDER = 0 WIDTH=300><TR><TD><span class=newformbig><b>"  + this.name + "</b></span></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></span></form></center>");



            if(this.image.length > 1){

               w.write("<CENTER><TABLE BORDER=0 COLS=2 WIDTH=300><TR BGCOLOR=#ffc000><TD><span class=newform>Produkt - Ansicht</span></TD><TD><span class=newform>Kurzbeschreibung</span></TD></TR><TR><TD><IMG SRC='" + this.image + "'></TD>");

 w.write("<TD><span class=newform>" + this.description + "</span></TD></TR></Table></CENTER>");

             }
           if(this.link != ""){
              w.write(this.link);
           }




           w.write("<FORM NAME=isaiah>");

            //alert(prodIndexNum);

           if (this.name == "il tubo")
           orderProdiltubo(this,w,prodIndexNum);           
           else
           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 orderProdiltubo(obj,win,index){


     win.write("<CENTER><TABLE BORDER=0 COLS=2 WIDTH=300><TR><TD><span class=newform><b>Preis pro St&uuml;ck:  &euro; </b>" + obj.price+"<br>(einschliesslich 1 Packung Vermicelli Nudeln, incl.Verpackung,Versand und 16% MwSt.)</span></CENTER>");

     win.write("<span class=newform><b>Anzahl:</b></span>  " + " <select NAME = 'q' onChange=parent.reTotaliltubo("+ parent.count + "," +  obj.price + ") onBlur = parent.reTotaliltubo("+ parent.count + "," +  obj.price + ") onFocus = parent.reTotaliltubo("+ parent.count + "," +  obj.price + ")><option value=1>1</option><option value=2>2</option><option value=5>5</option><option value=10>10</option><option value=15>15</option><option value=20>20</option><option value=25>25</option><option value=30>30</option><option value=40>40</option><option value=100>100</option></select><br>");


     win.write("<span class=newform><b>Gesamt:" + " &euro; </b></span><INPUT class=newform TYPE = 'text' SIZE=7 NAME= subTotal VALUE =" + obj.price + ">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;" + "<INPUT class=newformsm TYPE ='button' VALUE = 'SubTotal' onClick = parent.reTotaliltubo("+ parent.count + "," +  obj.price + ")></TR></TABLE></CENTER>");



     win.write("<CENTER><A HREF=javascript:parent.add(" + parent.count + "," + index + ")><IMG SRC=addtocart.gif border=0></A>")


   count++;

 }



   function orderProd(obj,win,index){


     win.write("<CENTER><TABLE BORDER=0 COLS=2 WIDTH=300><TR><TD><span class=newform><b>Preis pro St&uuml;ck:&euro; </b>" + obj.price+"</span></CENTER>");

     win.write("&nbsp;&nbsp;<span class=newform><b>Anzahl:</b></span>  " + "<INPUT class=newform 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;<span class=newform><b>Gesamt:" + " &euro; </b></span><INPUT class=newform TYPE = 'text' SIZE=7 NAME= subTotal VALUE =" + obj.price + ">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;" + "<INPUT class=newformsm TYPE ='button' VALUE = 'SubTotal' onClick = parent.reTotal("+ parent.count + "," +  obj.price + ")></TR></TABLE></CENTER>");



     win.write("<CENTER><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( + totalQuantity +"'"+ productName +  "' ins Warenkorb legen \n\nGesamtpreis: " + totalSum + " Euro ")){



          store(oIndex,totalSum,totalQuantity);

        }else{

           alert("\n\nDieser Artikel war nicht in Ihrem Warenkorb eingelegt");

        }

    }

   }



      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[3].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:&euro; "+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><head><link rel=stylesheet href=style.css></head><BODY><center>");
       if(orderNum != 0){
         vWin.write("<span class=newformbig><br><b>" + "Ihr Warenkorb</b></span><P>");
         vWin.write("<FORM><TABLE BORDER=0>");
         vWin.write("<TD COLSPAN=1 BGCOLOR=#ffc000><span class=newform>Anzahl</span></TD>");
         vWin.write("<TD COLSPAN=1 BGCOLOR=#ffc000><span class=newform>Artikel</span></TD>");
         vWin.write("<TD COLSPAN=1 BGCOLOR=#ffc000><span class=newform>Preis in &euro;</span></TD>");
         vWin.write("<TD COLSPAN=1 BGCOLOR=#ffc000><span class=newform>Entfernen</span></TD><TR>");
         for(var i = 1; i <= orderNum; i++){
         vWin.write("<TD COLSPAN=1 align=center><span class=newform>"+order[i].totQ+"</span></TD>");
         vWin.write("<TD COLSPAN=1 align=center><span class=newform>"+order[i].Indx+"</span></TD>");
         vWin.write("<TD COLSPAN=1 align=center ><span class=newform>"+order[i].totSum+",-</span></TD>");
         vWin.write("<TD VAlign=TOP align=center><input type='checkbox' Name=checkbox"+i+" onclick=parent.remove("+i+")></span>");
         vWin.write("<span class=newform><b>Entfernen</b></span></TD></TR>");
         }
      


// vWin.write("</TABLE></span></FORM><br><br><A HREF=javascript:history.back()><IMG SRC=continueShop.gif border=0></A>");

  vWin.write("<tr><td colspan=4><center><input type=button class=newformsm value='Zur Bestellformular' onclick='javascript:parent.checkOut();'></center></td></tr></TABLE></span></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><span class=newform>View Basket</span></TD><TD><A HREF = javascript:parent.checkOut(); return true;><IMG BORDER=0 SRC=checkout.gif></A><span class=newform>Check Out</span></TD><TD><A HREF=catalog.htm><img SRC=Home.gif border=0></A> <span class=newform>Store Front</span></TD><TD><A HREF=javascript:history.back(-1)><span class=newform><img src=exit.gif border=0></span></A><span class=newform>Continue To Shop</span></TD></TR></TABLE>

      }else{
			  alert("\n\nIn Moment sind keine Artikel in Ihrem Warenkorb.\n\n");
            vWin.write("<script language=javascript>window.location.href='catalog.htm';</script>");
            if(navigator.appName.indexOf("Netscape") != -1){
               vWin.write("<FORM><INPUT class=newformsm TYPE='button' VALUE='Back to Order Form' onclick='history.go(-1)'>");
            }
            }
            vWin.write("</TABLE></span></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[3].document.forms[0].runningTotal.value = currency(newSum);

      view();

     }
    function checkOut(){
        if(orderNum != 0){
        cWin = parent.frames[2].document;
        cWin.open();
        cWin.write("<HTML><head><link rel=stylesheet href=style.css></head><BODY><blockquote>");
        cWin.write("<FORM NAME=orderform METHOD='POST' " );  
        cWin.write("ACTION='http://www.start4.info/newform/form.php'>"); 

        cWin.write("<Table border=0><tr>");
         grandTotal = 0;
        // cWin.write("<FORM NAME = 'orderfor'>");
         cWin.write("<TD COLSPAN=1 BGCOLOR=#ffc000><span class=newform>Anzahl</span></TD>");
         cWin.write("<TD COLSPAN=1 BGCOLOR=#ffc000><span class=newform>Artikel</span></TD>");
         cWin.write("<TD COLSPAN=1 BGCOLOR=#ffc000><span class=newform>Preis</span></TD>");
         cWin.write("<TD COLSPAN=1 BGCOLOR=#ffc000><span class=newform>Gesamtpreis</span></TD></TR>");
         for(var i = 1; i <= orderNum; i++){
         cWin.write("<TD COLSPAN=1 align=center><span class=newform>"+order[i].totQ+"</span></TD>");
         cWin.write("<TD COLSPAN=1 align=center><span class=newform>"+order[i].Indx+"</span></TD>");
         cWin.write("<TD COLSPAN=1 align=center><span class=newform>"+parent.currency(order[i].totSum/order[i].totQ)+"</span></TD>");
         cWin.write("<TD COLSPAN=1 align=center><span class=newform>"+parent.currency(order[i].totSum)+",-</span></TD></TR>");
         cWin.write("<input type=hidden name=tableorder[] value=' Anzahl: "+order[i].totQ+"   Artikel: "+order[i].Indx+"   Preis: "+parent.currency(order[i].totSum/order[i].totQ)+"   Gesamtpreis: "+parent.currency(order[i].totSum)+"'>");
                   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 * 8.25/100) + grandTotal);
finalSum = currency(grandTotal);
                   cWin.write("<TD COLSPAN=3 ALIGN=CENTER bgcolor='#559976'><span class=newform><b>Summe:</b></span></TD>");

                   cWin.write("<TD COLSPAN=1 ALIGN=CENTER bgcolor='#559976'><span class=newform><b>&euro;   "  + finalSum +  " </b><SMALL>(inkl. MwSt.)</SMALL></span></TD>");

                   cWin.write("</TR></TABLE></blockquote>");

        cWin.write("<input type=hidden name=tableorder[] value='Summe : " + finalSum +"'>");

         // cWin.write("<br><br><b>Total:  &euro; " + finalSum + " </b><b>");
          cWin.write("</b><!--</form>--><br><br><blockquote><span class=newform>Nachdem Sie Ihre Bestellung &uuml;berpr&uuml;ft haben, f&uuml;len Sie bitte den Bestellformular aus.<br>");

      cWin.write("Ihre Ware wird in wenigen Tagen zugesand" + " um &Auml;nderungen vorzunehmen, clicken Sie \"View Basket\" .</span><br>");

//THE FOLLOWING SECURE FORM SUBMISSION USES SSL SERVICE UNDER GREATSHOP'S ACCOUNT.
//CHANGE YOUR E-MAIL HERE! 

  //cWin.write("<FORM NAME=orderform METHOD='POST' " );  
//cWin.write("ACTION='http://www.start4.info/newform/form.php'>  <INPUT type=hidden name=recipient value=" ); 

cWin.write("<INPUT type=hidden name=recipient value=" ); 
cWin.write("tester@greatbuilder.com");


//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("> <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("<center><span class=newform>Rechnungsadresse:</center><br><br>");           
          cWin.write("<input type=hidden name=fnsum value="+finalSum+">");
          cWin.write("<table border=0>");          

          cWin.write("<tr><td class=newform>Email:</td><td><INPUT class=newform TYPE = 'text' SIZE = 50 NAME = 'email'></td></tr>");           
  
       cWin.write("<tr><td class=newform>Vorname,Name :</td><td><INPUT class=newform TYPE = 'text' SIZE = 50 NAME = 'orderee'></td></tr>");           
  
          cWin.write("<tr><td class=newform>Strasse:</td><td> <INPUT class=newform TYPE = 'text' SIZE = 43 NAME = 'address'></td></tr>"); 


          cWin.write("<tr><td class=newform>Stadt:</td><td> <INPUT class=newform TYPE = 'text' SIZE = 52 NAME = 'city'></td></tr>"); 

          cWin.write("<tr><td class=newform>Land:</td><td><INPUT class=newform TYPE = 'text' SIZE = 2 NAME = 'state'> &nbsp; &nbsp;</td></tr>"); 

          cWin.write("<tr><td class=newform>PLZ:</td><td> <INPUT class=newform TYPE = 'text' SIZE = 5 NAME = 'zip'></td></tr>"); 

          cWin.write("<tr><td class=newform>Telefonnummer:</td><td> <INPUT class=newform TYPE = 'text' SIZE = 20 NAME = 'phone'></td></tr>"); 

	 cWin.write("<tr><td class=newform>Handy:</td><td> <INPUT class=newform TYPE = 'text' SIZE = 20 NAME = 'homephone'></td></tr>"); 

	 cWin.write("</table>");

    //      cWin.write("Fax: <INPUT TYPE = 'text' SIZE = 20 NAME = 'fax'><p>"); 
          cWin.write("<center> Lieferadresse<br>(Wenn vom Rechnungsadresse abweichend):</center><br><br>");           
         
	cWin.write("<table border=0>");
	 cWin.write("<tr><td class=newform>Vorname, Name:</td><td><INPUT class=newform TYPE = 'text' SIZE = 50 NAME = 'orderee1'></td></tr>");           
          cWin.write("<tr><td class=newform>Strasse:</td><td> <INPUT class=newform TYPE = 'text' SIZE = 43 NAME = 'address1'></td></tr>"); 
          cWin.write("<tr><td class=newform>Stadt:</td><td> <INPUT class=newform TYPE = 'text' SIZE = 52 NAME = 'city1'></td></tr>"); 
          cWin.write("<tr><td class=newform>Land:</td><td><INPUT class=newform TYPE = 'text' SIZE = 2 NAME = 'state1'> &nbsp; &nbsp;</td></tr>"); 
          cWin.write("<tr><td class=newform>PLZ:</td><td> <INPUT class=newform TYPE = 'text' SIZE = 5 NAME = 'zip1'></td></tr>"); 


// EDIT THE LINE BELOW. ASK IF INCLUDED CALIFNORNIA OR OTHER STATE SALES TAX AS APPLICABLE.

          cWin.write("&nbsp;&nbsp;<INPUT TYPE = 'hidden' NAME='order'" + " VALUE = ''>");

	 cWin.write("</table>");











          cWin.write("<INPUT class=newformsm TYPE = 'submit' VALUE = 'Abschicken' onClick = 'parent.formData(this.form)'>");
        
          //cWin.write("<INPUT class=newformsm TYPE = 'submit' VALUE = 'Abschicken'>");


          cWin.write("&nbsp;&nbsp;<INPUT class=newformsm TYPE = 'reset' VALUE = 'Zur&uuml;cksetzen'>");
          cWin.write("</table>");           
          cWin.write("</FORM>");
          cWin.write("</b></blockquote></BODY></HTML>");
          cWin.close();
      }else{
         alert("\n\nIhr Warenkorb ist leer!\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 reTotaliltubo(c,totalPrice){
   
             if (parent.frames[2].document.forms[c].q.options[parent.frames[2].document.forms[c].q.selectedIndex].value == 1)
             totalPrice = 22;
             if (parent.frames[2].document.forms[c].q.options[parent.frames[2].document.forms[c].q.selectedIndex].value == 2)
             totalPrice = 42;
             if (parent.frames[2].document.forms[c].q.options[parent.frames[2].document.forms[c].q.selectedIndex].value == 5)
             totalPrice = 100;
             if (parent.frames[2].document.forms[c].q.options[parent.frames[2].document.forms[c].q.selectedIndex].value == 10)
             totalPrice = 190;

             if (parent.frames[2].document.forms[c].q.options[parent.frames[2].document.forms[c].q.selectedIndex].value == 15)
             totalPrice = 270;

             if (parent.frames[2].document.forms[c].q.options[parent.frames[2].document.forms[c].q.selectedIndex].value == 20)
             totalPrice = 350;


             if (parent.frames[2].document.forms[c].q.options[parent.frames[2].document.forms[c].q.selectedIndex].value == 25)
             totalPrice = 425;


             if (parent.frames[2].document.forms[c].q.options[parent.frames[2].document.forms[c].q.selectedIndex].value == 30)
             totalPrice = 495;

             if (parent.frames[2].document.forms[c].q.options[parent.frames[2].document.forms[c].q.selectedIndex].value == 40)
             totalPrice = 640;
             if (parent.frames[2].document.forms[c].q.options[parent.frames[2].document.forms[c].q.selectedIndex].value == 100)
             totalPrice = 1400;

             newTotal = currency(totalPrice) 
             parent.frames[2].document.forms[c].subTotal.value = newTotal;
      }


      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");
       }
   }


