// pick stylesheet based on browser

// if windows + nav 6
if (is_win && is_nav6up) {
	document.write('<style type="text/css">@import "' + RootOffset + 'css/menu_ns_style.css";</style>');
	}
// windows + navigator
else if (is_win && is_nav) {
	document.write('<style type="text/css">@import "' + RootOffset + 'css/menu_ns_style.css";</style>');
	}
// windows + opera
else if (is_win && is_opera) {
	document.write('<style type="text/css">@import "' + RootOffset + 'css/menu_IE_style.css";</style>');
	}
// windows ie6
else if (is_win && is_ie6) {
	document.write('<style type="text/css">@import "' + RootOffset + 'css/menu_IE_style.css";</style>');
	}	
// windows + ie
else if (is_win && is_ie5_5up) {
	document.write('<style type="text/css">@import "' + RootOffset + 'css/menu_IE_style.css";</style>');
	}
// windows + ie (hopefully ie 6)
else if (is_win && is_ie5) {
	document.write('<style type="text/css">@import "' + RootOffset + 'css/menu_IE_style.css";</style>');
	}
// mac + safari
else if (is_mac && is_safari) {
	document.write('<style type="text/css">@import "' + RootOffset + 'css/menu_safari_style_mac.css";</style>');
}
// mac + nav6 
else if (is_mac && is_nav6up) {
	document.write('<style type="text/css">@import "' + RootOffset + 'css/menu_IE_style_mac.css";</style>');
	}
// mac + navigator
else if (is_mac && is_nav) {
	document.write('<style type="text/css">@import "' + RootOffset + 'css/menu_IE_style_mac.css";</style>');
	}
// mac + ie
else if (is_mac && is_ie) {
	document.write('<style type="text/css">@import "' + RootOffset + 'css/menu_IE_style_mac.css";</style>');
	}
// everybody else
else {
	document.write('<style type="text/css">@import "' + RootOffset + 'css/menu_IE_style.css";</style>');
	}

// popup an error window if agent is less than 5.0 
if ((is_mac && is_ie4) || (is_mac && is_nav4) || (is_win && is_ie4) || (is_win && is_nav4) && (getCookie("hide_upgrade_window") != "true")) {
	createWindow("/upgrade_your_browser.html","upgrade_me","statusbar,menubar,height=400,width=470,resizable");
}


/*****************************************************
 * SO
 * 3/04/2001
 * 
 * a nice little script to create exclusive, slide-out
 * menus for ns4, ns6, mozilla, opera, ie4, ie5 on 
 * mac and win32. I've got no linux or unix to test on but 
 * it should(?) work... 
 *
 *****************************************************/

SO.Registry = []
SO.aniLen = 200
SO.hideDelay = 300
SO.minCPUResolution = 10

// constructor
function SO(id, dir, left, top, width, height)
{
	this.ie  = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0
	this.css="";

	if (this.ie || this.ns4 || this.dom) {
		this.id			 = id
		this.dir		 = dir
		this.orientation = dir == "left" || dir == "right" ? "h" : "v"
		this.dirType	 = dir == "right" || dir == "down" ? "-" : "+"
		this.dim		 = this.orientation == "h" ? width : height
		this.hideTimer	 = false
		this.aniTimer	 = false
		this.open		 = false
		this.over		 = false
		this.startTime	 = 0

		// global reference to this object
		this.gRef = "SO_"+id
		eval(this.gRef+"=this")

		// add this menu object to an internal list of all menus
		SO.Registry[id] = this

		var d = document;
		var affiche="";
		affiche = affiche + '#' + this.id + 'Container { visibility:hidden; ';
		affiche = affiche + 'left:' + left + 'px; ';
		affiche = affiche + 'top:' + top + 'px; ';
		affiche = affiche + 'overflow:hidden; }';
		affiche = affiche + '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; filter:alpha(opacity=100); -moz-opacity:1.00; opacity: 1.00; ';
		affiche = affiche + 'width:' + width + 'px; ';
		affiche = affiche + 'height:' + height + 'px; ';
		affiche = affiche + 'clip:rect(0 ' + width + 'px ' + height + 'px 0); ';
		affiche = affiche + 'z-index: 999; ';
		affiche = affiche + '}';
		if (String(this.id).length>4) {
			if (String(this.id).substring(0,4)=="mn1_") {
				affiche = affiche + '#menus #' + this.id + ' { background-color: #e67a00; }';
				affiche = affiche + '#menus #' + this.id + ' li { border-right: 2px solid #e67a00; }';
				affiche = affiche + '#menus #' + this.id + ' a:hover { color: #293e65; }';
			} else if (String(this.id).substring(0,4)=="mn2_") {
				affiche = affiche + '#menus #' + this.id + ' { background-color: #293e65; }';
				affiche = affiche + '#menus #' + this.id + ' li { border-right: 2px solid #293e65; }';
				affiche = affiche + '#menus #' + this.id + ' a:hover { color: #C54C4C; }';
			} else if (String(this.id).substring(0,4)=="mn3_") {
				affiche = affiche + '#menus #' + this.id + ' { background-color: #83b0cf; }';
				affiche = affiche + '#menus #' + this.id + ' li { border-right: 2px solid #293e65; }';
				affiche = affiche + '#menus #' + this.id + ' a:hover { color: #C54C4C; }';
			} else if (String(this.id).substring(0,4)=="mn4_") {
				affiche = affiche + '#menus #' + this.id + ' { background-color: #83b0cf; }';
				affiche = affiche + '#menus #' + this.id + ' li { border-right: 2px solid #293e65; }';
				affiche = affiche + '#menus #' + this.id + ' a:hover { color: #6DABC8; }';
			} else if (String(this.id).substring(0,4)=="mn5_") {
				affiche = affiche + '#menus #' + this.id + ' { background-color: #83b0cf; }';
				affiche = affiche + '#menus #' + this.id + ' li { border-right: 2px solid #293e65; }';
				affiche = affiche + '#menus #' + this.id + ' a:hover { color: #A7001F; }';
			} 
		}
		this.css=affiche;
		this.load()
	}
}

SO.writeCSS=function(){
	document.writeln("<style type=\"text/css\">");
	for(var id in SO.Registry){
		document.writeln(SO.Registry[id].css);
	}
	document.writeln("</style>");
}

SO.prototype.load = function() {
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	var temp

	if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
	else {
		this.container	= obj1
		this.menu		= obj2
		this.style		= this.ns4 ? this.menu : this.menu.style
		this.homePos	= eval("0" + this.dirType + this.dim)
		this.outPos		= 0
		this.accelConst	= (this.outPos - this.homePos) / SO.aniLen / SO.aniLen 

		// set event handlers.
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
//		this.menu.onmouseover = new Function("SO.sM('" + this.id + "')")
//		this.menu.onmouseout = new Function("SO.hM('" + this.id + "')")

		//set initial state
		this.endSlide()
	}
}
	
SO.sM = function(id)
{
	var reg = SO.Registry
	var obj = SO.Registry[id]
	
	if ( obj && obj.container) {
		obj.over = true

		// if this menu is scheduled to close, cancel it.
		if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }

		// if this menu is closed, open it.
		if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
	}
}

SO.hM = function(id)
{
	// schedules the menu to close after <hideDelay> ms, which
	// gives the user time to cancel the action if they accidentally moused out
	var obj = SO.Registry[id]
	   if ( obj && obj.container) {
		   if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
		   obj.hideTimer = window.setTimeout("SO.hide('" + id + "')", SO.hideDelay);
	   }
}

SO.hM2 = function(id)
{
	// schedules the menu to close after <hideDelay> ms, which
	// gives the user time to cancel the action if they accidentally moused out
	var obj = SO.Registry[id]
	   if (obj.container) {
		   if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
		   obj.hideTimer = window.setTimeout("SO.hide('" + id + "')", SO.hideDelay+SO.aniLen);
	   }
}

SO.hideAll = function(){
	var reg=SO.Registry;
	for(menu in reg){
		SO.hide(menu);
		if(menu.hideTimer){
			window.clearTimeout(menu.hideTimer);
		}
	}
}

SO.hide = function(id)
{
	var obj = SO.Registry[id]
	obj.over = false

	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
	
	// flag that this scheduled event has occured.
	obj.hideTimer = 0

	// if this menu is open, close it.
	if (obj.open && !obj.aniTimer) obj.startSlide(false)
}

SO.prototype.startSlide = function(open) {
	this[open ? "onactivate" : "ondeactivate"]()
	this.open = open
	if (open) this.setVisibility(true)
	this.startTime = (new Date()).getTime()	
	this.aniTimer = window.setInterval(this.gRef + ".slide()", SO.minCPUResolution)
}

SO.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime
	if (elapsed > SO.aniLen) this.endSlide()
	else {
		var d = Math.round(Math.pow(SO.aniLen-elapsed, 2) * this.accelConst)
		if (this.open && this.dirType == "-")		d = -d
		else if (this.open && this.dirType == "+")	d = -d
		else if (!this.open && this.dirType == "-")	d = -this.dim + d
		else						d = this.dim + d

		this.moveTo(d)
	}
}

SO.prototype.endSlide = function() {
	this.aniTimer = window.clearTimeout(this.aniTimer)
	this.moveTo(this.open ? this.outPos : this.homePos)
	if (!this.open) this.setVisibility(false)
	if ((this.open && !this.over) || (!this.open && this.over)) {
		this.startSlide(this.over)
	}
}

SO.prototype.setVisibility = function(bShow) { 
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}
SO.prototype.moveTo = function(p) { 
	this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : (p) + "px"
}
SO.prototype.getPos = function(c) {
	return parseInt(this.style[c])
}

// events
SO.prototype.onactivate		= function() { }
SO.prototype.ondeactivate	= function() { }

			//This sets the size and position of each drop-down - left, top, width, height.
		//alert("test");
		// Differenz Leuk 35

	
		//alert(XPos);
 		//alert(document.body.clientWidth);
        new SO("mn1", "right", 140, 1, 140, 400)
        new SO("mn2", "right", 140, 26, 140, 400)
        new SO("mn3", "right", 140, 51, 140, 400)
        new SO("mn4", "right", 140, 76, 140, 400)
        new SO("mn5", "right", 140, 101, 140, 400)
        new SO("mn6", "right", 140, 126, 140, 400)
        new SO("mn7", "right", 140, 151, 140, 400)
        new SO("mn8", "right", 140, 176, 140, 400)

