DataBase      = new Array();
  HTTP_VARS     = new Array();
  ItemsArray    = new Array();
  StartArray    = new Array();
  Basket        = new Array();
  LastSeen      = new Array();
  CusInputArray = new Array();
  CusSelArray   = new Array();
  TopItemsArray = new Array();
  HistoryList   = new Array();
  HistoryIndex  = -1;
  NextPage      = "";
  LastVisted    = "main.htm";

  SeaArray      = new Array();
  currency      = "EUR";
  groname       = new Array();
  groindex      = -1
  picindex      = 0;
  WiSize        = -1;
  itemid        = -1;
  itemno        = -1;
  itemindex     = "";
  itemstart     = 0;
  itemend       = 0;
  pageno        = 1;
  groupid       = -1;
  protect       = true;
  ibox          = -1;
  SearchKeyWord = '';
  SearchNa      = -1; 
  SearchNo      = -1; 
  SearchSt      = -1; 
  SearchSl      = -1;
  SearchMa      = -1; 
  ListReport    = 0;  
  ShippingName  = '';
  ShippingPrice = 0;
  PaymentName   = '';
  PaymentPrice  = 0;
  order1        = false;
  order2        = false;
  order3        = false;
  OwnerCountry  = "";
  CustCountry   = "";
  SCustCountry  = "";
  ShippingType  = 0;
  SAddress      = false;

  BankName      = '';
  AccountOwner  = '';
  AccountNo     = '';
  BankNo        = '';
  BankIBAN      = '';
  BankSwift     = '';

  CreditName    = '';
  CreditNo      = '';
  CreditSafeNo  = '';
  CreditTT      = '';
  CreditMM      = '';
  CreditYYYY    = '';

  var uri = unescape(window.location.href);
  uri = uri.split("?");
  if (uri.length > 1) {
    var paramstring = uri[1];
    var paramarray = paramstring.split("&");    
    for ( var i = 0; i < paramarray.length; i++) {
      HTTP_VARS[i] = new Array();
      params = paramarray[i].split("=");
      HTTP_VARS[i]["name"] = params[0];  
      HTTP_VARS[i]["value"] = params[1];
    }  
  }

  var ndate = new Date();
  var oid = (Date.parse(ndate) / 1000) * 17;
  orderid = parseInt(oid);

  document.onkeyup = KeyPress;

  function IBoxPress(x) {
    ibox = x;
  }  

  function KeyPress(x) {
    if ( TestID("SearchInput",0) == true ) {
      if ( x.which == 13 ) {
        if ( ibox == 0 ) { SearchKeyWord = document.getElementById("SearchInput").value; SearchWord(0,1,1,1,1,1,0); }
        else if ( ibox == 1 ) { CheckPassword(); }
      }
    }
  }

 function GetTopItemsImageSrc(index) {
    var retVal = 'images/clear.gif';
    var id = items[index][0]; 
    if ( items[index][3] != "unk" ) { retVal = 'pictures/items_img_small_'+id+'.'+items[index][12]; }
    else {
      if ( items[index][4] != "" ) { retVal = items[index][4]; } 
      else {
        if ( items[index][5] != "unk" && parent.options[0][54] == 1 ) { retVal = 'pictures/items_img_small_'+id+'.'+items[index][13]; }
        else {
          if ( items[index][6] != "" && parent.options[0][54] == 1  ) { retVal = items[index][6]; }        
        }
      }
    }
    return retVal;
  }

  function TestID(a,b) {
    var retVal = false;
    if ( b == 0 ) { 
      var x = document.getElementsByTagName('div');
      for ( var y = 0; y < x.length; y++ ) {
        if ( x[y].id == a ) { retVal = true; } }
      var x = document.getElementsByTagName('span');
      for ( var y = 0; y < x.length; y++ ) {
        if ( x[y].id == a ) { retVal = true; } }
      var x = document.getElementsByTagName('input');
      for ( var y = 0; y < x.length; y++ ) {
        if ( x[y].id == a ) { retVal = true; } }
      var x = document.getElementsByTagName('table');
      for ( var y = 0; y < x.length; y++ ) {
        if ( x[y].id == a ) { retVal = true; } }
    }
    else { retVal = true; }
    return retVal;
  }

  function DoSearch() {
    if ( SearchKeyWord == "" ) {
      alert('Bitte geben Sie einen Suchbegriff an!');
    }
    else {      
      MainIFrame.location.href = "pages/search.htm?dosearch=1";
      window.scrollTo(0, 0);
      MainIFrame.scrollTo(0, 0);
    }
  }

  function StartFromSortName(a,b) {
    return parseFloat(a["startfrom"]) - parseFloat(b["startfrom"]);
  }
  function StartFromSort1(a,b) {
    return parseFloat(a[1]) - parseFloat(b[1]);
  }
  function StartFromSort2(a,b) {
    return parseFloat(a[2]) - parseFloat(b[2]);
  }

  function GetBruPrice() {
    var retVal = 0;    
    var BasketSum   = GetBasketSum();
    var DiscountSum = GetDiscountSum();
    var ShippingSum = GetShippingSum();
    var PaymentSum  = GetPaymentSum();
    var TotalSum    = parseFloat(BasketSum) - parseFloat(DiscountSum) + parseFloat(ShippingSum) + parseFloat(PaymentSum);
    if ( options[0][3] == 0 ) { retVal = TotalSum; }
    else {
      var AllTaxes = 0;
      var TPrices = String(GetTaxPrices()).split(',');
      for ( var i = 0; i < TPrices.length; i++ ) {
        AllTaxes = parseFloat(AllTaxes) + parseFloat(TPrices[i]);
      }
      retVal = parseFloat(TotalSum) + parseFloat(AllTaxes);
    }
    return retVal;     
  }

  function GetNetPrice() {
    var retVal = 0;
    var BasketSum   = GetBasketSum();
    var DiscountSum = GetDiscountSum();
    var ShippingSum = GetShippingSum();
    var PaymentSum  = GetPaymentSum();
    var TotalSum    = parseFloat(BasketSum) - parseFloat(DiscountSum) + parseFloat(ShippingSum) + parseFloat(PaymentSum);
    if ( options[0][3] == 1 ) { retVal = TotalSum; }
    else {
      var AllTaxes = 0;
      var TPrices = String(GetTaxPrices()).split(',');
      for ( var i = 0; i < TPrices.length; i++ ) {
        AllTaxes = parseFloat(AllTaxes) + parseFloat(TPrices[i]);
      }
      retVal = parseFloat(TotalSum) - parseFloat(AllTaxes);
    }
    return retVal;    
  }

  function GetDiscountPercent() {
    var BasketSum   = GetBasketSum();
    var DiscountSum = GetDiscountSum();
    if ( BasketSum > 0 ) {
      var retVal = ( parseFloat(DiscountSum) * 100.00 ) / parseFloat(BasketSum); }
    else { var retVal = 0; }
    retVal = retVal * (-1);
    return retVal;
  }

  function GetTaxPrices() {
    var retVal               = '';
    var b                    = false;
    var c                    = -1;
    var taxes                = String(GetTaxList()).split(',');
    var taxlist              = new Array();
    var dgp                  = GetDiscountPercent() * (-1);
    var BasketSum            = GetBasketSum();
    var DiscountSum          = GetDiscountSum();
    var ShippingSum          = GetShippingSum();
    var PaymentSum           = GetPaymentSum();
    var TotalSum             = GetTotal();


    for ( i = 0; i < taxes.length; i++ ) {
      var CurrentSum = 0.00;
      var CurrentTax = taxes[i];
      for ( var y = 0; y < Basket.length; y++ ) {
        if ( Basket[y]["tax"] == CurrentTax ) {
          CurrentSum = parseFloat(CurrentSum) + ( parseFloat(Basket[y]["realprice"]) * parseFloat(Basket[y]["amount"]) );
        }
      }
      if ( dgp > 0 ) {
        CurrentSum = parseFloat(CurrentSum) - ( (parseFloat(CurrentSum) / 100.00) * parseFloat(dgp) ); }      

      if ( ShippingType == 0 ) {
        if ( CurrentTax == options[0][52] ) {
          CurrentSum = parseFloat(CurrentSum) + parseFloat(ShippingSum) + parseFloat(PaymentSum); } }
      else if ( ShippingType == 1 ) {
        if ( CurrentTax == options[0][68] ) {
        if ( options[0][68] == 0 ) { options[0][68] = options[0][52]; }
          CurrentSum = parseFloat(CurrentSum) + parseFloat(ShippingSum) + parseFloat(PaymentSum); } }
      else if ( ShippingType == 2 ) {
        if ( options[0][69] == 0 ) { options[0][69] = options[0][52]; }
        if ( CurrentTax == options[0][69] ) {
          CurrentSum = parseFloat(CurrentSum) + parseFloat(ShippingSum) + parseFloat(PaymentSum); } }

      if ( options[0][3] == 1 ) {
         var netto  = CurrentSum;
         var brutto = GetSecPrice(netto,CurrentTax);
      }
      else if ( options[0][3] == 0 ) {
         var brutto  = CurrentSum;
         var netto = GetSecPrice(brutto,CurrentTax);
      }
      taxlist[i] = parseFloat(brutto) - parseFloat(netto);     

    }
    
    for ( i = 0; i < taxlist.length; i++ ) {
      if ( i < (taxlist.length - 1) ) {
        retVal = retVal + taxlist[i] + ','; }
      else {
        retVal = retVal + taxlist[i]; }
    }
    return retVal;
  }

  function GetTaxList() {
    var retVal    = '';
    var TempArray = new Array();
    for ( var i = 0; i < Basket.length; i++ ) {
      var Tax = Basket[i]["tax"];
      var b   = false; 
      for ( var y = 0; y < TempArray.length; y++ ) {
        if ( Tax == TempArray[y] ) { b = true; }
      }
      if ( b == false ) { TempArray[TempArray.length] = Tax; }
    }
    for ( var i = 0; i < TempArray.length; i++ ) {
      if ( i > 0 ) { retVal = retVal + ',' + TempArray[i]; }
      else { retVal = retVal + TempArray[i]; }
    } 
    if ( ShippingType == 0 ) { var Tax = options[0][52]; }
    else if ( ShippingType == 1 ) { var Tax = options[0][68]; }
    else if ( ShippingType == 2 ) { var Tax = options[0][69]; }
    var b   = false;
    for ( var i = 0; i < TempArray.length; i++ ) {
      if ( TempArray[i] == Tax ) { b = true; }    
    }    
    if ( b == false ) {
      if ( retVal == '' ) { retVal = Tax; }
      else { retVal = retVal + ',' + Tax; }
    } 
    return retVal;
  }

  function GetRealPrice(index, amount, price ) {
    var retVal  = 0;
    var IDPrice = Round(GetItemsDiscountAmount(index, amount, price));
    var GDPrice = Round(GetGroupsDiscount(index, amount, price));
    retVal      = parseFloat(price) - parseFloat(IDPrice) - parseFloat(GDPrice);
    return retVal;    
  }

  function GetPriceText(FirPrice, Tax) {
    var SecPrice = GetSecPrice(FirPrice, Tax);
    if ( options[0][3] == 0 && options[0][30] == 0) {
      var Price = FirPrice; }
    else if ( options[0][3] == 0 && options[0][30] == 1) {
      var Price = SecPrice; }
    else if ( options[0][3] == 1 && options[0][30] == 0) {
      var Price = SecPrice; }
    else if ( options[0][3] == 1 && options[0][30] == 1) {
      var Price = FirPrice; }
    Price = Round(Price) + ' ' + currency;
    return Price;   
  }

  function GetBasketSum() {
    var retVal = 0;
    for ( var i = 0; i < Basket.length; i++ ) {
      var Price = parseFloat(Basket[i]["amount"]) * parseFloat(Basket[i]["realprice"]);
      retVal = parseFloat(retVal) + parseFloat(Price);
    }
    return Round(retVal);
  }

  function GetTotal() {
    var retVal = 0;
    retVal = parseFloat(Round(GetBasketSum())) - GetDiscountSum() + parseFloat(GetShippingSum()) + parseFloat(GetPaymentSum());
    return retVal;
  }

  function GetWeightSum() {
    var retVal = 0;
    for ( var i = 0; i < Basket.length; i++ ) {
      retVal = parseFloat(retVal) + (parseFloat(Basket[i]["amount"]) * ( parseFloat(Basket[i]["weight"]) + parseFloat(Basket[i]["variantsweight"])));
    }
    return retVal;
  }

  function GetAmountSum() {
    var retVal = 0;
    for ( var i = 0; i < Basket.length; i++ ) {
      retVal = parseFloat(retVal) + parseFloat(Basket[i]["amount"]);
    }
    return retVal;
  }

  function GetDiscountSum() {
    var retVal = 0;
    retVal = parseFloat(GetAmountDiscount()) + parseFloat(GetWeightDiscount()) + parseFloat(GetPriceDiscount());
    retVal = parseFloat(retVal);
    return retVal;   
  }

  function GetShippingSum() {
    var retVal       = 0;    
    var BasketSum    = GetBasketSum();
    var WeightSum    = GetWeightSum();
    var AmountSum    = GetAmountSum();
    var FreeShipping = true;
    var toam         = 0;

    for ( var i = 0; i < Basket.length; i++ ) {
      if ( Basket[i]["freeshipping"] == false ) {
        FreeShipping = false;
      }
    } 

    for ( var i = 0; i < Basket.length; i++ ) {
      toam = parseFloat(toam) + parseFloat(Basket[i]["amount"]);
    } 

    if ( toam <= 0 ) { FreeShipping = false; }
   
    if ( ShippingType == 0 ) {
      if ( BasketSum >= options[0][45] && options[0][45] > 1  ) { FreeShipping = true; }
      if ( WeightSum >= options[0][44] && options[0][44] > 1 ) { FreeShipping = true; }
      if ( AmountSum >= options[0][43] && options[0][43] > 1 ) { FreeShipping = true; }
    }

    else if ( ShippingType == 1 ) {
      if ( BasketSum >= options[0][76] && options[0][76] > 1  ) { FreeShipping = true; }
      if ( WeightSum >= options[0][78] && options[0][78] > 1 ) { FreeShipping = true; }
      if ( AmountSum >= options[0][74] && options[0][74] > 1 ) { FreeShipping = true; }
    }

    else if ( ShippingType == 2 ) {
      if ( BasketSum >= options[0][77] && options[0][77] > 1  ) { FreeShipping = true; }
      if ( WeightSum >= options[0][79] && options[0][79] > 1 ) { FreeShipping = true; }
      if ( AmountSum >= options[0][75] && options[0][75] > 1 ) { FreeShipping = true; }
    }

    if ( ShippingType == 0 ) {
      if ( options[0][33] == 1 ) { FreeShipping = true; }   }
    else if ( ShippingType == 1 ) {
      if ( options[0][70] == 1 ) { FreeShipping = true; }   }
    else if ( ShippingType == 2 ) {
      if ( options[0][71] == 1 ) { FreeShipping = true; }   }

    if ( ShippingType == 0 ) {    
      if ( options[0][49] == 1 ) { 
        retVal = options[0][40]; }
      else { 
       retVal = parseFloat(ShippingPrice) + parseFloat(GetWeightShipping()) + parseFloat(GetItemShipping()); }
    }
    else if ( ShippingType == 1 ) {    
      if ( options[0][72] == 1 ) { 
        retVal = options[0][41]; }
      else { 
       retVal = parseFloat(ShippingPrice) + parseFloat(GetWeightShipping()) + parseFloat(GetItemShipping()); }
    }  
    else if ( ShippingType == 2 ) {    
      if ( options[0][73] == 1 ) { 
        retVal = options[0][42]; }
      else { 
       retVal = parseFloat(ShippingPrice) + parseFloat(GetWeightShipping()) + parseFloat(GetItemShipping()); }
    }
        
    if ( FreeShipping == true ) { retVal = 0; }

    return retVal;
  }

  function GetPaymentSum() {
    return PaymentPrice;
  }

  function GetEveryItemDiscount() {
    var retVal       = 0;
    var BasketSum    = GetBasketSum();
    var RealPriceSum = GetRealPriceSum();
    retVal = parseFloat(BasketSum) - parseFloat(RealPriceSum);
    return retVal; 
  }

  function GetAmountDiscount() {
    var retVal       = 0;
    var BasketSum    = GetBasketSum();
    var Amount       = GetAmountSum();
    var IsPercent    = true;
    var PricePercent = 0;
    var DisPos = -1;
    if ( options[0][16] == 0 ) { IsPercent = false; }      
    discount_amount.sort(StartFromSort1);
    for ( var i = 0; i < discount_amount.length; i++ ) {
      if ( Amount >= discount_amount[i][1] ) {
        DisPos = i;
      }
    }
    if ( DisPos > -1 ) {
      if ( IsPercent == false ) { retVal = discount_amount[DisPos][2]; }
      else { retVal = ( BasketSum / 100.00 ) * discount_amount[DisPos][2]; }
    }
    if ( options[0][13] == 0 ) { retVal = 0; }
    return retVal;
  }

  function GetWeightDiscount() {
    var retVal       = 0;
    var BasketSum    = GetBasketSum();
    var Weight       = GetWeightSum();
    var IsPercent    = true;
    var PricePercent = 0;
    var DisPos       = -1;
    if ( options[0][17] == 0 ) { IsPercent = false; }      
    discount_weight.sort(StartFromSort1);
    for ( var i = 0; i < discount_weight.length; i++ ) {
      if ( Weight >= discount_weight[i][1] ) {
        DisPos = i;
      }
    }
    if ( DisPos > -1 ) {
      if ( IsPercent == false ) { retVal = discount_weight[DisPos][2]; }
      else { retVal = ( BasketSum / 100.00 ) * discount_weight[DisPos][2]; }
    }
    if ( options[0][14] == 0 ) { retVal = 0; }
    return retVal;
  }

  function GetPriceDiscount() {
    var retVal       = 0;
    BasketSum        = GetBasketSum();
    var IsPercent    = true;
    var PricePercent = 0;
    var DisPos       = -1;
    if ( options[0][18] == 0 ) { IsPercent = false; }      
    discount_price.sort(StartFromSort1); 
    for ( var i = 0; i < discount_price.length; i++ ) {
      if ( BasketSum >= discount_price[i][1] ) {
        DisPos = i;
      }
    }
    if ( DisPos > -1 ) {
      if ( IsPercent == false ) { retVal = discount_price[DisPos][2]; }
      else { retVal = ( BasketSum / 100.00 ) * discount_price[DisPos][2]; }
    }
    if ( options[0][15] == 0 ) { retVal = 0; }
    return retVal;
  }

  function GetItemsDiscountAmount(index, amount, price) {
    var ID        = Basket[index]["id"];
    var retVal    = 0;
    var IsPercent = true;
    var TempArray = new Array();
    var counter   = -1;
    if ( options[0][21] == 0 ) { IsPercent = false; }      

    for ( var i = 0; i < items_discount.length; i++ ) {
      if ( items_discount[i][1] == ID ) {
        counter++;
        TempArray[counter]              = new Array();
        TempArray[counter]["id"]        = items_discount[i][0];
        TempArray[counter]["parent"]    = items_discount[i][1];
        TempArray[counter]["startfrom"] = items_discount[i][2];
        TempArray[counter]["price"]     = items_discount[i][3];

      }
    }
    TempArray.sort(StartFromSortName);
    var DisPos = -1;
    for ( var i = 0; i < TempArray.length; i++ ) {
      if ( parseFloat(amount) >= parseFloat(TempArray[i]["startfrom"]) ) { DisPos = i; }
    }
    if ( DisPos > -1 ) {
      var PricePercent = TempArray[DisPos]["price"];
      if ( IsPercent == false ) { retVal = parseFloat(PricePercent); }
      else { retVal = (parseFloat(price) / 100.00) * parseFloat(PricePercent); }
    }
    return retVal;
  }

  function GetGroupsDiscount(index, amount, price) {
    var ID        = Basket[index]["id"];
    var retVal    = 0;
    var IsPercent = true;
    var DisGroup  = -1;
    var counter   = -1;
    var TempArray = new Array();
    if ( options[0][31] == 0 ) { IsPercent = false; }      

    for ( var i = 0; i < Basket.length; i++ ) {
      if ( Basket[i]["id"] == ID ) {
        DisGroup = Basket[i]["rabgroups"];
      }
    }

    for ( var i = 0; i < disgroups_list.length; i++ ) {
      if ( disgroups_list[i][1] == DisGroup ) {
        counter++; 
        TempArray[counter]              = new Array(); 
        TempArray[counter]["id"]        = disgroups_list[i][0];
        TempArray[counter]["parent"]    = disgroups_list[i][1];
        TempArray[counter]["startfrom"] = disgroups_list[i][2];
        TempArray[counter]["price"]     = disgroups_list[i][3];
      }
    }

    if ( TempArray.length > 0 ) {
      TempArray.sort(StartFromSortName);  
      var PricePercent = 0;
      for ( var i = 0; i < Basket.length; i++ ) {
        if ( Basket[i]["rabgroups"] == DisGroup && Basket[i]["id"] != ID ) {
          amount = amount + parseFloat(Basket[i]["amount"]);
        }
      }
      for ( var i = 0; i < TempArray.length; i++ ) {
        if ( amount >= TempArray[i]["startfrom"] ) {
          PricePercent = TempArray[i]["price"];
        }
      }
      if ( IsPercent == false ) { retVal = retVal + parseFloat(PricePercent); }
      else { retVal = retVal + ((parseFloat(price) / 100.00) * PricePercent); }
    }
    else { retVal = 0; }

    return parseFloat(retVal);
  }

  function GetWeightShipping() {
    var retVal       = 0;
    var fs           = false; 
    var BasketWeight = GetWeightSum();
    var BasketSum    = GetBasketSum();
    var IsPercent    = false;
    var PricePercent = 0;
   
    if ( ShippingType == 0 ) { var wei = "weight"; var shi = "shipping"; }
    else if ( ShippingType == 1 ) { var wei = "weighteu"; var shi = "shippingeu"; }
    else if ( ShippingType == 2 ) { var wei = "weightworld"; var shi = "shippingworld"; }

    var shiindex = -1;
    for ( var i = 0; i < eval(shi).length; i++ ) {
      if ( ShippingName == eval(shi)[i][1] ) {
        shiindex = eval(shi)[i][0];
      }
    }

    temp = new Array();
    counter = -1;
     for ( var i = 0; i < eval(wei).length; i++ ) {
      if ( eval(wei)[i][3] == shiindex ) {
        counter++;
        temp[counter] = new Array();
        temp[counter][0] = eval(wei)[i][0];
        temp[counter][1] = eval(wei)[i][1];
        temp[counter][2] = eval(wei)[i][2];
        temp[counter][3] = eval(wei)[i][3];
      }
    }  

    if ( ShippingType == 0 ) {
      if ( options[0][19] == 1 ) { IsPercent = true; }   }
    if ( ShippingType == 1 ) {
      if ( options[0][80] == 1 ) { IsPercent = true; }   }
    if ( ShippingType == 2 ) {
      if ( options[0][81] == 1 ) { IsPercent = true; }   }

    temp.sort(StartFromSort1);
    for ( var i = 0; i < temp.length; i++ ) {
      if ( BasketWeight >= temp[i][1] ) {
        PricePercent = temp[i][2];
      }
    }
    if ( IsPercent == false ) { retVal = PricePercent; }
    else { retVal = ( BasketSum / 100.00 ) * parseFloat(PricePercent);  }    

    return retVal;
  }

  function GetItemShipping() {
    var retVal = 0;
    for ( var i = 0; i < Basket.length; i++ ) {
      retVal = parseFloat(retVal) + ( parseFloat(Basket[i]["shipping"]) * parseFloat(Basket[i]["amount"]) ); 
    }    
    return retVal;  
  }

  function RefreshBasketContent() {
    var price   = 0;
    var blength = 0;
    for ( var i = 0; i < Basket.length; i++ ) {
      if ( Basket[i]["amount"] > 0 ) { blength++; }}
    if ( blength == 0 ) { var temp = "Keine Artikel im Warenkorb"; } 
    else {
      for ( var y=0; y < Basket.length; y++ ) {
        price = price + parseFloat(GetPriceText(Basket[y]["amount"] * Basket[y]["realprice"], Basket[y]["tax"]));
      }
      price = Round(price) + ' ' + currency;
      var temp = '<b>'+blength+'</b>&nbsp;Positionen im Warenkorb.<br>Gesamtpreis:&nbsp;<b>'+price+'</b>';    
    }
    if ( TestID("BasketDiv",0) == true ) {
      document.getElementById('BasketDiv').innerHTML = temp;
    }
  }

  function RefreshTopItems() {
    var zahl = -1;
    var le   = TopItemsArray.length - 1;
    if (TopItemsArray.length >= 2 ) {
      zahl = Math.round(Math.random() * le); }
    else if ( TopItemsArray.length == 1 ) {
      zahl = 0; }
    if ( zahl >= 0 ) {
      if ( TestID("TopItemsDiv",0) == true ) {
        document.getElementById('TopItemsDiv').innerHTML = '<center><a href="javascript:LastSeenClick('+TopItemsArray[zahl][0]+','+TopItemsArray[zahl][2]+')"><img src="'+GetTopItemsImageSrc(zahl)+'" border="0"><br><br>' + TopItemsArray[zahl][1] + '</a></center>\n'; 
      }
    }
  }

  function RefreshLastSeenContent() {
    var temp = "Keine Artikel angeschaut";
    var llength = LastSeen.length;
    if ( llength > 0 ) {
      temp = '';
      for ( var i = 0; i < llength; i++ ) {
        temp = temp + '<a href="javascript:LastSeenClick('+LastSeen[i]["id"]+','+LastSeen[i]["parent"]+')">' + LastSeen[i]["name"] + '</a><br>\n';
      }
    }
    if ( TestID("LastSeenDiv",0) == true ) {
      document.getElementById('LastSeenDiv').innerHTML = temp;
    }
  }

  function LastSeenClick(x,y) {
    itemid  = x;
    groupid = y;
    MainIFrame.location.href = "pages/item.htm"
    window.scrollTo(0, 0);
    MainIFrame.scrollTo(0, 0);
  }

  function CheckPassword() {
    if ( TestID("LoginInput",0) == true && TestID("NotLogged",0) == true && TestID("LoginBox",0) == true ) {
      var p = document.getElementById("LoginInput").value;
      if ( p == options[0][32] ) {
        protect = false;
        setTopItems();
        alert('Vielen Dank. Sie haben nun Zugriff auf alle Artikel.');
        document.getElementById('NotLogged').innerHTML = 'Sie sind nun angemeldet.';
        document.getElementById('LoginBox').style.display = 'none';
        MainIFrame.location.reload(); 
      }
      else { 
        if ( confirm('Leider ist das angegebene Passwort falsch !\nMöchten Sie sehen, wie Sie das Passwort erhalten?') ) {
          MainIFrame.location.href = "pages/login.htm"; 
          window.scrollTo(0, 0);
          MainIFrame.scrollTo(0, 0);
        }
      }
      document.getElementById('LoginInput').value = '';
    }
  }

  function Round(x) {
    var retVal = parseFloat(x);
    retVal = retVal.toFixed(2)
    return retVal;
  }

  function GetNetText() {
    var nettext = "";
    if ( options[0][30] == 0 ) {
      nettext = 'Alle Preise in&nbsp;'+currency+',&nbsp;sofern nicht anders angegeben und inklusive der gesetzlichen Mehrwertsteuer.<br>Eventuelle Rabatte und Versandkosten sind nicht berücksichtigt. Änderungen und Irrtümer vorbehalten.'; }
    else if ( options[0][31] == 1) {
      nettext = 'Alle Preise in&nbsp;'+currency+',&nbsp;sofern nicht anders angegeben und exklusive der gesetzlichen Mehrwertsteuer.<br>Eventuelle Rabatte und Versandkosten sind nicht berücksichtigt. Änderungen und Irrtümer vorbehalten.'; }
    return nettext;
  }

  function GetSecPrice(x,y) {
    var retVal = 0.00;
    if ( options[0][3] == 1 ) {
      retVal = parseFloat(x) + ((parseFloat(x) / 100.00) * parseFloat(y)); }
    else if ( options[0][3] == 0 ) {
      retVal = (100.00 * parseFloat(x)) / (100.00 + parseFloat(y)); }
    return retVal;
  }

  function VarSort(a,b) {
    return a - b;
  }

  function SortPrice(p,x) {
    return  p + parent.MainIFrame.GetMinVarPrice(x);    
  }

  function SortItems(a,b) {    
    if ( itemindex == "nameup" || itemindex == "namedown" ) {
      if ( a[1] > b[1] == true ) { return 1; }
      else if ( a[1] < b[1] == true ) { return -1; }
      else if ( a[1] == b[1] == true ) { return 0; }
    }
    else if ( itemindex == "noup" || itemindex == "nodown" ) {
      if ( a[2] > b[2] == true ) { return 1; }
      else if ( a[2] < b[2] == true ) { return -1; }
      else if ( a[2] == b[2] == true ) { return 0; }
    }
    else if ( itemindex == "priceup" || itemindex == "pricedown" ) { 
      var p1 = SortPrice(a[3],a[0]);
      var p2 = SortPrice(b[3],b[0]);
      return (p1 - p2);
    }
  }

  function fillPage() {
   var sorti = options[0][63];
   if ( sorti == 1 ) { itemindex = "nameup"; }
   if ( sorti == 2 ) { itemindex = "noup"; }
   if ( sorti == 3 ) { itemindex = "priceup"; }
    var temp = ""; 
    temp = company[0][22];
    if ( temp == "" ) {
      temp = company[0][0]; }
    if ( temp == "" && company[0][1] && company[0][2]) {
      temp = company[0][1] + ' ' +company[0][2]; }
    if ( temp != "") {
      if ( TestID("cpr",0) == true ) {
        document.getElementById('cpr').innerHTML = 'copyright&nbsp;'+temp; 
      }
    }
    if ( TestID("CompanyName",0) == true && TestID("CompanySloagan",0) == true ) {
      document.getElementById('CompanyName').innerHTML = company[0][0];
      document.getElementById('CompanySloagan').innerHTML = company[0][21];
    }

    if ( options[0][1] == 1 ) {
      if ( TestID("LoginBox",0) == true ) {
        document.getElementById("LoginBox").style.display = "block"; }
    }

    ListReport = options[0][23];
    currency = options[0][5];
    OwnerCountry = company[0][8].toLowerCase();
  }

  function HasChildren(x) {
    var Result = false;
    for ( var i = 0; i < groups.length; i++) {
      if ( groups[i][2] == x ) {
        Result = true;
      }
    }
    return Result;
  }

  function GetParentLevel(x) {
    var level = -1;
    for ( var i = 0; i < groups.length; i++) {
      if ( groups[i][0] == x ) {
        level = groups[i][11];
      }
    }
    level++;
    return level;
  }

  function GetParentIndex(x) {
    var retVal = -1;
    for ( var i = 0; i < groups.length; i++) {
      if ( groups[i][0] == x ) {
        retVal = i;
      }
    }
    return retVal;
  }

  function clickGroup(index,y) {
    pageno        = 1;
    var start     = -1;
    var ende      = -1;
    var level     = -1;
    groupid       = groups[index][0];
    var cgname    = groups[index][1];
    var start     = index;
    groindex      = index;
    var level     = groups[index][11]; 
    groname       = new Array();
    var z         = groups[index][12];

    for ( var i=0; i < level; i++ ) {
      groname[i] = groups[z][1];
      if ( i < level-1) {
        z = groups[z][12]; }
    }
    groname.reverse();
    groname[groname.length] = cgname;

// Keine Untergruppen
    if ( groups[index][14] == "file" ) { 
      if ( y == 1 ) {
        if ( ListReport == 0 ) { NextPage = 'list.htm'; MainIFrame.location.href = "loader.htm"; window.scrollTo(0, 0); MainIFrame.scrollTo(0, 0); }
        else if ( ListReport == 1 ) { NextPage = 'report.htm'; MainIFrame.location.href = "loader.htm"; window.scrollTo(0, 0); MainIFrame.scrollTo(0, 0); }
      }
      else {
        if ( ListReport == 0 ) { NextPage = 'list.htm'; MainIFrame.location.href = "pages/loader.htm"; window.scrollTo(0, 0); MainIFrame.scrollTo(0, 0); }
        else if ( ListReport == 1 ) { NextPage = 'report.htm'; MainIFrame.location.href = "pages/loader.htm"; window.scrollTo(0, 0); MainIFrame.scrollTo(0, 0); }
      }
    }

// Untergruppen sind zu sehen
    else if ( groups[start][14] == "open" ) { 
      document.getElementById('menu_'+start).src = "images/plus.gif";
      groups[index][14] = "close";
      start++;
      var b = false;
      for ( var i = start; i < groups.length; i++ ) {
         if ( level >= groups[i][11] && b == false ) {
           ende = i;
           b = true;
         }
      } 

      if ( b == false && groups[groups.length - 1][11] > 0 ) {
        ende = groups.length;
      }

      for ( var i = start; i < ende; i++ ) {
        if ( groups[i][14] == "open" ) {
          groups[i][14] = "close"; 
          document.getElementById('menu_'+i).src = "images/plus.gif";
        }
        groups[i][15] = false;
        document.getElementById("gr_"+groups[i][0]).style.display = "none";    
      }   
      if ( y == 1 ) {
        if ( ListReport == 0 ) { NextPage = 'list.htm'; MainIFrame.location.href = "loader.htm"; window.scrollTo(0, 0); MainIFrame.scrollTo(0, 0); }
        else if ( ListReport == 1 ) { NextPage = 'report.htm'; MainIFrame.location.href = "loader.htm"; window.scrollTo(0, 0); MainIFrame.scrollTo(0, 0); }
      }
      else {
        if ( ListReport == 0 ) { NextPage = 'list.htm'; MainIFrame.location.href = "pages/loader.htm"; window.scrollTo(0, 0);MainIFrame.scrollTo(0, 0); }
        else if ( ListReport == 1 ) { NextPage = 'report.htm'; MainIFrame.location.href = "pages/loader.htm"; window.scrollTo(0, 0);MainIFrame.scrollTo(0, 0); }
      }
    }
// Untergruppen sind verborgen
    else if ( groups[start][14] == "close" ) { 
      document.getElementById('menu_'+start).src = "images/minus.gif";
      groups[index][14] = "open";
      for ( var i = 0; i < groups.length; i++ ) {
        if ( groups[i][2] == groupid && groups[i][7] == 1 ) {
          groups[i][15] = true;
          document.getElementById("gr_"+groups[i][0]).style.display = "block";
        }
      }
      if ( y == 1 ) {
        if ( ListReport == 0 ) { NextPage = 'list.htm'; MainIFrame.location.href = "loader.htm"; window.scrollTo(0, 0);MainIFrame.scrollTo(0, 0); }
        else if ( ListReport == 1 ) { NextPage = 'report.htm'; MainIFrame.location.href = "loader.htm"; window.scrollTo(0, 0);MainIFrame.scrollTo(0, 0); }
      }
      else {
        if ( ListReport == 0 ) { NextPage = 'list.htm'; MainIFrame.location.href = "pages/loader.htm"; window.scrollTo(0, 0);MainIFrame.scrollTo(0, 0); }
        else if ( ListReport == 1 ) { NextPage = 'report.htm'; MainIFrame.location.href = "pages/loader.htm"; window.scrollTo(0, 0);MainIFrame.scrollTo(0, 0); }
      }
    }
  }

  function setTopItems() {
    for ( var i = 0; i < items.length; i++ ) {
      if ( items[i][24] == 1 ) {
        if ( protect == false || items[i][23] == 0 ) {
          var ipa = items[i][6];
          var b = false;
          for ( var y = 0; y < groups.length; y++ ) {
            if ( groups[y][0] == ipa ) {
              if (groups[y][7] == 1 ) {
                b = true;
              }
            }
          }
          if (b == true) {
            var tial = TopItemsArray.length;
            TopItemsArray[tial] = new Array();
            TopItemsArray[tial][0] = items[i][0];
            TopItemsArray[tial][1] = items[i][1];
            TopItemsArray[tial][2] = items[i][6];
            TopItemsArray[tial][3] = items[i][12];
            TopItemsArray[tial][4] = items[i][16];
            TopItemsArray[tial][5] = items[i][13];
            TopItemsArray[tial][6] = items[i][17];
          }
        }
      }
    }
    if ( TopItemsArray.length > 0 ) {
      if ( TestID("TopItemsBox",0) == true ) {
        document.getElementById("TopItemsBox").style.display = "block"; 
      }
      RefreshTopItems();
    }
  }

  function createMenu() {  
    for ( var i = 0; i < groups.length; i++) {
      if ( groups[i][2] == 0 || groups[i][2] == -1 ) { 
        groups[i][11] = 0; 
        groups[i][12] = -1; 
      }
      else { 
        groups[i][11] = GetParentLevel(groups[i][2]); 
        groups[i][12] = GetParentIndex(groups[i][2]); 
      }
    }
    for ( var i = 0; i < groups.length; i++ ) {
      groups[i][13] = HasChildren(groups[i][0]); }
    for ( var i = 0; i < groups.length; i++ ) {
      if ( groups[i][13] == true ) {
        groups[i][14] = "close"; }
      else { 
        groups[i][14] = "file"; }
    }
    for ( var i = 0; i < groups.length; i++ ) {
      if ( groups[i][2] == -1 || groups[i][2] == 0) {
        groups[i][15] = true; }
      else {
        groups[i][15] = false; }
    } 

    var temp = '';
    for ( var i = 0; i < groups.length; i++ ) {
      if ( groups[i][14] == "file") { 
        prefix = '<img src="images/clear.gif" border="0" id="menu_'+i+'" style="margin-right:1px; margin-left:1px; width:10px; height:10px;">'; }
      else { 
        prefix = '<img src="images/plus.gif" border="0" id="menu_'+i+'" style="margin-right:1px; margin-left:1px;">'; }        

      var lv = '';
      for ( var z = 0; z < groups[i][11]; z++) { lv = lv + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; }
      if ( groups[i][15] == true && groups[i][7] == 1 ) {
        temp = temp + '<div id="gr_'+groups[i][0]+'" style="display:block;">'+lv+'<a href="javascript:clickGroup('+i+',0)" style="width:100%" onmouseover="status=\' \';return true;">'+prefix+' '+groups[i][1]+'</a></div>\n';
      }         
      else {
        temp = temp + '<div id="gr_'+groups[i][0]+'" style="display:none;">'+lv+'<a href="javascript:clickGroup('+i+',0)" style="width:100%" onmouseover="status=\' \';return true;">'+prefix+' '+groups[i][1]+'</a></div>\n';
      }
    } 
    if ( TestID("MenuDiv",0) == true ) {
      document.getElementById('MenuDiv').innerHTML = temp;
    }
  }

  function preload() {
    MainIFrame.location.replace("pages/preload.htm");
  }

