var statusNav = 	new Array();
var bgColor = 	"#c1c1c1";

function hoverNav(id, posid, navifont, stufe, first){
  var bg =		"";
  var check = 	0;
  var ebene = 	id.split("_");
  
  if(statusNav.length == 0){
    statusNav[0] = 				new Object();
    statusNav[0]["id"] = 		id;
	statusNav[0]["posid"] = 	posid;
	statusNav[0]["navifont"] = 	navifont;
	statusNav[0]["ebene"] = 	ebene.length;
    statusNav[0]["stop"] = 		1;
	check = 					1;
	
	if(ebene.length > 2){
	  bg = bgColor;
	}
  }

  for(var i=0; i < statusNav.length; i++){
	if((statusNav[i]["id"] != id && statusNav[i]["ebene"] == ebene.length)){
	  out2(statusNav[i]["id"], statusNav[i]["posid"], statusNav[i]["navifont"]);
	  
	  for(var y=0; y < statusNav.length; y++){
	    if((statusNav[y]["id"] != id && statusNav[y]["ebene"] > ebene.length)){
		  out2(statusNav[y]["id"], statusNav[y]["posid"], statusNav[y]["navifont"]);
		}
	  } //end of for
	}  
    if(statusNav[i]["id"] == id && check == 0){
      statusNav[i]["stop"] = 	1;
	  check = 				1;
	  window.clearTimeout(statusNav[i]["time"]);
	  
	  if(ebene.length > 2){
	    bg = bgColor;
	  }
	}
	if(i+1 == statusNav.length && check == 0){
	  var k = 						i + 1;
      statusNav[k] = 				new Object();
      statusNav[k]["id"] = 			id;
	  statusNav[k]["posid"] = 		posid;
	  statusNav[k]["navifont"] = 	navifont;
	  statusNav[k]["ebene"] = 		ebene.length;
      statusNav[k]["stop"] = 		1;
	  window.clearTimeout(statusNav[k]["time"]);
	  
	  if(ebene.length > 2){
	    bg = bgColor;
	  }
	}
  } //end of for
  
  var KorTop =		0;
  var KorTop2 =		0;
  var KorLeft = 	0;
  var KorLeft2 =	0;
  var ie = 			navigator.userAgent.search(/MSIE/);
  var safari = 		navigator.userAgent.search(/Safari/);
  var os =			navigator.platform.search(/Win32/);
  var linux =		navigator.platform.search(/Linux/);
  var unix =		navigator.platform.search(/X11/);
  var ieVer = 		navigator.userAgent.indexOf("MSIE");
  var ieVerNr =		0;
  
  if(ie != -1){
    ieVerNr = 		navigator.userAgent.substr(ieVer+5,1);
  }

  if(ie != -1 && ieVerNr < 8){
    KorTop =	11;
	KorLeft = 	1;
  }
  if(safari != -1 && os == -1){
	KorTop2 = 9;
  }
  if(linux != -1 || unix != -1){
  	KorLeft2 = 	-1;
  }
  
  if(stufe == 1){
    var topPos = 	10 + KorTop2;
	var leftPos =	2 + KorLeft2;
  }
  if(stufe == 2){
    var topPos = 	0 + KorTop;
	var leftPos =	document.getElementById(posid).offsetWidth + KorLeft;
	
	if(first == 0){
	  topPos = -8 + KorTop;
	}
  }
  if(stufe == 3){
    var topPos = 	0;
	var leftPos =	document.getElementById(posid).offsetWidth + KorLeft;
	
	if(first == 0){
	  topPos = -8;
	}
  }
  
  if(window.location.host == "www.foldmaster.ch" || window.location.host == "foldmaster.ch"){
  	color = 	"#0b3486";
  }
  if(window.location.host == "www.multigraf.ch" || window.location.host == "multigraf.ch" || window.location.host == "www.eurofold.ch" || window.location.host == "eurofold.ch"){
  	color = 	"#00872f";
  }
  if(window.location.host != "www.foldmaster.ch" && window.location.host != "foldmaster.ch" && window.location.host != "www.multigraf.ch" && window.location.host != "multigraf.ch" && window.location.host != "www.eurofold.ch" && window.location.host != "eurofold.ch"){
  	color = 	"#2e72b6";
  }  

  var top =		document.getElementById(posid).offsetTop + topPos;
  var left =	document.getElementById(posid).offsetLeft + leftPos;
  
  document.getElementById(id).style.top =						top + "px";
  document.getElementById(id).style.left =						left + "px";
  document.getElementById(id).style.visibility = 				"visible";
  document.getElementById(navifont).style.color =				color;
  document.getElementById(navifont).style.backgroundColor =		bg;
	
} //end of function


function out3(){
  for(var i=0; i < statusNav.length; i++){
    document.getElementById(statusNav[i]["navifont"]).style.color =			"#85868a";
    document.getElementById(statusNav[i]["id"]).style.visibility = 			"hidden";
	document.getElementById(statusNav[i]["navifont"]).style.backgroundColor = 	"";
  } //end of for
} //end of function


function out2(id, posid, navifont){
  for(var i=0; i < statusNav.length; i++){
    if(statusNav[i]["id"] == id && statusNav[i]["stop"] == 0){
      document.getElementById(navifont).style.color =				"#85868a";
      document.getElementById(id).style.visibility = 				"hidden";
	  document.getElementById(navifont).style.backgroundColor =		"";
    }
  } //end of for
} //end of function


function out(id, posid, navifont){
  var check = 	0;
  var ebene = 	id.split("_");

  if(statusNav.length == 0){
    statusNav[0] = 			new Object();
    statusNav[0]["id"] = 		id;
	statusNav[0]["posid"] = 	posid;
	statusNav[0]["navifont"] = navifont;
	statusNav[0]["ebene"] = 	ebene.length;
    statusNav[0]["stop"] = 	0;
	statusNav[0]["time"] =		window.setTimeout("out2('" + id + "', '" + posid + "', '" + navifont + "')", 2000);
	check = 				1; 
  }

  for(var i=0; i < statusNav.length; i++){
    if(statusNav[i]["id"] == id && check == 0){
      statusNav[i]["stop"] = 	0;
	  statusNav[i]["time"] = 	window.setTimeout("out2('" + id + "', '" + posid + "', '" + navifont + "')", 2000);
	  check = 				1;
	}
	if(i+1 == statusNav.length && check == 0){
	  var k = 					i + 1;
      statusNav[k] = 				new Object();
      statusNav[k]["id"] = 		id;
	  statusNav[k]["posid"] = 		posid;
	  statusNav[k]["navifont"] = 	navifont;
	  statusNav[k]["ebene"] = 		ebene.length;
      statusNav[k]["stop"] = 		0;
	  statusNav[k]["time"] = 		window.setTimeout("out2('" + id + "', '" + posid + "', '" + navifont + "')", 2000);
	}
  } //end of for
} //end of function


var aktiv;

function fenster(doku, laenge, hoehe){
	if(aktiv == 1){
		info.close();
		info = window.open(doku, "popup", "top=250,left=500,width="+laenge+",height="+hoehe);
	}
	
	info = window.open(doku, "popup", "top=250,left=500,width="+laenge+",height="+hoehe);
	info.focus();
	aktiv = 1;
	
	if(info.closed == true){
		aktiv = 0;
	}
} //end of function


var aktiv2;

function fenster2(doku, laenge, hoehe){
	if(aktiv2 == 1){
		info2.close();
		info2 = window.open(doku, "popup2", "scrollbars=yes,top=50,left=50,width="+laenge+",height="+hoehe);
	}
	
	info2 = window.open(doku, "popup2", "scrollbars=yes,top=50,left=50,width="+laenge+",height="+hoehe);
	info2.focus();
	aktiv2 = 1;
	
	if(info2.closed == true){
		aktiv2 = 0;
	}
} //end of function


function rubrik(modul, id, rubwahl){
  modulbezeich =															"Produkte "
  opener.document.getElementById("rubrik" + rubwahl).value = 				document.getElementById("r1_" + id).value;
  opener.document.getElementById("untrubrik" + rubwahl).value = 			document.getElementById("r2_" + document.getElementById("wahlrubrik2").value).value;
  opener.document.getElementById("modul" + rubwahl).value = 				modulbezeich + modul;
  opener.document.getElementById("rubrik" + rubwahl + "_id").value = 		id;
  opener.document.getElementById("untrubrik" + rubwahl + "_id").value =		document.getElementById("wahlrubrik2").value;
  opener.document.getElementById("modul" + rubwahl + "_id").value =			modul;
} //end of function


function rubrikwahl(newmod, rubwahl){
  idP = document.getElementById("wahlrubrik").value;

  if(newmod == 1){
    idP = "";
  }

  window.location.href = "popup_rubrik.php?mod=" + document.getElementById("pmodul").value + "&id=" + idP + "&rub=" + rubwahl;
} //end of function


function rubrikdelete(rubwahl){
  opener.document.getElementById("rubrik" + rubwahl).value =			'';
  opener.document.getElementById("untrubrik" + rubwahl).value = 		'';
  opener.document.getElementById("modul" + rubwahl).value = 			'';
  opener.document.getElementById("rubrik" + rubwahl + "_id").value =	'';
  opener.document.getElementById("untrubrik" + rubwahl + "_id").value = '';
  opener.document.getElementById("modul" + rubwahl + "_id").value = 	'';
} //end of function


function auswahl(modNav){
  // Modul Produkte nur auf Hauptnavigation (nav1) verlinkbar
  modus =		"";
  navEbene = 	document.getElementById("eig").value;
  navE = 		navEbene.split("_");
  
  if(navE[0] == "nav1"){
  	modus = "&modus=mod1";
  }
  
  // Rewrite Adresszeile
  if(modNav == "w"){
  	window.location.href = "index_inhalt.php?cont=naverfass&web=" + document.getElementById("website").value + "&modus=mod1";
  }
  if(modNav == "n"){
  	window.location.href = "index_inhalt.php?cont=naverfass&web=" + document.getElementById("website").value + modus + "&eig=" + document.getElementById("eig").value;
  }

} //end of function


function auswahl2(){
  	window.location.href = "index_inhalt.php?cont=start&web=" + document.getElementById("website").value;
} //end of function


function pmodul(){
	window.location.href = window.location.href + "&mod=" + document.getElementById("pmod").value;
} //end of function
