function showfilter(zielId){
		ziel = document.getElementById(zielId);
		if (ziel.style.display == "none"){
			ziel.style.display = "";
			x1 = document.getElementById("downloadsfilterlink");
			if (window.location.search.indexOf("&L=1") == -1){
				x1.innerHTML = "zus&auml;tzliche Optionen ausblenden";
			}else{
				x1.innerHTML = "Hide additional options";
				}	
		}else{
			ziel.style.display = "none";
			x1 = document.getElementById("downloadsfilterlink");
			if (window.location.search.indexOf("&L=1") == -1){
				x1.innerHTML = "zus&auml;tzliche Optionen einblenden";
			}else{
				x1.innerHTML = "Show additional options";
				}
		}
}
function checkallsubmit(){
	//alert('es wird aufgerufen');
	document.getElementById("fiftyormore1").checked=true;
	//document.downloadsfilterform.submit();
	document.getElementById("submitdownloads").click();
	}

function sortandsend_titel(){
	document.getElementById("oesorting0").checked=true;
	//document.downloadsfilterform.submit();
	if (document.getElementById("sortdir").value == 1){	
		document.getElementById("sortdir").value=0;
	} else {	
		document.getElementById("sortdir").value=1;
	}
	document.getElementById("submitdownloads").click();
	}

function sortandsend_dokumentkategorie(){
	document.getElementById("oesorting1").checked=true;
	//document.downloadsfilterform.submit();
	if (document.getElementById("sortdir").value == 1){	
		document.getElementById("sortdir").value=0;
	} else {	
		document.getElementById("sortdir").value=1;
	}	
	document.getElementById("submitdownloads").click();
	}

function sortandsend_dokument(){
	document.getElementById("oesorting2").checked=true;
	//document.downloadsfilterform.submit();
	if (document.getElementById("sortdir").value == 1){	
		document.getElementById("sortdir").value=0;
	} else {	
		document.getElementById("sortdir").value=1;
	}	
	document.getElementById("submitdownloads").click();
	}

	
function showakt(zielId ){	
		ziel = document.getElementById( zielId  );	
		if((document.getElementById("update3").checked==true) || (document.getElementById("update4").checked==true)){	
			ziel.style.display = "";
		}else{
			ziel.style.display = "none";
		}
}
			
function showzuordng( ){	
		if(document.getElementById("allocation0").checked==true){				
			document.getElementById("erregergruppe").style.display ="none";
			document.getElementById("erreger").style.display = "none";
			document.getElementById("produkt").style.display = "none";
			document.getElementById("produktlinie").style.display = "none";
			document.getElementById("nexth2hide").style.display = "none";
			document.getElementById("anderesprodukt").style.display = "none";
		}
		else if (document.getElementById("allocation1").checked==true){
			document.getElementById("erregergruppe").style.display = "";
			document.getElementById("erreger").style.display = "none";
			document.getElementById("produkt").style.display = "none";
			document.getElementById("produktlinie").style.display = "none";
			document.getElementById("nexth2hide").style.display = "";
			document.getElementById("anderesprodukt").style.display = "none";
		}
		else if (document.getElementById("allocation2").checked==true){
			document.getElementById("erregergruppe").style.display = "none";
			document.getElementById("erreger").style.display = "";
			document.getElementById("produkt").style.display = "none";
			document.getElementById("produktlinie").style.display = "none";
			document.getElementById("nexth2hide").style.display = "";
			document.getElementById("anderesprodukt").style.display = "none";
		}
		else if (document.getElementById("allocation3").checked==true){
			document.getElementById("erregergruppe").style.display = "none";
			document.getElementById("erreger").style.display = "none";
			document.getElementById("produkt").style.display = "";
			document.getElementById("produktlinie").style.display = "none";
			document.getElementById("nexth2hide").style.display = "";
			document.getElementById("anderesprodukt").style.display = "none";
		}
		else if (document.getElementById("allocation4").checked==true){
			document.getElementById("erregergruppe").style.display = "none";
			document.getElementById("erreger").style.display = "none";
			document.getElementById("produkt").style.display = "none";
			document.getElementById("produktlinie").style.display = "";
			document.getElementById("nexth2hide").style.display = "";
			document.getElementById("anderesprodukt").style.display = "none";
		}
		else if (document.getElementById("allocation5").checked==true){
			document.getElementById("erregergruppe").style.display = "none";
			document.getElementById("erreger").style.display = "none";
			document.getElementById("produkt").style.display = "none";
			document.getElementById("produktlinie").style.display = "none";
			document.getElementById("nexth2hide").style.display = "none";
			document.getElementById("anderesprodukt").style.display = "none";
		}
		else if (document.getElementById("allocation6").checked==true){
			document.getElementById("erregergruppe").style.display = "none";
			document.getElementById("erreger").style.display = "none";
			document.getElementById("produkt").style.display = "none";
			document.getElementById("produktlinie").style.display = "none";
			document.getElementById("nexth2hide").style.display = "";
			document.getElementById("anderesprodukt").style.display = "";
		}

}

//--------------------------Produktnavigator---------------------------//

var dx = 0, dy = 0;
//var isW3C = true;
var isIE = false;
var bottom,results;
var stopDieBerechnung = true;
//var bot_top_default = 0;
var result_height_default = 114;
var result_height_max = 250;
var isW3C = false;
//var isIE = false;
var lastheight = 0;
//var rlheight = 0;
var current = null;
function init_drag(){
	//makeDebugDiv();
        //bottom = getDiv("bottom").style;
        results = getDiv("results").style;   



		if (document.addEventListener) isW3C = true;
		else if (window.event) isIE = true;
		
	     // Cookie holen  
	     lastheight = holeCookie("lastheight");
 
 		// Für den Fall, dass kein Produkt ausgewählt wird aber relaoded wurde:
 		// Wenn nicht relaoded wären wir nicht an dieser Stelle. Wenn ein Produkt 
 		// Übergeben wurde, wird die Get-Var rl=true
		if (window.location.search.indexOf("&rl=true") == -1) {
			//debug("results.height = result_height_default;");
			oe_reload = true;
			lastheight = result_height_default;
			}

		// Falls es noch 0 ist (scheint teils bei nicht vorhanedenem Cookie vorzukommen): auf Standard setzen
		if (lastheight < result_height_default) { lastheight = result_height_default; }
		// Setze die Höhe
		if(isW3C){
	            results.height =  lastheight + "px";
             }else  if (isIE){
		        results.pixelHeight = lastheight; 
	          }

	     // Coookie neu setzen - fuer den Fall wiederholter Reloads:
         setzeCookie("lastheight", lastheight);  

		document.onmousedown = startDrag;
		document.onmouseup = endDrag;
		
		
       /* if (navigator.appName.indexOf("Netscape") != -1) {
                isW3C = true;              
                ns6_reload_fix();
        }else{
                isIE = true;
        }*/
}
/*function ns6_reload_fix(){
        if(location.search.indexOf("&rl=true") == -1){return}  
        if(holeCookie("lastheight")> result_height_default){
                results.height = parseInt(holeCookie("lastheight"))+'px'; 
            }else{
	            results.height = parseInt(result_height_default)+'px'; 
	            }
        }*/

function startDrag(e) {
		//debug("Letzte Hoehe Startdrag: " + lastheight);
		//debug("e.clientY: " + e.clientY);
		//debug("e.clientX: " + e.clientX);

		// TODO: Abfragen ob die Maus auf dem Pfeil/ der Grenze ist. 
		// Im Moment nur X. Y?? Oder direkt hitTest?
		var found = false;
		var obj;
		if (isW3C) obj = e.target;	
        else if (isIE) {
	        e = window.event;
            obj = e.srcElement;                     
        }
        else return;
        
        //alert(obj.parentNode.id);

      if (!obj || !obj.id || obj.id != "pfeil" ){ stopDieBerechnung == true; return }
      if(obj.parentNode.id == 'bottom'){
      	//debug ("IM STARTDRAG GEZOGEN");
	      current = results;
	      //alert(current);
	      stopDieBerechnung = false;
	      dy = e.clientY;    
	      
	      if(holeCookie("lastheight") >= result_height_default && holeCookie("lastheight") <=  parseInt(result_height_max)){    	         	      	 	
	 				lastheight = holeCookie("lastheight");		 		 		
	 				//debug ("lastheight vom Cookie: " + lastheight);
 			 }else{lastheight = result_height_default;}     
	      
 		if(isW3C){
	        document.addEventListener("mousemove", drag, true);	     
	     }else{
		     document.attachEvent("onmousemove", drag); 
	        } 
	        //alert(current);     
        return false;
	       
      	}
      	
	    stopDieBerechnung = true;
	    current = null;
	    return false;
}	 
	                 	          
         	                

        //document.onmousemove = drag; 
function endDrag(e){
		//var curry = mouse_pos(e);	
		//alert(curry.top+','+dy.top);       
        if (isIE) e = window.event;
        	
                if (parseInt(lastheight) + (e.clientY - dy) >= result_height_default && parseInt(lastheight) + (e.clientY - dy) <= result_height_max && !stopDieBerechnung) {
	                 lastheight = parseInt(lastheight)+(e.clientY - dy);
                } else if (!stopDieBerechnung){
	                	  if (parseInt(lastheight) + (e.clientY - dy) >= result_height_max) {
	                			//debug("--- HIER WIRD AUF MAX HEIGHT GESETZT! ---");	                	  	
				                lastheight = result_height_max;
	                	  } else {
	                			//debug("--- HIER WIRD AUF DEFAULT HEIGHT GESETZT! ---");
				                lastheight = result_height_default;
	                	  }
		                
	                }            
        setzeCookie("lastheight", lastheight);  
        stopDieBerechnung = true; 
        
        if (isW3C){
	        document.removeEventListener("mousemove", drag, true);
	    }else if(isIE){
		    document.detachEvent ("onmousemove", drag);
		    }
	    
		//debug("Hoehe Ende Enddrag: " + lastheight);
		current = null;
        return false;
}

function drag(e){
	//debug("current" + current);
	 if(current != null){    
		 if (isIE) e = window.event;  	
         if(parseInt(lastheight)+ (e.clientY - dy) >=  result_height_default &&  parseInt(lastheight) + (e.clientY - dy) <= result_height_max){		
         		 //alert ("hier kommen wie an"); 	             
	        // if(isW3C){
	        	//debug("letze Hoehe: " + parseInt(lastheight) + "  -  ");
	             oetemphoehe = parseInt(lastheight) + (e.clientY - dy)+'px'; 
	             //debug(oetemphoehe +" ");
	             if (oetemphoehe == result_height_default || oetemphoehe == result_height_default+1 || oetemphoehe == result_height_default+2 || oetemphoehe == result_height_default+3 || oetemphoehe == result_height_default+4 || oetemphoehe == result_height_default+5) { results.height = result_height_default; } else { results.height = oetemphoehe; }
             //}else  if (isIE){
		       // results.pixelHeight = parseInt(lastheight) + (e.clientY - dy); 
	          //}
          }   
      }
      return false;   
}
function _clear(){
	
	if(holeCookie("lastheight") >= result_height_default && holeCookie("lastheight") <= result_height_max){
		alert("Seitenreload");
		//if(isW3C){
			results.height = parseInt(holeCookie("lastheight"))+'px';
		//}else if(isIE){
			//results.pixelHeight = parseInt(holeCookie("lastheight")); 
		//}
			setzeCookie("lastheight",holeCookie("lastheight"));
	}
}
/*
function mouse_pos(e) {
	    if(!e) e = window.event;
    	var body = (window.document.compatMode && window.document.compatMode == "CSS1Compat") ?
   		window.document.documentElement : window.document.body || null;
    	var mouse = { left:0, top:0 };	
    	mouse.left = e.pageX ? e.pageX : e.clientX + body.scrollLeft;
    	mouse.top = e.pageY ? e.pageY : e.clientY + body.scrollTop;		
    	return mouse;
}*/

function getDiv(divname) {
         var div;
         if (document.getElementById) {
                div = document.getElementById(divname);
        }else{
                div = document.all[divname]; //IE4
        }

         return div;
}

//--------------------------Cookies---------------------------//
function holeCookieWert(position) {
	var ende = document.cookie.indexOf(";", position);
	if (ende == -1) 
		ende = document.cookie.length;

	return unescape(document.cookie.substring(position, ende));
}
function holeCookie(name) {
	name += "=";
	var laenge = name.length;
	var cookie_laenge = document.cookie.length;
	var i = 0;
	while (i < cookie_laenge) {
	var j = i + laenge;
	if (document.cookie.substring(i, j) == name) 
		return holeCookieWert(j);
	i = document.cookie.indexOf(" ", i) + 1;
	if (i == 0)
		break;
	}
	return null;
}
function setzeCookie(name, wert) {
	var arg_wert = setzeCookie.arguments;
	var arg_laenge = setzeCookie.arguments.length;
	var expires = (arg_laenge > 2) ? arg_wert[2] : null;
	var path = (arg_laenge > 3) ? arg_wert[3] : null;
	var domain = (arg_laenge > 4) ? arg_wert[4] : null;
	var secure = (arg_laenge > 5) ? arg_wert[5] : false;
	document.cookie = name + "=" + escape (wert) +
		((expires == null) ? "" : ("; expires=" + 
		expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}
function loescheCookie(name) {
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cookie_wert = holeCookie(name);
	if (cookie_wert != null)
		document.cookie = name + "=" + cookie_wert + 
			"; expires=" + exp.toGMTString();
}

function makeDebugDiv() {
	dv = document.createElement('div'); // create dynamically div tag
	dv.setAttribute('id',"debug");       //give id to it
	dv.className="debug";                 // set the style classname  
	//set the inner styling of the div tag 
	dv.style.position="absolute";       
	dv.style.top="0";
	dv.style.left="0";
	dv.style.backgroundColor="#ffffda";
	// write it in the document
	document.getElementsByTagName('body')[0].appendChild(dv);
}

function debug(string) {
	// write debugs in the div created by function makeDebugDiv
	document.getElementsByTagName('DIV')['debug'].appendChild(document.createTextNode(string));
}

function hitTest(e) {
	
	var testobj;
	if (isW3C) testobj = e.target;	
        else if (isIE) {
	        e = window.event;
            testobj = e.srcElement;                     
        }
	if (!testobj || !testobj.id || testobj.id != "pfeil" ){ return false } else { return true; }
	}