// JavaScript Document
function TMenuHandle()
{
	this.gvispopup;
	this.gvispopup = '';
	this.gmnus;
	this.gmnus = Array();
	this.aktivmnus;
	this.aktivmnus = '';
	this.debinfo;
	this.debinfo = '';
}

TMenuHandle.prototype.setgmnu = function(aid, astyle, astate)
{

	var styleparam = Array();

//	this.debinfo = 'sm(' +   aid + ',' + astate + ')<br>' + this.debinfo ;
//	document.getElementById("deb").innerHTML = this.debinfo;

	bfound = false;
	
	for(i = 0; i < this.gmnus.length; i++)
	{
	
		if (this.gmnus[i].indexOf(aid + '#+#')  > -1)
		{

			bfound = true;
			break;
		}
		
		
	}

	
	if (!bfound)
	{
		this.gmnus[i] = aid + '#+#' + astyle;
	}
	
	styleparam = this.gmnus[i].split("#+#");

	fly = document.getElementById(styleparam[0]).style;
	if (fly)
	{
		if (astate == "ON")
		{
			fly.backgroundColor = "#" + styleparam[3];
			
			var fly2 =	document.getElementById("abs" + styleparam[0].substr(3,  styleparam[0].length - 1)).style;
			if (fly2)
			{
				//alert(astyle);
				fly2.color = "#" + styleparam[4];
				fopa = styleparam[6].split("#");
				fly2.fontFamily = fopa[0];
				sfs = fopa[1] + "px";
				fly2.fontSize = sfs;
				
				//alert(fopa[2].indexOf("font-style1") + " <-> "  + fopa[2]);
				if (fopa[2].indexOf("font-weight:bold") > -1)
				{
					fly2.fontWeight = "bold";
					//alert(styleparam[6]);
				}
				else
				{
					fly2.fontWeight = "normal";
				}
				
				if (fopa[2].indexOf("font-style") > -1)
				{
					fly2.fontStyle = "italic";
				}
				else
				{
					fly2.fontStyle = "";
				}
			
			}
			
		}
		else if  (astate == "OFF")
		{
			fly.backgroundColor = "#" + styleparam[1];
			
			var fly2 =	document.getElementById("abs" + styleparam[0].substr(3,  styleparam[0].length - 1)).style;
			if (fly2)
			{
				fly2.color = "#" + styleparam[2];
				selfopa = styleparam[5].split("#");
				fly2.fontFamily = selfopa[0];
				sfs = selfopa[1] + "px";
//				alert(styleparam[5]);
				fly2.fontSize = sfs;
				
				if (selfopa[2].indexOf("font-weight:bold") > -1)
				{
					fly2.fontWeight = "bold";
				}
				else
				{
					fly2.fontWeight = "normal";
				}
				
				if (selfopa[2].indexOf("font-style") > -1)
				{
					fly2.fontStyle = "italic";
				}
				else
				{
					fly2.fontStyle = "";
				}
				
			}
			
		}
	}
	
		
}

TMenuHandle.prototype.timertogglepopup = function(apopups, amnus, astyle, debinfo)
{
		var visdivs = Array();
		var newdivs = Array();
		var mnus = Array();
		var bfound = false;
		var mnuarray = Array();	

		if (this.gvispopup != '')
		{
			visdivs = this.gvispopup.split(";");
		}
		
		if (apopups != '')
		{
			newdivs = apopups.split(";");
			
			// Test ob aktuelles Pop schon sichtbar
			bfound = false;
			for(i = 0; i < visdivs.length; i++)
			{
				if (visdivs[i] == newdivs[0])
				{
					bfound = true;
					break;
				}
			}
		}
	
		if (!bfound)
		{
		
			// Nicht mehr benoetigte Popups auf hidden
			if (this.gvispopup != '')
			{
				for(i = 0; i < visdivs.length; i++)
				{
					bfound = false;
					
					for(i2 = 0; i2 < newdivs.length; i2++)
					{
					
						if (newdivs[i2] == visdivs[i])
						{
							bfound = true;
							break;
						}
					}
					
					if (!bfound)
					{
						fly = document.getElementById(visdivs[i]).style;
						if (fly)
						{
							//fly.backgroundColor = "#" + hgcolor;
							fly.visibility = 'hidden';
						}
					}
				}
			}

			if (apopups != '')
			{
				for(i = 0; i < newdivs.length; i++)
				{
					fly = document.getElementById(newdivs[i]).style;
					if (fly)
					{
						//fly.backgroundColor = "#" + selhgcolor;				
						fly.visibility = 'visible';
					}
				}
			}
			
			this.gvispopup = apopups;
	//		this.debinfo = debinfo + ":" + apopups + " <-> " + this.gvispopup +  '<br>' + this.debinfo ;
	//		document.getElementById("deb").innerHTML = this.debinfo;
	}

// Menuestyles setzen

//alte menues deaktivieren

if (this.aktivmnus != '')
{
	var mnuarray = this.aktivmnus.split(";");
	for(var i = 0; i < mnuarray.length; i++)
	{
		if (amnus.indexOf(mnuarray[i])  == -1)
		{
			this.setgmnu(mnuarray[i], astyle, 'OFF');
		}
	}
}


//neue menues aktivieren

if (amnus != "")
{
	var mnuarray = amnus.split(";");
	for(var i = 0; i < mnuarray.length; i++)
	{
		//this.debinfo = 'am(' +   mnuarray[i]  + ') ->' + mnuarray.length + '<br>' + amnus + '<br>' + this.debinfo ;
		//document.getElementById("deb").innerHTML = this.debinfo;
		
		if (this.aktivmnus.indexOf(mnuarray[i])  == -1)
		{
			this.setgmnu(mnuarray[i], astyle, 'ON');
		}
	}
}

this.aktivmnus = amnus;

//s = amnus;
//this.debinfo = s +  '<br>' + this.debinfo ;
//document.getElementById("deb").innerHTML = this.debinfo;

}

TMenuHandle.prototype.togglepopup = function(apopups, amnus, astyle, debinfo)
{
	var thisObject = this; 
	
	//this.debinfo = 'tp(' +   debinfo  + ') -><br>' + amnus + '<br>' + this.debinfo ;
	//document.getElementById("deb").innerHTML = this.debinfo;
	
	window.setTimeout(function () {thisObject.timertogglepopup(apopups, amnus, astyle, debinfo);});
}


TMenuHandle.prototype.testalert = function(atext)
{
	alert(atext);
}



