/*******************************************
/*   
/*   http://buro.sequenz.net
/*   jun. 2006
/*   
/*   erstellt 'div-pop-ups'
/*   
/******************************************/
//globale counter-var fuer die id's
var iCnt = 1;
var referenceLink = "...";
var countOpenWindows = 0;

function setBack(o)
{
	document.getElementById(o).style.zIndex = 99;
}

function createDivIframe(toShow, toGo, parent, isRef, custClass, posX, posY, ifWidth, ifHeight)
{
	iCnt++;
	
	var idRoot = "win" + iCnt;
	var idBorder = "brd" + iCnt;
	var idHandle = "han" + iCnt;
	var idContent = "con" + iCnt;
	var idIframe = "ifr" + iCnt;
	var idRealContent = "rct" + iCnt;
	var idEcke = "eck" + iCnt;
	var idWinTitle = "tit" + iCnt;
	
	//Grund-Div
	var rootDiv = document.createElement('div');
	
	if(window.pageXOffset != 0 || window.pageYOffset != 0)
	{
		var scrollX = window.pageXOffset;
		var scrollY = window.pageYOffset;
	}

	if(document.documentElement.scrollLeft != 0 || document.documentElement.scrollTop != 0)
	{
		var scrollX = document.documentElement.scrollLeft;
		var scrollY = document.documentElement.scrollTop;
	}
	
	if(posX != null && posY != null)
	{
		rootDiv.style.left = posX + "px";
		rootDiv.style.top = posY + "px";
	}
	else
	{
		if(isRef == 1)
		{
			rootDiv.style.left = 70 + "px";
			rootDiv.style.top = 20 + "px";
		}
		else
		{
			rootDiv.style.left = (scrollX - document.getElementById(parent).offsetLeft) + 70 + "px";
			rootDiv.style.top = (scrollY - document.getElementById(parent).offsetTop) + 50 + "px";
		}
	}
		
	
	rootDiv.style.zIndex= absoluteTopIndex;
	rootDiv.id = idRoot;
	
	if(custClass != null)
	{
		rootDiv.className = custClass;
	}
	else
	{
		rootDiv.className = "fenster_gross";
	}
	
	rootDiv.refLink = "http://buro.sequenz.net&#63;b=" + parent + "&#38;p=" + toShow + "&#38;g=" + toGo;
	rootDiv.onclick = function(evnt)
	{
		bringToFront(this);
		referenceLink = rootDiv.refLink;
		getRefLink();
	}
	
	//document.getElementById('spacer').appendChild(rootDiv);
	document.getElementById(parent).appendChild(rootDiv);
	//--------
	
	//Border-Div
	var borderDiv = document.createElement('div');
	
	borderDiv.id = idBorder;
	borderDiv.className = "borderDiv";
	document.getElementById(idRoot).appendChild(borderDiv);
	
	//Leiste
	var handleDiv = document.createElement('div');
	handleDiv.id = idHandle;
	handleDiv.className = "leiste";
	handleDiv.onmouseover = function(ev)
	{
		Drag.init(this,this.parentNode.parentNode);
		mouseOverHandle(this);
	}
	handleDiv.onmouseout = function(evt)
	{
		mouseOutHandle(this);
	}
		//SchliessenKnopf
		var buttonClose = document.createElement('img');
		buttonClose.id = 'close';
		buttonClose.rootId = idRoot;
		buttonClose.onclick = function(ir2)
		{
			toBeKilled = document.getElementById(this.rootId);
			parent = toBeKilled.parentNode;
			parent.removeChild(toBeKilled);
			
			bringToFront(this);
			referenceLink = "...";
			getRefLink();
		}
		buttonClose.onmouseover = function(event)
		{
			roll(this);
		}
		buttonClose.className = "finger";
		buttonClose.alt = "close";
		buttonClose.src = "img/i_close.gif"
		
		//MinimierenKnopf
		var buttonMinimize = document.createElement('img');
		buttonMinimize.contentId = idContent;
		buttonMinimize.id = 'minimze';
		buttonMinimize.rootId = idRoot;
		buttonMinimize.eckeId = idEcke;
		buttonMinimize.titelId = idWinTitle;
		buttonMinimize.realContId = idRealContent;
		buttonMinimize.isMinimized = 0;
		buttonMinimize.size = '';
		buttonMinimize.onclick = function(ic1)
		{
			minimize(this.realContId,this.eckeId, this.titelId);
		}
		buttonMinimize.onmouseover = function(event)
		{
			roll(this);
		}
		buttonMinimize.className = "finger";
		buttonMinimize.alt = "minimize";
		buttonMinimize.src = "img/i_mini.gif"
		
		//Fenstertitel
		var windowTitle = document.createElement('p');
		windowTitle.className = 'windowTitle';
		windowTitle.id = idWinTitle;
		
			//Text
			var windowTitleText =  document.createTextNode(toShow);
		
		windowTitle.appendChild(windowTitleText);
		
		
	handleDiv.appendChild(windowTitle);
	handleDiv.appendChild(buttonClose);
	handleDiv.appendChild(buttonMinimize);
	
	document.getElementById(idBorder).appendChild(handleDiv);
	//---------
	

	
	//Inhalt
	var contentDiv = document.createElement('div');
	
	contentDiv.id = idContent;
	contentDiv.className = "inhalt";
		
		//Hilfsdiv fuer echten Inhalt
		var realContentDiv = document.createElement('div');
		realContentDiv.className = "echtInhalt_gross";
		realContentDiv.id = idRealContent;
			
			//iframe
			var iframe = document.createElement('iframe');
			iframe.name = idIframe;
			iframe.id = idIframe;
			iframe.src = "iframes/if_" + toShow + ".shtml?toGo=" + toGo;
			iframe.scrolling = "no";
			iframe.frameBorder = "0";
			if(ifWidth != null && ifHeight != null)
			{
				iframe.width = ifWidth; 
				iframe.height = ifHeight;
			}
			else
			{
				iframe.width = "720"; 
				iframe.height = "450";
			}
			iframe.align = "middle"
			
		realContentDiv.appendChild(iframe);
			
		//Div fuer Ecke
		var imgDiv = document.createElement('div');
		imgDiv.className = "eckediv";
		imgDiv.id = idEcke;
		
		var imgEcke = document.createElement('img');
		imgEcke.alt = "ecke";
		imgEcke.src = "img/ecke.gif";
		imgEcke.className = "ecke";
		
		imgDiv.appendChild(imgEcke);
		
	contentDiv.appendChild(realContentDiv);
	
	document.getElementById(idBorder).appendChild(contentDiv);
	document.getElementById(idRoot).appendChild(imgDiv);
	
	referenceLink = rootDiv.refLink;
	getRefLink();
	countOpenWindows++;
	writeStats();
}


function minimize(elementID,elementID2,elementID3)
{
	
	realContentDiv = document.getElementById(elementID);
	eckeDiv = document.getElementById(elementID2);
	title = document.getElementById(elementID3);
	
	realContentDiv.style.display = '';
	eckeDiv.style.display = '';
	
	if(!realContentDiv.isMinimized)
	{
		realContentDiv.isMinimized = 0;
	}
	
	if(realContentDiv.isMinimized == 0)
	{
		realContentDiv.isMinimized = 1;
		realContentDiv.style.display = 'none';
		eckeDiv.style.display = 'none';
		title.style.display = 'inline';
		return;
	}
	
	if(realContentDiv.isMinimized == 1)
	{
		realContentDiv.isMinimized = 0;
		realContentDiv.style.display = '';
		eckeDiv.style.display = '';
		title.style.display = '';
		return;
	}
}

