
var NewEoc = document.cookie; 
var ShipTotal=2.50; 
var Total=0; 
var SaleTotal=0; 
    var X1 ="";  
var X2 =0;
var X3 =0;
var X4 =0;
var today = new Date(); 
var expiry = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1000); 
var Xname = new Array(); 
var sdesc = new Array(); 
var cost = new Array(); 
var ship = new Array(); 
var quant = new Array(); 
var f = document.form; 
var value; 
var found = 0; var  whattowritepp = "";
var CookieAll;
var TotalQuant;
var TotalProducts;
var SubTotals;
var DiscountAmt;
Xname[0]    = 0;
sdesc[0]    = 0; 
cost[0]      = 0; 
ship[0]       = 0; 
quant[0]     = 0;  


function getallCookie() { 
//new spanning code
  var whole_cookie = document.cookie;
  var each_cookie = whole_cookie.split(";") ;
  var value ="";

  for (var i=0; i< each_cookie.length;i++){
    if( each_cookie[i].indexOf("NewEoc=") != -1) {
      var index = each_cookie[i].indexOf("NewEoc=");
      index = each_cookie[i].split("=");
      value = value + index[1];}

  for(var j=1; j<6;j++){
     if( each_cookie[i].indexOf("NewEoc"+j+"=") != -1) {
       var index = each_cookie[i].indexOf("NewEoc"+j+"=");
       index = each_cookie[i].split("=");
       value = value + index[1];}}} 

  return unescape(value);}


function initValues() {
    CookieAll = getallCookie();
          if (CookieAll == null) { 
          } else {          var EachCookie = CookieAll.split("^~^");
          var f = document.form;          var j=0;
              ShipTotal = EachCookie[0]   || 2.50 ; 
              ShipTotal = ShipTotal * 1;
           X1 = EachCookie[1]   || "" ; 
           X2 = EachCookie[2]   || 0 ; 
           X2 = X2 * 1;
           X3 = EachCookie[3]   || 0 ; 
          X3 = X3 * 1;
          X4 = EachCookie[4]   || 0 ; 
          X4 = X4 * 1;
               for (var i = 5; i < EachCookie.length; i=i+5){
               Xname[j]  = EachCookie[i] || 0;
              sdesc[j]   = EachCookie[i+1] || 0; 
               cost[j]  = EachCookie[i+2] || 0; 
               ship[j]  = EachCookie[i+3] || 0; 
               quant[j] = EachCookie[i+4] || 0; j++;}}

               var s ="";
               for (var i = 0; i < document.form.elements.length; i++){
               if (document.form.elements[i].type == "text") {               s= document.form.elements[i].name;
               if (s.indexOf("tOption") > -1) {document.form.elements[i].value = "0.00"}}}
               for (var i = 0; i < Xname.length; i++){
                    if (Xname[i] == '1')  {Xname[i] ='1';f.Option0A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '2')  {Xname[i] ='2';f.Option1A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '3')  {Xname[i] ='3';f.Option2A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '4')  {Xname[i] ='4';f.Option3A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '5')  {Xname[i] ='5';f.Option4A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '6')  {Xname[i] ='6';f.Option5A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '7')  {Xname[i] ='7';f.Option6A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '8')  {Xname[i] ='8';f.Option7A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '9')  {Xname[i] ='9';f.Option8A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '10')  {Xname[i] ='10';f.Option9A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '11')  {Xname[i] ='11';f.Option10A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '12')  {Xname[i] ='12';f.Option11A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '13')  {Xname[i] ='13';f.Option12A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '14')  {Xname[i] ='14';f.Option13A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '15')  {Xname[i] ='15';f.Option14A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '16')  {Xname[i] ='16';f.Option15A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '17')  {Xname[i] ='17';f.Option16A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '18')  {Xname[i] ='18';f.Option17A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '19')  {Xname[i] ='19';f.Option18A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '20')  {Xname[i] ='20';f.Option19A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '21')  {Xname[i] ='21';f.Option20A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '22')  {Xname[i] ='22';f.Option21A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '23')  {Xname[i] ='23';f.Option22A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '24')  {Xname[i] ='24';f.Option23A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '25')  {Xname[i] ='25';f.Option24A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '26')  {Xname[i] ='26';f.Option25A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '27')  {Xname[i] ='27';f.Option26A.options.selectedIndex = quant[i];continue;}
                    if (Xname[i] == '28')  {Xname[i] ='28';f.Option27A.options.selectedIndex = quant[i];continue;}
                    


               }
          Calculate();
          }


function Calculate()   { 
   ShipTotal = 0;
   Total = 0;
  var f = document.form;
  for (var i = 0; i < Xname.length; i++){
if (Xname[i] == '1')  {f.tOption0A.value = "" + round(document.form.Option0A[document.form.Option0A.selectedIndex].value  * 29.50);continue;}

if (Xname[i] == '2')  {f.tOption1A.value = "" + round(document.form.Option1A[document.form.Option1A.selectedIndex].value  * 29.50);continue;}

if (Xname[i] == '3')  {f.tOption2A.value = "" + round(document.form.Option2A[document.form.Option2A.selectedIndex].value  * 29.50);continue;}

if (Xname[i] == '4')  {f.tOption3A.value = "" + round(document.form.Option3A[document.form.Option3A.selectedIndex].value  * 59.00);continue;}

if (Xname[i] == '5')  {f.tOption4A.value = "" + round(document.form.Option4A[document.form.Option4A.selectedIndex].value  * 29.50);continue;}

if (Xname[i] == '6')  {f.tOption5A.value = "" + round(document.form.Option5A[document.form.Option5A.selectedIndex].value  * 29.50);continue;}

if (Xname[i] == '7')  {f.tOption6A.value = "" + round(document.form.Option6A[document.form.Option6A.selectedIndex].value  * 49.50);continue;}

if (Xname[i] == '8')  {f.tOption7A.value = "" + round(document.form.Option7A[document.form.Option7A.selectedIndex].value  * 24.50);continue;}

if (Xname[i] == '9')  {f.tOption8A.value = "" + round(document.form.Option8A[document.form.Option8A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '10')  {f.tOption9A.value = "" + round(document.form.Option9A[document.form.Option9A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '11')  {f.tOption10A.value = "" + round(document.form.Option10A[document.form.Option10A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '12')  {f.tOption11A.value = "" + round(document.form.Option11A[document.form.Option11A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '13')  {f.tOption12A.value = "" + round(document.form.Option12A[document.form.Option12A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '14')  {f.tOption13A.value = "" + round(document.form.Option13A[document.form.Option13A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '15')  {f.tOption14A.value = "" + round(document.form.Option14A[document.form.Option14A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '16')  {f.tOption15A.value = "" + round(document.form.Option15A[document.form.Option15A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '17')  {f.tOption16A.value = "" + round(document.form.Option16A[document.form.Option16A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '18')  {f.tOption17A.value = "" + round(document.form.Option17A[document.form.Option17A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '19')  {f.tOption18A.value = "" + round(document.form.Option18A[document.form.Option18A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '20')  {f.tOption19A.value = "" + round(document.form.Option19A[document.form.Option19A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '21')  {f.tOption20A.value = "" + round(document.form.Option20A[document.form.Option20A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '22')  {f.tOption21A.value = "" + round(document.form.Option21A[document.form.Option21A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '23')  {f.tOption22A.value = "" + round(document.form.Option22A[document.form.Option22A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '24')  {f.tOption23A.value = "" + round(document.form.Option23A[document.form.Option23A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '25')  {f.tOption24A.value = "" + round(document.form.Option24A[document.form.Option24A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '26')  {f.tOption25A.value = "" + round(document.form.Option25A[document.form.Option25A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '27')  {f.tOption26A.value = "" + round(document.form.Option26A[document.form.Option26A.selectedIndex].value  * 24.50);continue;}
if (Xname[i] == '28')  {f.tOption27A.value = "" + round(document.form.Option27A[document.form.Option27A.selectedIndex].value  * 24.50);continue;}

  }     for (var i = 0; i < Xname.length; i++){ 
             if(cost[i] > 0) {Total += quant[i] * cost[i];}             if(ship[i] > 0) {ShipTotal +=  quant[i] * ship[i];}}
         var Saletotal = Total * (0/100);
         Saletotal = Saletotal * 1;         f.total.value = "" + round(Total);
return false; 
} 



function setCookie(PageName,PageDesc,PageQuant,PageCost,PageShip) {  
var f = document.form;  found = 0;
     for (var i = 0; i < Xname.length; i++){
       if (PageName == Xname[i]) {
        if (PageName==1){ Xname[i] = '1'; quant[i] = document.form.Option0A[document.form.Option0A.selectedIndex].value; f.Option0A.focus(); f.tOption0A.focus(); found=1;break;}
else         if (PageName==2){ Xname[i] = '2'; quant[i] = document.form.Option1A[document.form.Option1A.selectedIndex].value; f.Option1A.focus(); f.tOption1A.focus(); found=1;break;}
else         if (PageName==3){ Xname[i] = '3'; quant[i] = document.form.Option2A[document.form.Option2A.selectedIndex].value; f.Option2A.focus(); f.tOption2A.focus(); found=1;break;}
else         if (PageName==4){ Xname[i] = '4'; quant[i] = document.form.Option3A[document.form.Option3A.selectedIndex].value; f.Option3A.focus(); f.tOption3A.focus(); found=1;break;}
else         if (PageName==5){ Xname[i] = '5'; quant[i] = document.form.Option4A[document.form.Option4A.selectedIndex].value; f.Option4A.focus(); f.tOption4A.focus(); found=1;break;}
else         if (PageName==6){ Xname[i] = '6'; quant[i] = document.form.Option5A[document.form.Option5A.selectedIndex].value; f.Option5A.focus(); f.tOption5A.focus(); found=1;break;}
else         if (PageName==7){ Xname[i] = '7'; quant[i] = document.form.Option6A[document.form.Option6A.selectedIndex].value; f.Option6A.focus(); f.tOption6A.focus(); found=1;break;}
else         if (PageName==8){ Xname[i] = '8'; quant[i] = document.form.Option7A[document.form.Option7A.selectedIndex].value; f.Option7A.focus(); f.tOption7A.focus(); found=1;break;}
else         if (PageName==9){ Xname[i] = '9'; quant[i] = document.form.Option8A[document.form.Option8A.selectedIndex].value; f.Option8A.focus(); f.tOption8A.focus(); found=1;break;}
else         if (PageName==10){ Xname[i] = '10'; quant[i] = document.form.Option9A[document.form.Option9A.selectedIndex].value; f.Option9A.focus(); f.tOption9A.focus(); found=1;break;}
else         if (PageName==11){ Xname[i] = '11'; quant[i] = document.form.Option10A[document.form.Option10A.selectedIndex].value; f.Option10A.focus(); f.tOption10A.focus(); found=1;break;}
else         if (PageName==12){ Xname[i] = '12'; quant[i] = document.form.Option11A[document.form.Option11A.selectedIndex].value; f.Option11A.focus(); f.tOption11A.focus(); found=1;break;}
else         if (PageName==13){ Xname[i] = '13'; quant[i] = document.form.Option12A[document.form.Option12A.selectedIndex].value; f.Option12A.focus(); f.tOption12A.focus(); found=1;break;}
else         if (PageName==14){ Xname[i] = '14'; quant[i] = document.form.Option13A[document.form.Option13A.selectedIndex].value; f.Option13A.focus(); f.tOption13A.focus(); found=1;break;}
else         if (PageName==15){ Xname[i] = '15'; quant[i] = document.form.Option14A[document.form.Option14A.selectedIndex].value; f.Option14A.focus(); f.tOption14A.focus(); found=1;break;}
else         if (PageName==16){ Xname[i] = '16'; quant[i] = document.form.Option15A[document.form.Option15A.selectedIndex].value; f.Option15A.focus(); f.tOption15A.focus(); found=1;break;}
else         if (PageName==17){ Xname[i] = '17'; quant[i] = document.form.Option16A[document.form.Option16A.selectedIndex].value; f.Option16A.focus(); f.tOption16A.focus(); found=1;break;}
else         if (PageName==18){ Xname[i] = '18'; quant[i] = document.form.Option17A[document.form.Option17A.selectedIndex].value; f.Option17A.focus(); f.tOption17A.focus(); found=1;break;}
else         if (PageName==19){ Xname[i] = '19'; quant[i] = document.form.Option18A[document.form.Option18A.selectedIndex].value; f.Option18A.focus(); f.tOption18A.focus(); found=1;break;}
else         if (PageName==20){ Xname[i] = '20'; quant[i] = document.form.Option19A[document.form.Option19A.selectedIndex].value; f.Option19A.focus(); f.tOption19A.focus(); found=1;break;}
else         if (PageName==21){ Xname[i] = '21'; quant[i] = document.form.Option20A[document.form.Option20A.selectedIndex].value; f.Option20A.focus(); f.tOption20A.focus(); found=1;break;}
else         if (PageName==22){ Xname[i] = '22'; quant[i] = document.form.Option21A[document.form.Option21A.selectedIndex].value; f.Option21A.focus(); f.tOption21A.focus(); found=1;break;}
else         if (PageName==23){ Xname[i] = '23'; quant[i] = document.form.Option22A[document.form.Option22A.selectedIndex].value; f.Option22A.focus(); f.tOption22A.focus(); found=1;break;}
else         if (PageName==24){ Xname[i] = '24'; quant[i] = document.form.Option23A[document.form.Option23A.selectedIndex].value; f.Option23A.focus(); f.tOption23A.focus(); found=1;break;}
else         if (PageName==25){ Xname[i] = '25'; quant[i] = document.form.Option24A[document.form.Option24A.selectedIndex].value; f.Option24A.focus(); f.tOption24A.focus(); found=1;break;}
else         if (PageName==26){ Xname[i] = '26'; quant[i] = document.form.Option25A[document.form.Option25A.selectedIndex].value; f.Option25A.focus(); f.tOption25A.focus(); found=1;break;}
else         if (PageName==27){ Xname[i] = '27'; quant[i] = document.form.Option26A[document.form.Option26A.selectedIndex].value; f.Option26A.focus(); f.tOption26A.focus(); found=1;break;}
else         if (PageName==28){ Xname[i] = '28'; quant[i] = document.form.Option27A[document.form.Option27A.selectedIndex].value; f.Option27A.focus(); f.tOption27A.focus(); found=1;break;}
else { found=1;break;
  }}}
  if (found == 0){ 
  var bv = parseInt(navigator.appVersion);
     Xname[Xname.length] = PageName;     sdesc[sdesc.length] = PageDesc;     quant[quant.length] = PageQuant;     cost[cost.length] = PageCost;       ship[ship.length] = PageShip;  }
  Calculate();
     var value ="";  
    value = ShipTotal  || 2.50;  
    value += "^~^"
    value += X1    || "";  
    value += "^~^"
    value += X2    || 0;  
    value += "^~^"
    value += X3 || 0;  
    value += "^~^"
    value += X4  || 0;  
    value += "^~^"
    var kk = 30; 
    var jj = Xname.length/kk; 
    for (var i = 0; i < kk && i < Xname.length; i++){ 
    value += Xname[i] + "^~^" + sdesc[i] + "^~^" + cost[i] + "^~^"+ ship[i] + "^~^" + quant[i] + "^~^";} 
    if (value != null && value != "") { 
    document.cookie= "NewEoc=" + escape(value) + "; expires=" + expiry.toGMTString()+";path=/;";
    NewEoc = document.cookie;} 
    value = ""; 
    for (var mm=1; mm < jj; mm++){  
      if (Xname.length - 1 >= kk*mm) { 
        for ( i = kk*mm; i < kk*mm+kk && i < Xname.length; i++){ 
          value += Xname[i] + "^~^" + sdesc[i] + "^~^" + cost[i] + "^~^"+ ship[i] + "^~^" + quant[i] + "^~^";} 
      if (value != null && value != "") { 
        document.cookie= "NewEoc"+mm+"=" + escape(value) + "; expires=" + expiry.toGMTString()+";path=/;";
        value = "";}}} 
    if (jj >= 20){ alert("Please checkout now, the cart is full");}
   }




function round(number) { number = Math.round(number*Math.pow(10,2))/Math.pow(10,2); 
return (number == Math.floor(number)) ? number + '.00' : (  (number*10 == Math.floor(number*10)) ? number + '0' : number); } 



function OpenIn(NewLocation) {document.location = NewLocation;return false;}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//################################## Triple Check ################
var a=0;
function tripleCheck()
{
	a++;
	if(a<2){
		
//############ alle Fälle		
/*	if(document.form.tOption0A.value >="29.50"&&document.form.tOption4A.value >= "69.00")
			{
  			alert(unescape("Sie haben Filme einzeln bestellt.\nBeachten Sie unser Angebote%3A 4erPack%21"));
   			document.form.Option3A.focus();
			return false;
		   }
		   
	if(document.form.tOption1A.value >="29.50"&&document.form.tOption4A.value >= "69.00")
			{
  			alert(unescape("Sie haben Filme einzeln bestellt.\nBeachten Sie unser Angebote%3A 4erPack%21"));
   			document.form.Option3A.focus();
			return false;
		   }
		   	if(document.form.tOption2A.value >="29.50"&&document.form.tOption4A.value >= "69.00")
			{
  			alert(unescape("Sie haben Filme einzeln bestellt.\nBeachten Sie unser Angebote%3A 4erPack%21"));
   			document.form.Option3A.focus();
			return false;
		   }
	if(document.form.tOption3A.value >="29.50"&&document.form.tOption4A.value >= "69.00")
			{
  			alert(unescape("Sie haben Filme einzeln bestellt.\nBeachten Sie unser Angebote%3A 4erPack%21"));
   			document.form.Option3A.focus();
			return false;
		   }*/
		   
//################################## Double Check 	   
		   
		   	if(document.form.tOption5A.value >="29.50"&&document.form.tOption6A.value >= "29.50")
			{
  			alert(unescape("Sie die Filme einzeln bestellt.\nBeachten Sie unser Angebot%3A Doublepack%21"));
   			document.form.Option7A.focus();
			return false;
		   }
		   
		   
		   	}
		   	OpenIn("viewcart.html")


	
}


//################################## Triple Check Kasse ################
var a=0;
function tripleCheckKasse()
{
	a++;
	if(a<3){
		
//############ alle Fälle		
/*	if(document.form.tOption0A.value >="29.50"&&document.form.tOption1A.value >= "29.50")
			{
  			alert(unescape("Sie haben Filme einzeln bestellt.\nBeachten Sie unser Angebote%3A Triplepack%21"));
   			document.form.Option3A.focus();
			return false;
		   }
		   
		if(document.form.tOption0A.value >="29.50"&&document.form.tOption2A.value >= "29.50")
			{
  			alert(unescape("Sie haben Filme einzeln bestellt.\nBeachten Sie unser Angebot%3A Triplepack%21"));
   			document.form.Option3A.focus();
			return false;
		   } 
		   
		   
		   if(document.form.tOption1A.value >="29.50"&&document.form.tOption2A.value >= "29.50")
			{
  			alert(unescape("Sie mehr als einen Film bestellt.\nBeachten Sie unser Angebot%3A Triplepack%21"));
   			document.form.Option3A.focus();
			return false;
		   }  
		   */
//################################## Double Check 	   
		   
		   	if(document.form.tOption5A.value >="29.50"&&document.form.tOption6A.value >= "29.50")
			{
  			alert(unescape("Sie die Filme einzeln bestellt.\nBeachten Sie unser Angebot%3A Doublepack%21"));
   			document.form.Option7A.focus();
			return false;
		   }
		   
		   
		   	}
		   	OpenIn("checkout.html")


	
}

