$.vdiMenu = function(id) {
    $(id).find('ul').find('li').hover(function() {
        $(id).find('ul').find('li').removeClass("trail");
        $(this).parent("ul").parent("li").addClass("trail");
        $(this).parent("ul").parent("li").parent("ul").parent("li").addClass("trail");
        $(this).parent("ul").children("li").children("ul").hide();
        clearTimeout($(this).data('vdiMenu'));
        $(this).find('ul:first').show();
       }, function() {
		$(id).find('li').removeClass("trail");
        var mm = $(this);
        var timer = setTimeout(function() {
            mm.find('ul:first').hide();
        }, 500);
        $(this).data('vdiMenu', timer);
    });
}

$(document).ready(function() {
    $.vdiMenu("#hauptnavi");
});

 //	var Seite = "http://www.vdi-nachrichten.com/default.asp";
//	var Beschreibung = "VDI nachrichten";
	var browser = navigator.appName;
	var version = navigator.appVersion.substring(0,1);
	var ie	= ((browser == "Microsoft Internet Explorer") && (version >= 4));
	var ns4	= ((browser=="Netscape") && (version = 4));
	var ns	= ((browser=="Netscape") && (version > 4));
	var op5	= ((browser=="Opera") && (version = 5));
	var op	= ((browser=="Opera") && (version > 5));

	function Startseite(Seite)
	{
		if (ie)
		{
			document.body.style.behavior = "url(#default#homepage)";
			document.body.sethomepage(Seite);
		}else{
			document.location.href = "/allgemein/browser.asp";
		}
	}
	
	function Seite_versenden(a,b,c)
	{
		document.write("<a href='/_framework/template/sendpage.asp?url='+a+'&sitestat='+b+'&ivw='+c onClick='window.open('','printversion','width=480,height=500,toolbar=yes,status=no,directories=no,location=no,menubar=yes,scrollbars=yes,resizable=yes');' target='printversion'><img alt='versenden' src='/_library/img/verschicken.gif' title='Seite versenden' \/>Seite versenden<\/a>");
	}

	function Favoriten(Seite,Beschreibung)
	{
		if (ie)
		{
			window.external.addfavorite(Seite,Beschreibung);
		}else{
			if (ns4)
			{
//				alert("Bitte drücken Sie STRG + D um " + Beschreibung + " zu Ihren Favoriten hinzuzufügen");
				document.location.href = "/allgemein/browser.asp#netscape4";
			}else{
				if (ns)
				{
//					alert("Bitte drücken Sie STRG + D um " + Beschreibung + " zu Ihren Favoriten hinzuzufügen");
					document.location.href = "/allgemein/browser.asp#netscape";
				}else{
					if (op5)
					{
//						alert("Bitte drücken Sie STRG + T um " + Beschreibung + " zu Ihren Favoriten hinzuzufügen");
						document.location.href = "/allgemein/browser.asp#opera5";
					}else{
						if (op)
						{
//							alert("Bitte drücken Sie STRG + T um " + Beschreibung + " zu Ihren Favoriten hinzuzufügen");
							document.location.href = "/allgemein/browser.asp#opera";
						}else{
//							alert("Leider kann " + Beschreibung + " nicht automatisch zu Ihren Favoriten hinzugefügt werden. Bitte fügen Sie " + Beschreibung + " manuell zu Ihren Favoriten hinzu.");
							document.location.href = "/allgemein/browser.asp#unknown";
						}
					}
				}
			}
		}
	}

	function PrintForm()
	{
		window.open('','printversion','width=500,height=480,toolbar=yes,status=no,directories=no,location=no,menubar=yes,scrollbars=yes,resizable=yes');
	}

	function openpopup(strPage,strName,strWidth,strHeight)
	{
		window.open(strPage,strName,'height='+strHeight+',width='+strWidth+',status=no,toolbar=no,menubar=no,location=no,top=80,left=100,resizable=no,scrollbars=yes',true);
	}

	function openpopup1(strPage,strName,strWidth,strHeight)
	{
		window.open(strPage,strName,'height='+strHeight+',width='+strWidth+',status=no,toolbar=no,menubar=no,location=no,top=80,left=100,resizable=no,scrollbars=no',true).focus;
	}

	function NewWindow(strPage,strName)
	{
		window.open(strPage,strName,'location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes').focus;
	}

	function openComic()
	{
		window.open('/allgemein/dilbertshow.asp','dilbert','height=300,width=700,status=no,toolbar=no,menubar=no,location=no,top=80,left=100,resizable=no,scrollbars=no',true);
	}

	function openvcpanel(img,w,h)
	{
		window.open('/studien/wirtschaft/vc-panel/panelshow.asp?img='+img,'vcpanel','height='+h+',width='+w+',status=no,toolbar=no,menubar=no,location=no,top=80,left=100,resizable=no,scrollbars=auto',true);
	}

	function openimage(img,w,h)
	{
		window.open('/allgemein/showimagepopup.asp?img='+img,'showimg','height='+h+',width='+w+',status=no,toolbar=no,menubar=no,location=no,top=80,left=100,resizable=no,scrollbars=auto',true);
	}

	function openresizeablepopup(strPage,strName,strWidth,strHeight)
	{
		window.open(strPage,strName,'height='+strHeight+',width='+strWidth+',status=no,toolbar=no,menubar=no,location=no,top=80,left=100,resizable=yes,scrollbars=yes',true);
	}

	function closepopup()
	{
		window.opener.focus;
		window.close();
	}

	function getCookieVal (offset)
	{
		var endstr = document.cookie.indexOf (";", offset); 
		if (endstr == -1) 
		endstr = document.cookie.length; 
		return unescape(document.cookie.substring(offset, endstr));
	}

	function GetCookie(name)
	{
		var arg = name + "="; 
		var alen = arg.length; 
		var clen = document.cookie.length; 
		var i = 0; 
		while (i < clen)
		{ 
			var j = i + alen; 
			if (document.cookie.substring(i, j) == arg) 
			return getCookieVal (j); 
			i = document.cookie.indexOf(" ", i) + 1; 
			if (i == 0) break; 
		} 
		return null;
	}

	function SetCookie(name, value)
	{
		var argv	= SetCookie.arguments;
		var argc	= SetCookie.arguments.length;
		var expires	= (argc > 2) ? argv[2] : null; 
		var path	= (argc > 3) ? argv[3] : null; 
		var domain	= (argc > 4) ? argv[4] : null; 
		var secure	= (argc > 5) ? argv[5] : false; 
		path		= "/";
		document.cookie = name + "=" + escape (value) + 
			((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
			((path == null) ? "" : ("; path=" + path)) + 
			((domain == null) ? "" : ("; domain=" + domain)) + 
			((secure == true) ? "; secure" : "");
	}

	function DeleteCookie(name)
	{
		var exp		= new Date(); 
		exp.setTime(exp.getTime() - 1); 
		var cval	= GetCookie(name); 
		document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
	}
			
	// lese Zoom Cookie und lade passendes Stylesheet			  @04.05.06 - FD, EoA
	function CheckZoomCookie()
	{
		var Zoom	= GetCookie('zoom')
		if ((Zoom != null) && (Zoom == '1'))
		{
			document.getElementById("csszoom").href			= "/_framework/css/zoom.css";
		}
	}

	// schreibe Zoom Cookie und lade passendes Stylesheet
	function writeCookie(wert)
	{
		var expDays	= 365;
		var exp		= new Date(); 
		exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
		SetCookie('zoom', wert, exp);
		if (wert=='1')
		{
			document.getElementById("csszoom").href			= "/_framework/css/zoom.css";
			document.getElementById("font_gross").style.display = "block";
			document.getElementById("font_klein").style.display = "none";
		}
		else // if (wert=='0')
		{
			document.getElementById("csszoom").href			= "";
			document.getElementById("font_gross").style.display = "none";
			document.getElementById("font_klein").style.display = "block";
		}
	}

	function jump(bolNewWindow)
	{
		// 1. Zeichen der URL = boolscher wert, ob link im neuen fenster geöffnet wird
		url = document.AZForm.sel_ExtrasAZ.options[document.AZForm.sel_ExtrasAZ.selectedIndex].value;
		if (url.substring(0,1) == '0')
			bolNewWindow = false;
		else
			bolNewWindow = true;
		url = url.substring(1, url.length);
		if (bolNewWindow == true)
			window.open(url);
		else
			location = url;
	}

	function jump_teaser(bolNewWindow)
	{
		// 1. Zeichen der URL = boolscher wert, ob link im neuen fenster geöffnet wird
		url = document.AZForm_Teaser.sel_ExtrasAZ.options[document.AZForm_Teaser.sel_ExtrasAZ.selectedIndex].value;
		if (url.substring(0,1) == '0')
			bolNewWindow = false;
		else
			bolNewWindow = true;
		url = url.substring(1, url.length);
		if (bolNewWindow == true)
			window.open(url);
		else
			location = url;
	}

	function noBookPic(pic) 
	{ 
		pic.src = '/_library/onlineshop/buch1.gif'  
	}

	function sesamopenme(x,w,h,t)
	{
		var str = 'width='+w+',height='+h+',toolbar=no,location=no,left=100,top=100,status=no,resizable=no,menubar=no'
		sesamWindow = window.open(x,t,str);
	}
	
	function showArticleRating(intVTG_AR_ID)
	{
	    window.open('artikelbewertung.asp?vtg_ar_id=' + intVTG_AR_ID + '', 'artikelbewertung', 'height=600,width=640,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no');
	}

	function showBookLayer(intIndex, strID, strTitle, strSubtitle, strAuthor, strOrdNumber, strPrice, strImage, strThumbnail, strISBN, strPublisher)
	// JavaScript-Tooltip-Layer für Bücher aus dem Onlineshop
	{
		var objImage	= new Image();
		objImage.src	= strImage;
		var intActWidth	= objImage.width;
		var intMaxWidth	= 267;
	//	alert(intActWidth);
		if (intActWidth < 1)
		{
			intActWidth = 150;
		}
		if (intActWidth > intMaxWidth)
		{
			intActWidth = intMaxWidth;
		}
		sContent = '<img alt=\'X\' class=\'exit\' src=\'/_library/img/exit.gif\' /><p> <img alt=\'Bild\' class=\'left\' src=\'' + strImage + '\' onerror=\'noBookPic(this)\' width=\'' + intActWidth + '\' />'
		if (strAuthor != "")
			sContent += 'Autor: ' + strAuthor;
		
		sContent += '</p><p><strong>' + strTitle + '</strong></p><p>' + strSubtitle + '</p><p>' + strPublisher + '</p>';
		sContent += '<div class="breaker"></div>';
		if (strISBN != "")		
			sContent += '<p>ISBN: ' + strISBN + '</p>';
		if (strOrdNumber!= "")
			sContent += '<p>Best.Nr.: ' + strOrdNumber + '</p>';
		if (strPrice != "")
			sContent += '<p><strong>&euro;&nbsp;' + strPrice + '</strong></p>';
		return(sContent);
	}

	function showToyLayer(intIndex, strID, strText, strName, strOrdNumber, strPrice, strImage, strThumbnail)
	// JavaScript-Tooltip-Layer für Toys aus dem Onlineshop
	{	
		var objImage	= new Image();
		objImage.src	= strImage;
		var intActWidth	= objImage.width;
		var intMaxWidth	= 267;
		if (intActWidth < 1 || intActWidth > intMaxWidth)
		{
			intActWidth = intMaxWidth;
		}
		return '<img alt=\'X\' class=\'exit\' src=\'/_library/img/exit.gif\' /><p><img alt=\'Bild\' class=\'left\' src=\'' + strImage + '\' width=\'' + intActWidth + '\' /><strong>' + strName + '</strong></p><p>' + strText + '</p><p>Best.Nr.: ' + strOrdNumber + '</p><p><strong>&euro;&nbsp;' + strPrice + '</strong></p>'
	}
