function resize2(w,h) {
 if (parseInt(navigator.appVersion)>3) {
   if (navigator.appName=="Netscape") {
    top.outerWidth=w;
    top.outerHeight=h;
   }
   else top.resizeTo(w,h);
 }
}

function checkSearchString() {
        fr = document.forms["sucheForm"];
        fr2 = document.forms["sucheFormHidden"];
        searchString = fr.elements["searchval"].value.toLowerCase();
        searchString = searchString.replace(/^\s+/, '');
        searchString = searchString.replace(/\s+$/, '');
       // searchKat= fr.elements["searchThis"].value;
        firstLetter=searchString.substring(0,1);
        if (firstLetter!="+"){
           if (firstLetter!="-"){
            //  searchString="+"+searchString;
           }
        }

        if(searchString.length < 2) {
                alert("Sie müssen mindestens zwei Zeichen eingeben,\num ein Suchergebnis zu erhalten.");
        }
        else {
           fr2.elements["searchval"].value=searchString;
           if(fr.elements["searchNav"].checked==true){
           	   navse=fr.elements["searchNav"].value;
           	   fr2.elements["searchNav"].value=navse;
          }
           fr2.submit();
        }
}

function open_NW(adr,winName,screenwidth,screenheight) {
     screenwidth+=20;screenheight+=20;
     if (screenwidth<(screen.availWidth/2)) {
        xPos = screen.availWidth/2 - screenwidth -10;
     } else {
        xPos = screen.availWidth - screenwidth -10;
     }
     if (screenheight<(screen.availHeight/2)) {
        yPos = screen.availHeight/2 - screenheight -10;
     } else {
        yPos = screen.availHeight - screenheight -10;
     }
     var NW = window.open(adr,winName,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width="+screenwidth+",height="+screenheight+",screenX="+xPos+",screenY="+yPos+",left="+xPos+",top="+yPos);
     NW.focus();
return
}


function katalog(ausf,kat_id){
   var nam = 'w' + ausf;
   var para = '';
   if (document.layers){
      para += 'outerWidth=' + screen.availWidth + ',outerHeight=' + screen.availHeight;
      para += ',screenX=' + screen.availLeft + 'screenY=' + screen.availTop;
   }else
      if (document.all)
         para += 'width=' + screen.availWidth + ',height=' + screen.availHeight;
      else
         para += 'width=500,height=400';
   if (ausf)
      para += 'resizable=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,toolbar=1';
   else
      para += 'resizable=1,location=0,directories=0,status=0,menubar=0,scrollbars=0,toolbar=0';
      link='./katalog/index.php?kat_id='+kat_id;
   neu = window.open(link,nam,para)
   if (document.all){
      neu.resizeTo(screen.availWidth,screen.availHeight)
      neu.moveTo(0,0)
   }
   neu.focus();
}

var temp, temp2, cookieArray, cookieArray2, cookieCount;

function initiate(){
  cookieCount=0;
  if(document.cookie){
    cookieArray=document.cookie.split(";");
    cookieArray2=new Array();
    for(i in cookieArray){
      cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,"");
    }
  }
  cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array();
  temp=document.getElementById("containerul");
  for(var o=0;o<temp.getElementsByTagName("li").length;o++){
    if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){
      temp2                                = document.createElement("span");
      temp2.className                        = "symbols";
      temp2.style.backgroundImage        = (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(http://"+location.host+"/images/listimage.gif)":"url(http://"+window.location.host+"/images/dropdown.gif)"):"url(http://"+window.location.host+"/images/dropdown.gif)";
      temp2.onclick=function(){
        showhide(this.parentNode);
        writeCookie();
      }
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)
      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";
      if(cookieArray[cookieCount]=="true"){
        showhide(temp.getElementsByTagName("li")[o]);
      }
      cookieCount++;
    }
    else{
      temp2                                = document.createElement("span");
      temp2.className                        = "symbols";
      temp2.style.backgroundImage        = "url(http://"+location.host+"/images/listimage.gif)";
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild);
    }
  }
}



function showhide(el){
  el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block";
  el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(http://"+window.location.host+"/images/dropup.gif)":"url(http://"+window.location.host+"/images/dropdown.gif)";
}



function writeCookie(){                // Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie.
  cookieArray=new Array()
  for(var q=0;q<temp.getElementsByTagName("li").length;q++){
    if(temp.getElementsByTagName("li")[q].childNodes.length>0){
      if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){
        cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block");
      }
    }
  }
  document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString();
}


function CheckLen(formular, ziel, maxlength, output){
	fr = document.forms[formular];
	val=document.getElementById(ziel).value
	//alert(val);
	StrLen=val.length;
	if (StrLen==1&&val.substring(0,1)==" "){
	document.getElementById(ziel).value=""; 
	StrLen=0;
	}
	if (StrLen>maxlength ){
	document.getElementById(ziel).value=val.substring(0,maxlength);
	CharsLeft=0;
	}else{
	CharsLeft=maxlength-StrLen;
	}
	fr.elements[output].value=CharsLeft;
}