//------------------------- CONFIG und INFO
// wichtig!: Include und onmousemove='blende();' im Body-tag nicht vergessen!

// Klassendefinition fźr layeraufrufende Zellen
var open_sel_div_ ="";


if(typeof cssnormal == 'undefined')
{
	cssnormal = "subm-container";
}

if(typeof cssselected == 'undefined')
{
	cssselected = "subm-container-sel";
}

//------------------------- ENDE


window.aktDiv = new Array();
window.aktMen = new Array();

function showDiv(ziel,ausloeser,xposition,padX,padY)
{	
		
	if(open_sel_div_ != ziel)
	{
		blende();
	}


	if (ausloeser.name != akt_menue_)
	{

		
		if(document.getElementById(ziel)==null)
		{	
			if (ausloeser.name)
			{
				Sel(ausloeser.name);
			}
			return;
		}
	
	
		newLayer = document.getElementById(ziel);
	
		///////////// Positionierung
	
		ausloeserX = getLeft(ausloeser);
		ausloeserY = getTop(ausloeser);
		ausloeserW = ausloeserX + ausloeser.offsetWidth;
		ausloeserH = ausloeserY + ausloeser.offsetHeight;
	
		//newLayer.style.position = "absolute";
	
		if (xposition == "topW")
		{
			newLayer.style.left = ausloeserW + padX;
			newLayer.style.top = ausloeserY + padY;
		}
		else if (xposition == "bottomX")
		{
			newLayer.style.left = ausloeserX + padX;
			newLayer.style.top = ausloeserH + padY;
		}
		else if (xposition == "topX") //---------------- Layer klappt nach links auf. 
		{
			newLayer.style.left = ausloeserX + padX - newLayer.offsetWidth;
			newLayer.style.top = ausloeserY + padY;
		}
		else if (xposition == "bottomW") //---------------- Layer klappt nach links auf. 
		{
			//alert(ausloeser.offsetWidth);
			//alert(ausloeserX);
			newLayer.style.left = ausloeserX + ausloeser.offsetWidth - 182;
			newLayer.style.top = ausloeserH + padY;
		}
		else
		{
			alert("divDirection ungźltig");
		}
		///////////// Positionierung Ende
	
		// Check der Fenstergrš§e
	
		if (getLeft(newLayer)+newLayer.offsetWidth >= document.body.offsetWidth)
		{
			if (xposition == "bottomX")
			{
				newLayer.style.left = ausloeserW - newLayer.offsetWidth;
			}
			else
			{
				newLayer.style.left = ausloeserX - newLayer.offsetWidth;
			}		
		}
		// /Check der Fenstergrš§e


		newLayer.style.visibility = "visible";
		
	
		////////// Sel-DeSel-Effekt bei Menuepunkten
	
		if (ausloeser.name)
		{
			Sel(ausloeser.name);
		}
		///////// Sel-DeSel Ende

	
		window.aktMen[window.aktMen.length] = ausloeser;
	
		if (ausloeser.className == cssnormal)
		{
			csswechsel(ausloeser,cssselected);
		}
	
	}
}



function ausblenden(ziel, ausloeser)
{

		if(document.getElementById(ziel)==null)
		{	
			if (ausloeser.name)
			{
				Desel(ausloeser.name);
			}
			return;
		}


	if (ausloeser.name != akt_menue_)
	{

		newLayer = document.getElementById(ziel);
		
		if (testMousepos(ziel) == true)
		{
			window.aktDiv[window.aktDiv.length] = ziel;
		}
		else
		{
			//alert("nope1");
			newLayer.style.visibility = "hidden";
			
			/// CSS
			cssreload();
			
			
			////////// Sel-DeSel-Effekt bei Menuepunkten
		
			if (ausloeser.name)
			{
				Desel(ausloeser.name);
			}
		
			///////// Sel-DeSel Ende
		}
	
	}
}

function blende()
{
	if (window.aktDiv.length >0)
	{
		i = window.aktDiv.length-1;
		ziel = window.aktDiv[i];
		
		i = window.aktMen.length-1;
		ausloeser = window.aktMen[i];
		
		if(testMousepos(ziel) == false && testMousepos(ausloeser) == false && open_sel_div_ != ziel)
		{
			//alert(ziel);
			newLayer = document.getElementById(ziel);
			newLayer.style.visibility = "hidden";
	
			window.aktDiv.length=window.aktDiv.length-1;
			
			/// CSS
			cssreload();

			////////// Sel-DeSel-Effekt bei Menuepunkten
	
			if (ausloeser.name)
			{
				Desel(ausloeser.name);
			}
			else
			{
				//---- Letzten Menuepunkt deselektieren
				var x = 1;
			
				while (window.aktMen[window.aktMen.length-x].name == false)
				{
					x++;
				}
				Desel(window.aktMen[window.aktMen.length-x].name);
			}
	
			///////// Sel-DeSel Ende
		}
	}
}

function cssreload()
{
	
	i = window.aktMen.length-1;
	ausloeser = window.aktMen[i];
			
	if (ausloeser.className == cssselected)
	{
		csswechsel(ausloeser,cssnormal);
		window.aktMen.length=window.aktMen.length-1;
	}	
}

function csswechsel(ziel,cssneu)
{
	ziel.className = cssneu;
}