var CoolMenu = {
	author: "el Audio Media",
	version: "1.0",
	threadactive: false,
	jobs: 0,
	frames: 100,
	
	ie: navigator.appName == "Microsoft Internet Explorer",
	
	active: new Array(),
	
	colornormR: 255,
	colornormG: 255,
	colornormB: 255,
	coloractiveR: 255,
	coloractiveG: 0,
	coloractiveB: 0,
	bgcolornormR: 00,
	bgcolornormG: 80,
	bgcolornormB: 145,
	bgcoloractiveR: 255,
	bgcoloractiveG: 255,
	bgcoloractiveB: 255,
	
	colorintime: 100,
	colorouttime: 250,
	coloroutdelay: 50,
	fadeintime: 300,
	fadeouttime: 300,
	fadeoutdelay: 50,
	
	menuwidth: 170,
	pagewidth: 970,
	
	colorintimes: new Array(),
	colorouttimes: new Array(),
	colorouthandles: new Array(),
	colorvisible: new Array(),
	
	fadeintimes: new Array(),
	fadeouttimes: new Array(),
	fadeouthandles: new Array(),
	framevisible: new Array(),
	
	InitActive: function(x){
		if (!CoolMenu.ExistsElement(x)) return;
		for (var i = 0; i < CoolMenu.active.length; i++){
			if (CoolMenu.active[i] == x) return;
		}
		CoolMenu.active.push(x);
		CoolMenu.Element(x).className += " InitActive";
		//CoolMenu.Element(x).firstChild.style["visibility"] = "visible";
		if (!CoolMenu.IsTop(x))
			CoolMenu.Element(x).firstChild.nextSibling.style["color"] = "#d10019";
		else CoolMenu.Element(x).firstChild.style["visibility"] = "visible";
						
		/*if (!CoolMenu.IsTop(x)){
			CoolMenu.Element(x).firstChild.firstChild.style["color"] = "rgb("+CoolMenu.coloractiveR
															+", "+CoolMenu.coloractiveG
															+", "+CoolMenu.coloractiveB+")";
		} else {
			CoolMenu.Element(x).firstChild.firstChild.style["color"] = "rgb("+CoolMenu.coloractiveR
															+", "+CoolMenu.coloractiveG
															+", "+CoolMenu.coloractiveB+")";
		}*/
	},
	
	ColorIn: function(x){
		if (CoolMenu.ie) return;
		if (!CoolMenu.ExistsElement(x)) return;
		for (var i = 0; i < CoolMenu.active.length; i++){			
			//CoolMenu.Element(CoolMenu.active[i]).firstChild.style["visibility"] = "visible";
			if (CoolMenu.active[i] == x) return;
		}
		
		while (CoolMenu.colorintimes.length <= x) CoolMenu.colorintimes.push(0);
		while (CoolMenu.colorvisible.length <= x) CoolMenu.colorvisible.push(false);
		while (CoolMenu.colorouthandles.length <= x) CoolMenu.colorouthandles.push(false);
		
		if (!(CoolMenu.colorouthandles[x] === 0)) clearTimeout(CoolMenu.colorouthandles[x]);
		CoolMenu.colorouthandles[x] = 0;
		
		if (CoolMenu.colorvisible[x]) return;
		CoolMenu.colorvisible[x] = true;
		
		if (CoolMenu.colorouttimes.length >= x && CoolMenu.colorouttimes[x] > 0){
			var prog = (CoolMenu.colorouttimes[x] - new Date().getTime()) / CoolMenu.colorouttime;
			if (prog < 0) prog = 0; if (prog > 1) prog = 1;
			CoolMenu.colorintimes[x] = new Date().getTime() + CoolMenu.colorintime * (1 - prog);
			CoolMenu.colorouttimes[x] = 0;
		} else {
			if (CoolMenu.colorintimes[x] == 0)
				CoolMenu.jobs++;
			CoolMenu.colorintimes[x] = new Date().getTime() + CoolMenu.colorintime;			
		}
		
		CoolMenu.Element(x).firstChild.style["opacity"] = "0";
		CoolMenu.Element(x).firstChild.style["visibility"] = "visible";
		
		/*
		if (!CoolMenu.IsTop(x)){
			//alert(CoolMenu.Element(x).firstChild.firstChild.className);
			CoolMenu.Element(x).firstChild.firstChild.style["color"] = "rgb("+CoolMenu.coloractiveR
															+", "+CoolMenu.coloractiveG
															+", "+CoolMenu.coloractiveB+")";
		} else {
			CoolMenu.Element(x).firstChild.firstChild.style["color"] = "rgb("+CoolMenu.coloractiveR
															+", "+CoolMenu.coloractiveG
															+", "+CoolMenu.coloractiveB+")";
		}*/
														
		CoolMenu.process(false);
	},
	ColorOut: function(x){
		if (CoolMenu.ie) return;
		if (!CoolMenu.ExistsElement(x)) return;
		for (var i = 0; i < CoolMenu.active.length; i++){
			if (CoolMenu.active[i] == x) {
				return;
			}
		}
		
		while (CoolMenu.colorouttimes.length <= x) CoolMenu.colorouttimes.push(0);		
		while (CoolMenu.colorouthandles.length <= x) CoolMenu.colorouthandles.push(0);
		
		if (!(CoolMenu.colorouthandles[x] === 0)) clearTimeout(CoolMenu.colorouthandles[x]);
		
		CoolMenu.colorouthandles[x] = window.setTimeout("CoolMenu.TimedColorOut("+x+")", CoolMenu.coloroutdelay);
		
	},
	TimedColorOut: function(x){
		if (CoolMenu.colorintimes.length >= x && CoolMenu.colorintimes[x] > 0){
			var prog = (CoolMenu.colorintimes[x] - new Date().getTime()) / CoolMenu.colorintime;
			if (prog < 0) prog = 0; if (prog > 1) prog = 1;
			CoolMenu.colorouttimes[x] = new Date().getTime() + CoolMenu.colorouttime * (1 - prog);
			CoolMenu.colorintimes[x] = 0;
		} else {
			if (CoolMenu.colorouttimes[x] == 0)
				CoolMenu.jobs++;
			CoolMenu.colorouttimes[x] = new Date().getTime() + CoolMenu.colorouttime;
		}
		
		/*if (!CoolMenu.IsTop(x)){
			CoolMenu.Element(x).firstChild.firstChild.style["color"] = "rgb("+CoolMenu.colornormR
															+", "+CoolMenu.colornormG
															+", "+CoolMenu.colornormB+")";
		} else {
			CoolMenu.Element(x).firstChild.firstChild.style["color"] = "rgb("+CoolMenu.colornormR
																		+", "+CoolMenu.colornormG
																		+", "+CoolMenu.colornormB+")";
		}*/
		
		CoolMenu.process(false);
	},
	FadeIn: function(x){
		//return;
		if (!CoolMenu.ExistsElement(x)) return;
		if (!CoolMenu.IsFrame(x)) return;
				
		while (CoolMenu.fadeintimes.length <= x) CoolMenu.fadeintimes.push(0);
		while (CoolMenu.framevisible.length <= x) CoolMenu.framevisible.push(false);
		while (CoolMenu.fadeouthandles.length <= x) CoolMenu.fadeouthandles.push(false);
		
		if (!(CoolMenu.fadeouthandles[x] === 0)) clearTimeout(CoolMenu.fadeouthandles[x]);
		CoolMenu.fadeouthandles[x] = 0;
		
		if (CoolMenu.framevisible[x]) return;
		CoolMenu.framevisible[x] = true;
		
		/*var left = CoolMenu.findeL(CoolMenu.Element(x));
		if (left + CoolMenu.menuwidth > CoolMenu.pagewidth + CoolMenu.findeL(CoolMenu.$("wrap"))){
			if (CoolMenu.Element(x).parentNode.parentNode.className == "coolmenu_top"){
				//CoolMenu.Element(x).style["left"] = (CoolMenu.pagewidth - CoolMenu.menuwidth) + "px";
				//alert(CoolMenu.Element(x).parentNode.parentNode.offsetWidth);
				CoolMenu.Element(x).style["left"] = "auto";
				CoolMenu.Element(x).style["right"] = "0px";
				CoolMenu.Element(x).style["marginLeft"] = "0px";
			} else {
				CoolMenu.Element(x).style["left"] = "auto";
				CoolMenu.Element(x).style["right"] = (CoolMenu.menuwidth) + "px";
				CoolMenu.Element(x).style["marginLeft"] = "0px";
			}
				//alert("jo");
		}*//* else {
			if (CoolMenu.Element(x).parentNode.className == "coolmenu_top"){
				CoolMenu.Element(x).style["left"] = "auto";
			} else {
				CoolMenu.Element(x).style["left"] = CoolMenu.menuwidth + "px";
			}
		}*/
		
		if (CoolMenu.fadeouttimes.length >= x && CoolMenu.fadeouttimes[x] > 0){
			CoolMenu.fadeintimes[x] = new Date().getTime() + CoolMenu.fadeintime - (CoolMenu.fadeouttimes[x] - new Date().getTime());
			CoolMenu.fadeouttimes[x] = 0;
		} else {
			if (CoolMenu.fadeintimes[x] == 0)
				CoolMenu.jobs++;
			CoolMenu.fadeintimes[x] = new Date().getTime() + CoolMenu.fadeintime;
			if (!CoolMenu.ie)
				CoolMenu.Element(x).style["opacity"] = "0";			
			CoolMenu.Element(x).style["width"] = "0px";
		}
		
		CoolMenu.Element(x).style["visibility"] = "visible";
		
		//log("fadein"+x);
		
		CoolMenu.process(false);
	},
	FadeOut: function(x){
		//return;
		if (!CoolMenu.ExistsElement(x)) return;
		if (!CoolMenu.IsFrame(x)) return;
		
		while (CoolMenu.fadeouttimes.length <= x) CoolMenu.fadeouttimes.push(0);
		while (CoolMenu.fadeouthandles.length <= x) CoolMenu.fadeouthandles.push(0);
		
		if (!(CoolMenu.fadeouthandles[x] === 0)) clearTimeout(CoolMenu.fadeouthandles[x]);
		
		CoolMenu.fadeouthandles[x] = window.setTimeout("CoolMenu.TimedFadeOut("+x+")", CoolMenu.fadeoutdelay);
	},
	
	TimedFadeOut: function(x){
		if (CoolMenu.fadeintimes.length >= x && CoolMenu.fadeintimes[x] > 0){
			CoolMenu.fadeouttimes[x] = new Date().getTime() + CoolMenu.fadeouttime - (CoolMenu.fadeintimes[x] - new Date().getTime());
			CoolMenu.fadeintimes[x] = 0;
		} else {
			if (CoolMenu.fadeouttimes[x] == 0)
				CoolMenu.jobs++;
			CoolMenu.fadeouttimes[x] = new Date().getTime() + CoolMenu.fadeouttime;
			if (!CoolMenu.ie)
				CoolMenu.Element(x).style["opacity"] = "1";	
			CoolMenu.Element(x).style["width"] = CoolMenu.menuwidth + "px";	
		}
		
		//log("fadeout"+x);
		
		CoolMenu.Element(x).style["visibility"] = "visible";
		
		CoolMenu.process(false);
	},
	
	ExistsElement: function(x){
		return CoolMenu.$("coolmenu"+x) != null;
	},
	IsFrame: function(x){
		return CoolMenu.$("coolmenu"+x).className == "coolmenu_frame";
	},
	IsTop: function(x){
		return CoolMenu.$("coolmenu"+x).parentNode.className != "coolmenu_frame";
	},
	Element: function(x){
		return CoolMenu.$("coolmenu"+x);
	},
	
	process: function(active){
		if (CoolMenu.threadactive != active) return;
	
		CoolMenu.threadactive = true;
		var time = new Date().getTime();
		
		for (var i = 0; i < CoolMenu.colorintimes.length; i++){
			if (CoolMenu.colorintimes[i] > 0){
				//cancel
				if (CoolMenu.colorintimes[i] <= time){
					CoolMenu.colorintimes[i] = 0;
					CoolMenu.jobs--;
					
					if (!CoolMenu.ie)
						CoolMenu.Element(i).firstChild.style["opacity"] = "1.00";
					/*CoolMenu.Element(i).style["backgroundColor"] = 
						"rgb("+CoolMenu.bgcoloractiveR
						+", "+CoolMenu.bgcoloractiveG
						+", "+CoolMenu.bgcoloractiveB+")";*/
				} else { //setting ...
					var prog = 1 - (CoolMenu.colorintimes[i] - time)/(1.0 * CoolMenu.colorintime);
					if (prog < 0) prog = 0;
					if (prog > 1) prog = 1;
					if (!CoolMenu.ie)
						CoolMenu.Element(i).firstChild.style["opacity"] = prog*1.00 + "";
					/*CoolMenu.Element(i).style["backgroundColor"] = 
						"rgb("+Math.round(CoolMenu.bgcolornormR + prog*(CoolMenu.bgcoloractiveR - CoolMenu.bgcolornormR))
						+", "+Math.round(CoolMenu.bgcolornormG + prog*(CoolMenu.bgcoloractiveG - CoolMenu.bgcolornormG))
						+", "+Math.round(CoolMenu.bgcolornormB + prog*(CoolMenu.bgcoloractiveB - CoolMenu.bgcolornormB))+")";*/
				}
			}
		}
		for (var i = 0; i < CoolMenu.colorouttimes.length; i++){
			if (CoolMenu.colorouttimes[i] > 0){
				//cancel
				CoolMenu.colorvisible[i] = false;
				if (CoolMenu.colorouttimes[i] <= time){
					CoolMenu.colorouttimes[i] = 0;
					CoolMenu.jobs--;
					if (!CoolMenu.ie)
						CoolMenu.Element(i).firstChild.style["opacity"] = "0";
					CoolMenu.Element(i).firstChild.style["visibility"] = "hidden";
					/*CoolMenu.Element(i).style["backgroundColor"] = 
						"rgb("+CoolMenu.bgcolornormR
						+", "+CoolMenu.bgcolornormG
						+", "+CoolMenu.bgcolornormB+")";*/
				} else { //setting ...
					var prog = (CoolMenu.colorouttimes[i] - time)/(1.0 * CoolMenu.colorouttime);
					if (prog < 0) prog = 0;
					if (prog > 1) prog = 1;
					if (!CoolMenu.ie)
						CoolMenu.Element(i).firstChild.style["opacity"] = prog*1.00 + "";
					/*CoolMenu.Element(i).style["backgroundColor"] = 
						"rgb("+Math.round(CoolMenu.bgcolornormR + prog*(CoolMenu.bgcoloractiveR - CoolMenu.bgcolornormR))
						+", "+Math.round(CoolMenu.bgcolornormG + prog*(CoolMenu.bgcoloractiveG - CoolMenu.bgcolornormG))
						+", "+Math.round(CoolMenu.bgcolornormB + prog*(CoolMenu.bgcoloractiveB - CoolMenu.bgcolornormB))+")";*/
				}
			}
		}
		for (var i = 0; i < CoolMenu.fadeintimes.length; i++){
			if (CoolMenu.fadeintimes[i] > 0){
				//CoolMenu.Element(i).style["zIndex"] = 200;
				//cancel
				if (CoolMenu.fadeintimes[i] <= time){
					CoolMenu.fadeintimes[i] = 0;
					CoolMenu.jobs--;
						if (!CoolMenu.ie)
					CoolMenu.Element(i).style["opacity"] = "1";	
					CoolMenu.Element(i).style["width"] = CoolMenu.menuwidth + "px";
					CoolMenu.Element(i).style["visibility"] = "visible";			
				} else { //setting ...
					CoolMenu.Element(i).style["visibility"] = "visible";
					var prog = 1 - (CoolMenu.fadeintimes[i] - time)/(1.0 * CoolMenu.fadeintime);
					if (prog < 0) prog = 0;
					if (prog > 1) prog = 1;		
					if (!CoolMenu.ie)					
						CoolMenu.Element(i).style["opacity"] = "" + prog;	
					CoolMenu.Element(i).style["width"] = Math.round(CoolMenu.menuwidth*prog) + "px";
				}
			}
		}
		for (var i = 0; i < CoolMenu.fadeouttimes.length; i++){
			if (CoolMenu.fadeouttimes[i] > 0){
				//CoolMenu.Element(i).style["zIndex"] = 100;
				CoolMenu.framevisible[i] = false;
				//cancel
				if (CoolMenu.fadeouttimes[i] <= time){
					CoolMenu.fadeouttimes[i] = 0;
					CoolMenu.jobs--;
					if (!CoolMenu.ie)
						CoolMenu.Element(i).style["opacity"] = "0";	
					CoolMenu.Element(i).style["width"] = "0px";
					CoolMenu.Element(i).style["visibility"] = "hidden";	
					//CoolMenu.Element(i).style["zIndex"] = 99;	
				} else { //setting ...
					CoolMenu.Element(i).style["visibility"] = "visible";	
					var prog = (CoolMenu.fadeouttimes[i] - time)/(1.0 * CoolMenu.fadeouttime);
					if (prog < 0) prog = 0;
					if (prog > 1) prog = 1;	
					if (!CoolMenu.ie)	
						CoolMenu.Element(i).style["opacity"] = "" + prog;				
					CoolMenu.Element(i).style["width"] = Math.round(CoolMenu.menuwidth*prog) + "px";		
				}
			}
		}
		
		//log("jobsthreads: " + CoolMenu.jobs);
		
		if (CoolMenu.jobs <= 0){
			CoolMenu.jobs = 0;
			CoolMenu.threadactive = false;		
			//log("inactive");
		} else {			
			window.setTimeout("CoolMenu.process(true)", 1000/CoolMenu.frames);
		}
	},
	
	findeL: function (obj){ 
	    var lPos = 0; 
	    if (obj.offsetParent){ 
	        while (obj.offsetParent){ 
	            lPos += obj.offsetLeft 
	            obj = obj.offsetParent; 
	        } 
	    } 
	    else if (obj.x) 
	        lPos += obj.x; 
	    return lPos; 
	},
	
	$: function(id){
        return document.getElementById(id);
	}
};

//function log(msg){
	//CoolMenu.$("logdiv").innerHTML = msg + "<br>" + CoolMenu.$("logdiv").innerHTML;
//}
