//*******************************************************************************
// Fenster neu laden wenn Netscape resized wird
//*******************************************************************************

function reloadPage(init) {
if (init == true) with (navigator) {
  if ( (appName == "Netscape") && (parseInt(appVersion) == 4) ) {
    document.pgW = innerWidth;
    document.pgH = innerHeight;
    onresize = reloadPage;
  }
}
else if ( innerWidth != document.pgW || innerHeight != document.pgH)
  location.reload();
}
reloadPage(true);

//*******************************************************************************
//  Neues Fenster mit angegebenen Parametern oeffnen
//  ACHTUNG: Hierbei wird der Name des Originalfensters auf "main" gesetzt !!
//*******************************************************************************
function openWindow(theURL,winName,features)
{
  window.name = "main";
  window.open(theURL,winName,features);
}

//*******************************************************************************
//  Neues Fenster mit angegebenen Parametern oeffnen
//  ACHTUNG: Hierbei wird der Name des Originalfensters auf "sitemap" gesetzt !!
//*******************************************************************************
function openWindowFromSitemap(theURL,winName,features)
{
  window.name = "sitemap";
  window.open(theURL,winName,features);
}

//*******************************************************************************
// This function is needed for CMS links, do not change!
//*******************************************************************************
function openPopup(href, window_name, width, height, is_resizable, show_scrollbars, show_menubar, show_statusbar) {
    if (!window_name || window_name == "") window_name = "popup";
    window_name = window_name.replace(/ /g, "_"); // ... window_name must not contain spaces
    var features = '';
    if (is_resizable) {
        features += ',resizable=yes'
    } else {
        features += ',resizable=no'
    }
    if (show_scrollbars) {
        width = parseInt(width) + 16; // ... the vertical scrollbar does need some place for itself
        features += ',scrollbars=yes'
    } else {
        features += ',scrollbars=no'
    }
    if (show_menubar) {
        features += ',menubar=yes'
    } else {
        features += ',menubar=no'
    }
    if (show_statusbar) {
        features += ',status=yes'
    } else {
        features += ',status=no'
    }
    features = 'width=' + width + ',height=' + height + features + ',dependent=yes,toolbar=no,location=no,directories=no';
    var popup = window.open(href, window_name, features);
    popup.focus();
}

//*************************************************************************
//  Bilder fuer MouseOvers vorausladen
//*************************************************************************
function preloadImages() 
{ 
  if(document.images)
  {
    if (!document.preload) 
      document.preload = new Array();
    var i, j = document.preload.length, a = preloadImages.arguments; 
    for(i = 0; i < a.length; i++)
      if ( a[i].indexOf("#") != 0 )
      { 
        document.preload[j] = new Image; 
        document.preload[j++].src = a[i];
      }
  }
}

//*************************************************************************
//  Funktion fuer MouseOvers 
//*************************************************************************
function swapImage() 
{ 
  var i, j = 0, x, a = swapImage.arguments; 
  document.sr = new Array; 
  for ( i=0; i < (a.length-2); i+=3 )
    if ( ( x = findObj(a[i]) ) != null )
    {
      document.sr[j++] = x; 
      if (!x.oSrc) 
        x.oSrc = x.src; 
        x.src = a[i+2];
    }
}

//*************************************************************************
//  Funktion fuer MouseOut 
//*************************************************************************
function swapImgRestore() 
{ 
  var i, x, a = document.sr; 
  for ( i = 0; a && i < a.length && (x=a[i]) && x.oSrc;i++) 
    x.src=x.oSrc;
}

//*************************************************************************
//  Allgemeines Script zur Bestimmung enthaltener Objekte im Dokument
//*************************************************************************
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

//*************************************************************************
//  Funktionen für die Produktsuche
//*************************************************************************
function submitSearch(openMarke, anchor, markeIdParam, actionUrl) {
    var formRef = document.forms[0];
    if (openMarke >= 0) {
        formRef.elements['openMarke'].value = openMarke;
    }
    if (markeIdParam > 0) {
        formRef.elements['marke_id'].value = markeIdParam;
    }
    setFormAction(formRef, actionUrl);
    if (openMarke >= 0) {
        formRef.action = formRef.action + "#marke_id_" + anchor;
    }
    formRef.submit();
}
function setFormAction(formRef, actionUrl) {
    formRef.action = actionUrl;
}
