/*
	Globale Javascripts.
	29.03.2007
*/



// onloadRegistrierer. Beispiel:  addLoadEvent(functionsName);
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
	
var newWin;
var xPath = "http://www.weinhaus-neuerburg.de/scripts/x/x_core.js";

function imgPopUp(cont,text, winname,w,h,scroll) {
	var width1 = (w)? (w) : 700;
	var height1 = (h)? (h) : 500;
	var width = 10;
	var height = 10;
	var left = parseInt((screen.availWidth/2) - (width1/2));
	var top = parseInt((screen.availHeight/2) - (height1/2));
	var scrolling = (scroll == 1)? ',scrollbars=yes, resizable=yes, menubar=no' : ',scrollbars=no, resizable=yes, menubar=no'
	var param = "width=" + width + ", height=" + height + ", left=" + left + ", top=" + top; 
	newWin = window.open("", winname, param + scrolling);
	newWin.resizeTo(10, 10);
		setTimeout("putInWindow('" + cont + "', '" + text + "')", 50);
		newWin.focus();
	return false;
}


function putInWindow(cont, text) {
	var newCont = "<html><head><title>Preview</title>";
	newCont += "<script type='text/javascript' src=" + xPath + "><\/script>\n";
	newCont += "<script>\n";
	newCont += "window.onload=function(){\n";
	newCont += "if(xGetElementById('textBox').innerHTML != ''){\n";
	newCont += "var ih = document.getElementById('img').height;\n";
	newCont += "var th = xHeight('textBox')+10;\n";
	newCont += "var bh = xHeight('body');\n";
	newCont += "var h = ih+th;\n";
	newCont += "var dh = h-bh;\n";
	newCont += "var w = document.getElementById('img').width;\n";
	newCont += "var bw = xWidth('body');\n";
	newCont += "var dw = w-bw;\n";
	//newCont += "alert(ih + ' - ' + th + ' - ' + h);\n";
	newCont += "window.resizeTo(w+8, 0);\n";
	newCont += "window.resizeBy(0, dh);\n";
	//newCont += "window.moveBy(-dw/2, -dh/2);\n";
	newCont += "xTop('textBox', ih);";
	newCont += "xShow('textBox');";
	newCont += "window.focus();";
	newCont += "}\n";
	newCont += "}\n";
	newCont += "\n<\/script>";
	newCont += "</head>";
	newCont += "<body id='body' style='margin: 0; padding: 0; height: 100%'>"
	newCont += "<div style='position: relative; z-index: 1; font: 11px Verdana, sans-serif; color:#8A8A8A; margin-top: 30%; text-align: center;'>Bild wird geladen...</div>";
	newCont += "<div id='imageBox' style='position: absolute; z-index: 100; top: 0'><img id='img' src='"+ cont + "' onclick='window.close();' style='cursor: pointer;' title='Fenster schließen'></div>";
	newCont += "<div id='textBox' style='position: absolute;visibility: hidden; z-index: 100; top: 0;padding: 5px 20px; font: 11px Arial, sans-serif; color:#8A8A8A;'>" + text + "</div>";
	newCont += "</body></html>";
	newWin.document.write(newCont);
	newWin.document.close();
}

var activMenuItem = "";

function show(obj) {
	obj.lastChild.style.display = 'block';
	//alert(obj.lastChild.tagName + "/" + obj.firstChild.tagName)
	obj.firstChild.style.backgroundColor = "#fff"
	if (activMenuItem.style) activMenuItem.style.display = 'none';
}
function hide(obj) {
	obj.lastChild.style.display = 'none';
	if (activMenuItem.style) activMenuItem.style.display = 'block';
	obj.firstChild.style.backgroundColor = "transparent"
}
function showActMenu() {
	if (activMenuItem.style) activMenuItem.style.display = 'block';
}
function hideActMenu() {
	if (activMenuItem.style) activMenuItem.style.display = 'none';
}

function enableDropdownMenu(){
           return false;
  //  if (document.all){
        var uls = document.getElementsByTagName('UL');
        for(var i = 0; i < uls.length; i++){
            if (uls[i].className == 'dropdown'){
               var lis = uls[i].getElementsByTagName('li');
				var lisLength = lis.length;
                for (var j = 0; j < lisLength; j++){
					var sUls = lis[j].getElementsByTagName('ul');
					if (sUls.length > 0)
					{
						if (lis[j].className != "activ" && lis[j].className != "activ_widthSubCat") {
                       		lis[j].onmouseover = function() { show(this); }
                       		lis[j].onmouseout = function() { hide(this); }
                    	} else {
							activMenuItem = lis[j].lastChild;
						}
						hide(lis[j]); // Für IE < 7
					} else if (lis[j].parentNode.className ==  'dropdown'){
						lis[j].firstChild.onmouseover = function() { hideActMenu(); }
                      	lis[j].firstChild.onmouseout = function() { showActMenu(); }
					}
                }
            }
        }
   // }
}
