/* MAUS -- MAUS -- MAUS -- MAUS -- MAUS -- MAUS -- MAUS -- MAUS */
// find out if ie runs in quirks mode
//
var xPos = "";
var yPos = "";

var docEl = (
	typeof document.compatMode != "undefined" && 
	document.compatMode        != "BackCompat"
	)? "documentElement" : "body";

// register event
// capture it for nc 4x (ok it's a dino)
//
function init_mousemove() 
{
	if(document.layers) document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove =	dpl_mouse_pos;
}

function dpl_mouse_pos(e) 
{
	// position where mousemove fired
	//
	xPos    =  e? e.pageX : window.event.x;
	yPos    =  e? e.pageY : window.event.y;
	
	// for ie add scroll position
	//
	if (document.all && !document.captureEvents) 
	{
		xPos    += document[docEl].scrollLeft;
		yPos    += document[docEl].scrollTop;
	}
	
	xPos 	+= 10;
	yPos 	+= 10;
	
	// display position
	//
	//alert(xPos + " x " + yPos);
	
	// for the dino pass event
	//
	if (document.layers) routeEvent(e);
}

init_mousemove();
/* MAUS -- MAUS -- MAUS -- MAUS -- MAUS -- MAUS -- MAUS -- MAUS */

/* AJAX -- AJAX -- AJAX -- AJAX -- AJAX -- AJAX -- AJAX */
// 
// Usage:
// callServer(contentsite,output,input,input_value);
// 
// contentsite 	= Website where the content comes from
// output			= id on page where the content will be displayed
// input				= variable name for contentsite
// input_value		= variable input for contentsite
// 
// example: 
// 			getCode.php?name=ehret   <div id="ziel"></div>
// 			callServer('getCode.php','ziel','name','ehret');
// 

/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try 
{
	xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (e) 
{
	try 
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	catch (e2) 
	{
		xmlHttp = false;
	}
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') 
{
	xmlHttp = new XMLHttpRequest();
}

var bgLayer;

function initLayer()
{
	bgLayer = document.createElement("div");
	bgLayer.style.height = "100%";
	bgLayer.style.width = "100%";
	bgLayer.style.backgroundColor = "#000";
	bgLayer.style.display = "none";
	bgLayer.style.zIndex = "1000";
	bgLayer.style.position = "absolute";
	bgLayer.style.opacity = "0.3";
	bgLayer.style.filter = "alpha(opacity=30)";
	bgLayer.style.top = "0";
	bgLayer.style.left = "0";	
	bgLayer.onclick = function() {
		document.getElementById("ajaxOutputContainer").style.display = "none";
		this.style.display = "none";
	};
	adjustLayerHeight();
	document.body.appendChild(bgLayer);
}

function adjustLayerHeight()
{
	var size = eqLayer_getPageSize();
	if(document.all)
	{
		bgLayer.style.height = document.body.parentNode.scrollHeight+"px";
	}
	else
	{
		bgLayer.style.height = size[1]+"px";
	}
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Changed for IE by Timon Rapp
//
function eqLayer_getPageSize() {
    var xScroll, yScroll;
	var docElm;
	if(document.documentElement)
	{
		docElm = document.documentElement;
	}
	else
	{
		docElm = document.body;
	}
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (docElm.scrollHeight > docElm.offsetHeight) {
        xScroll = docElm.scrollWidth;
        yScroll = docElm.scrollHeight;
    } else {
        xScroll = docElm.offsetWidth;
        yScroll = docElm.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) {
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.scrollHeight) {
        windowWidth = document.documentElement.scrollWidth;
        windowHeight = document.getElementsByTagName("html")(0).offsetHeight;
    } else if (document.body) {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }
    if (xScroll < windowWidth) {
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }

	
    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight, xScroll, yScroll);

    return arrayPageSize;
}

eqDOMReady_addEvent(initLayer);


function callServer(contentsite,output,input,input_value) 
{
	function updatePage() 
	{
		if (xmlHttp.readyState == 4) 
		{
			var response = xmlHttp.responseText;
			var zielContainer = document.getElementById(output);
			if (zielContainer.style.display != "block")
			{
				zielContainer.style.display = "block";
			}
			
			bgLayer.style.display = "block";			
			zielContainer.innerHTML = unescape(response);
			
			//02.10.08 TR — Hintergrund Layer einblenden und Schliessenlink einfügen
			zielContainer.appendChild(document.createElement("br"));
			zielContainer.appendChild(document.createElement("br"));
			var closelink = document.createElement("a");
			closelink.href="#";
			closelink.onclick = function() {
				document.getElementById("ajaxOutputContainer").style.display = "none";
				bgLayer.style.display = "none";	
				return false;
			};
			closelink.innerHTML = "Schließen";
			zielContainer.appendChild(closelink);
			zielContainer.appendChild(document.createElement("br"));		
			adjustLayerHeight(); //Höhe des Hintergrundes anpassen, falls der Layer die Seite vergrößert hat.
		}
	}
	// Only go on if there are values
	if ((input_value == null) || (input_value == "")) return;
	
	// Build the URL to connect to
	var url = contentsite + "?" + input + "=" + escape(input_value);
	
	// Open a connection to the server
	xmlHttp.open("GET", url, true);
	
	// Setup a function for the server to run when it's done
	xmlHttp.onreadystatechange = updatePage;
	
	// Send the request
	xmlHttp.send(null);
}

function callServer2(contentsite,output,input,input_value,input2,input2_value) 
{
	function updatePage() 
	{
		if (xmlHttp.readyState == 4) 
		{
			var response = xmlHttp.responseText;
			var zielContainer = document.getElementById(output);
			if (zielContainer.style.display != "block")
			{
				zielContainer.style.display = "block";
			}
			zielContainer.innerHTML = unescape(response);
		}
	}
	// Only go on if there are values
	if ((input_value == null) || (input_value == "")) return;
	
	// Build the URL to connect to
	var url = contentsite + "?" + input + "=" + escape(input_value) + "&" + input2 + "=" + escape(input2_value);
	
	// Open a connection to the server
	xmlHttp.open("GET", url, true);
	
	// Setup a function for the server to run when it's done
	xmlHttp.onreadystatechange = updatePage;
	
	// Send the request
	xmlHttp.send(null);
}
/* AJAX -- AJAX -- AJAX -- AJAX -- AJAX -- AJAX -- AJAX */

