function popup(url)
{
   newPopup = window.open(url, "", "width=700, height=500, top=50, left=50, location=yes, menubar=yes, toolbar=yes, status=yes, scrollbars=yes, resizable=yes");
}

/*
 * Gibt die Breite zurueck, nach der die Angebotsboxen
 * von alleine umbrechen (weil "#content" eben nicht
 * breit genug ist fuer alle Angebotsboxen)
 */
function getOptimaleAngebotsContainerBreite()
{
   // Breite von 'content' abzueglich (padding-left + padding-right)
   var contentWidth = xWidth("content");
   // Breite einer Angebotsbox (inclusive 'border-left' & 'border-right', 'padding-left' & 'padding-right' UND 'margin-left' & 'margin-right' einer Angebotsbox!)
   var angebotWidth = 179;
   // Wie oft passt eine Angebotsbox in '#content'
   var angebotCount =  parseInt(contentWidth/angebotWidth);
   // + evtl. 'border-left' bzw. 'border-right' des Angebotscontainers
   var optimaleBreite = angebotCount*angebotWidth;

   // Dem Footer die Breite vom Content zuweisen, damit kein Scrollbalken entsteht
   xWidth("contentFt",contentWidth);
   // Dem Link- und Adressblock auch noch die Breite der linken Spalte (soll ueber ganze Breite gehen)
   xWidth("nav",(contentWidth + 160));
   xWidth("adr",(contentWidth + 190));

   return optimaleBreite;
}

/*
 * @param string  container   Die CSS-ID des zu pruefenden Containers
 * @param int     padTop      das "padding-top" des zu pruefenden Containers
 * @param int     padBot      das "padding-bottom" des zu pruefenden Containers
 *
 **/
function applyPositioningFix(container, padTop, padBot)
{
   var containerHeight = xHeight(container);
   if ( containerHeight%2 != 0 )
   {
      var newHeight = containerHeight - padTop - padBot + 1;
      document.getElementById(container).style.height = newHeight;
   }
}

// -------------- dieses Script passt die Hoehe von "rechteSpalte" automatisch an ----------------
function adjustLayout()
{
   // --------------------------------------------------------------------------------------------
   // Die Anpassung (zB Höhe & Breite) von Objekten im Quelltext
   // muss VOR der Spaltenhöhenanpassung erfolgen!
   // --------------------------------------------------------------------------------------------

   var optimaleBreite = getOptimaleAngebotsContainerBreite();

   if ( document.getElementById("katAC") != null )
   {
      xWidth("katAC",optimaleBreite);
   }
   if ( document.getElementById("microAG") != null )
   {
      xWidth("microAG",optimaleBreite);
   }

   // Die 2 Hoehen der 2 Haupt-Container der Produktdetails angleichen...
   if ( document.getElementById("pageBox") != null )
   {
      // JavaScript ist aktiviert, also kann die fuer den gegeteiligen Fall festgelegte Hoehe ueberschrieben werden
      document.getElementById("PBRight").style.height = "auto";
      document.getElementById("PBLeft").style.height = "auto";

      var infoHeight = xHeight("PBRight");
      var descHeight = xHeight("PBLeft");
      var maxHeight = Math.max(infoHeight, descHeight)
      xHeight("PBRight", maxHeight);
      xHeight("PBLeft", maxHeight);
   }

   // --------------------------------------------------------------------------------------------
   // Die Anpassung (zB Höhe & Breite) von Objekten im Quelltext
   // muss VOR der Spaltenhöhenanpassung erfolgen!
   // ------------------------------------------------------------------------------------- (Ende)

   //Ermitteln der Hoehe von "linkeSpalte" (inkl. linkem FooterBG) und "content"
   var linkeSpalteHeight = xHeight("linkeSpalte") + xHeight("footerBG01");
   var contentHeight = xHeight("content");

   //Ermitteln der groessten Hoehe
   var maxHeight = Math.max(linkeSpalteHeight,contentHeight);

   //Zuweisen der groessten Hoehe
   xHeight("linkeSpalte",(maxHeight + xHeight("contentNav") - xHeight("footerBG01")));
   xHeight("content",maxHeight);

   applyPositioningFix("content", 30, 60);
   applyPositioningFix("linkeSpalte", 0, 0);
}

window.onload = function()
{
   xAddEventListener(window, "resize", adjustLayout, false );
   adjustLayout();
   // -------------- dieses Script passt die Hoehe von "rechteSpalte" automatisch an ----------------
   // IE-Button-Hover (Anfang)
   //
   // die folgende "if" - Anw. testet ob Browser ein IE5+ ist!
   if (document.all&&document.getElementById)
   {
      // "buttons" ist ein Array aller im document befindlichen Buttons
      var buttons = document.getElementsByTagName("button");
      for (i=0; i<buttons.length; i++)
      {
         buttons[i].onmouseover=function()
         {
            if("button2" != this.className && "rechtsMittel" != this.className)
            {
               this.className+="HoverIE";
            }
         }
         buttons[i].onmouseout=function()
         {
            if("button2" != this.className && "rechtsMittel" != this.className)
            {
               this.className=this.className.replace("HoverIE", "");
            }
         }
      }
   }
   // IE-Button-Hover (Ende)
}

// Bestsella-Funktion
function bestscout(page)
{
   window.open("https://www.bestscout.com/bestScout/userlogin?unit=apobyte&lp="+page, "sppopup", "width=400,height=255,noresize");
   window.name = 'ScreenPilotMainFrame';
   return;
}

// dateCheck Funktion
// Diese Funktion generiert bei einer Datumseingabe per Select Box, die Select Box fuer die Tage, nach der Auswahl des Monates bzw Jahres automatisch
function dateCheck(tag_id, monat_id, jahr_id)
{
   var tag = tag_id.value;
   var monat = monat_id.value;
   var jahr = jahr_id.value;

   // Ausgewähltes Jahr ein Schaltjahr?
   var schaltjahr = false;
   var schaltjahr_string = new String(jahr / 4);
   if (-1 == schaltjahr_string.indexOf("."))
   {
      schaltjahr = true;
   }

   if(4 == monat || 6 == monat || 9 == monat || 11 == monat) // Monat mit 30 Tagen
   {
      // Loescht Tag 31 und fügt 29 und 30 neu ein
      tag_id.options[31] = null;
      tag_id.options[30] = new Option("30", "30", false, false);
      tag_id.options[29] = new Option("29", "29", false, false);
      if(tag <= 30 && tag >= 1) { tag_id.options[tag] = new Option(tag, tag, false, true); } // Selected einen vorher ausgewählten Tag innerhalb der neuen Tages"Range"
   }
   else if(02 == monat) // Februar mit 28 bzw 29 Tagen
   {
      // Je nach Schaltjahr 29 oder 28 Tage
      if( schaltjahr )
      {
         // Fuegt Tag 29 ein und loescht 30 und 31
         tag_id.options[31] = null;
         tag_id.options[30] = null;
         tag_id.options[29] = new Option("29", "29", false, false);
         if(tag <= 29 && tag >= 1) { tag_id.options[tag] = new Option(tag, tag, false, true); } // Selected einen vorher ausgewählten Tag innerhalb der neuen Tages"Range"
      }
      else
      {
         // Loescht Tag 29,30 und 31
         tag_id.options[31] = null;
         tag_id.options[30] = null;
         tag_id.options[29] = null;
         if(tag <= 28 && tag >= 1) { tag_id.options[tag] = new Option(tag, tag, false, true); } // Selected einen vorher ausgewählten Tag innerhalb der neuen Tages"Range"
      }
   }
   else  // Monat mit 31 Tagen
   {
      tag_id.options[31] = new Option("31", "31", false, false);
      tag_id.options[30] = new Option("30", "30", false, false);
      tag_id.options[29] = new Option("29", "29", false, false);
      if(tag <= 31 && tag >= 1) { tag_id.options[tag] = new Option(tag, tag, false, true); } // Selected einen vorher ausgewählten Tag innerhalb der neuen Tages"Range"
   }
}

function paypalTimedRedirect()
{
   var secs = parseInt($('#seconds').html());
   if(secs <= 0)
   {
      return $('#paypalForm').submit();
   }
   $('#seconds').html((secs -1));
   window.setTimeout("paypalTimedRedirect()", 1000);
}
