// -------------------------------------------------- Netscape Resize Fix (wg. der Style Sheets)

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// -------------------------------------------------- Open centered window
// Aufrufender Link: <a href="javascript:OpenBrWindow(800,600,'dateiname.htm','fenstername')">Link</a>

function OpenBrWindow(x,y,theURL,winName) {
    var x;
    var y;
    
    ScreenWidth = screen.width;
    ScreenHeight = screen.height;
    
    xpos = (ScreenWidth/2)-(x/2);
    ypos = (ScreenHeight/2.3)-(y/2);
    
    features = "width=" + x + ",height=" + y + ",location=no,menubar=no,personalbar=no,resizable=no,screenX=" + xpos + ",screenY=" + ypos + ",left=" + xpos + ",top=" + ypos + ",locationbar=no,scrollbars=no,directories=no,statusbar=no,toolbar=no";
    
    window.open(theURL,winName,features);
}


// -------------------------------------------------- Open centered window 2
// Aufrufender Link: <a href="javascript:OpenBrWindow2(800,600,'dateiname.htm','fenstername')">Link</a>
// Mit Menubar (Drucken) und Srollbars

function OpenBrWindow2(x,y,theURL,winName) {
var x;
var y;

ScreenWidth = screen.width;
ScreenHeight = screen.height;

xpos = (ScreenWidth/2)-(x/2);
ypos = (ScreenHeight/2.3)-(y/2);

features = "width=" + x + ",height=" + y + ",location=no,menubar=yes,personalbar=no,resizable=no,screenX=" + xpos + ",screenY=" + ypos + ",left=" + xpos + ",top=" + ypos + ",locationbar=no,scrollbars=yes,directories=no,statusbar=no,toolbar=no";

window.open(theURL,winName,features);
}


// -------------------------------------------------- Weitere Funktionen

/////////////////////////DHTML for Image////////////////

n=(document.layers)?true:false;

function imgDiv(name,src)
{
  if(n) document.layers['mainpic'].document.images[name].src = src;
  else document.images[name].src = src;
}

/////////////////////////end DHTML for Image////////////



///////////////////////// SUCHE ////////////////

   function extSearchWin(url){
      title = 'globalSearch';
      sizeH = 780;
      sizeV = 550;
      extWinHandle = top.open(url,title,'toolbar=yes,directories=no,status=yes,scrollbars=yes,menubar=yes,resizable=yes,screenY=10,alwaysRaised=yes,width='+sizeH+',height='+sizeV);
      if(navigator.appVersion.indexOf("MSIE 3",0)==-1) id = setTimeout('extWinHandle.focus()',1000);
   }

   

// ------------------------------
// -- test valid Email         --
// ------------------------------
function isEmail(str)
{
    var atLoc,dotLoc,len,i,ch;
    
    atLoc = str.indexOf('@');
    dotLoc = str.lastIndexOf('.');
    len = str.length;  
    
    //- @ vorhanden
    //- mindestens 1 buchstabe vor dem @
    if (atLoc < 1) return false;

    //- punkt hinter dem @ 
    //- mindestens 1 buchstabe zwischen @ und .
    if (dotLoc - atLoc < 2) return false;

    //- mindestens 1 buchstabe nach dem .
    if (dotLoc >= len-1) return false;

    return true;
}

// ------------------------------
// -- Test String Chars/Length --
// ------------------------------
function testString(string, check, lang)
{
  if (lang)
    if ((string.length)<lang)
      return false;

  for (i=0; i<string.length; i++)
  {
    if (check.indexOf(string.charAt(i))==-1)
    return false;
  }
  return true;
}


// Kategoriesuche, level=1 oder 2
function searchCategories(level, param) 
{
    var form = document.CatSearch;

	if (form.elements["CatLevel"+level+"ID"].selectedIndex!=0 && form.elements["CatLevel"+level+"ID"].options[form.elements["CatLevel"+level+"ID"].selectedIndex].defaultSelected == false) 
	{
        if (param) {
			trenner = "?";
			if ( form.action.indexOf("?")>= 0 ) trenner = "&";
            form.action=form.action + trenner + "CatLevel" + level + "ID=" + form.elements["CatLevel"+level+"ID"].options[form.elements["CatLevel"+level+"ID"].selectedIndex].value;
        }

        form.method="POST";

		form.submit();
	}
}

// Selectboxen MenuID-Jump
function jumptoMenuID(selectbox,languageID)
{
	var form 			= selectbox.form;
	var selectedValue	= selectbox.options[selectbox.options.selectedIndex].value;
	if	(selectedValue == "") {
			form.reset();
			selectbox.blur();
			return;
	} else {
			top.location.href = "../../menu/"+selectedValue+"_l"+languageID+"/index.html";
			selectbox.blur();
	}
}
// opens Microsite in Browser without URL Field, Buttons ans Menus
//this function is further on only used by the top-level flash
function OpenMicrositeWindow(ID) {

    x = Math.min(1015,screen.availWidth-10);
    y = Math.min(700,screen.availHeight-6);
    
    xpos = (screen.availWidth-(x + 10)) /2;
    ypos = (screen.availHeight-(y + 36)) /2;

    properties = "width=" + x + ",height=" + y + ",location=no,menubar=no,personalbar=no,resizable=no,screenX=" + xpos + ",screenY=" + ypos + ",left=" + xpos + ",top=" + ypos + ",locationbar=no,scrollbars=yes,directories=no,statusbar=no,toolbar=no";
    window.open('../../menu/'+ID+'/index.html','Microsite',properties).focus();
}

//new function to allow authors to determine window size and name
function openMicrositeWindow2(x,y,theURL,winName) {

  xmin = Math.min(x,screen.availWidth-10);
  ymin = Math.min(y,screen.availHeight-36);

  xpos = (screen.availWidth-(xmin+10))/2;
  ypos = (screen.availHeight-(ymin+36))/2;

  properties = "width=" + xmin + ",height=" + ymin + ",location=no,menubar=no,personalbar=no,resizable=no,screenX=" + xpos + ",screenY=" + ypos + ",left=" + xpos + ",top=" + ypos + ",locationbar=no,scrollbars=yes,directories=no,statusbar=no,toolbar=no";
    
  window.open(theURL,winName,properties).focus();
}

 function showAdressTable(divTag) {
        var div = document.getElementById(divTag);
					if(document.handelsweltenBestellung.receivadress.checked==true){
        		div.style.display="inline";
							}
        else {
        	div.style.display = "none";
					}       	
     }

