var ScrollTop=0;
var ScrollLeft=0;
var InnerWidth;
var InnerHeight;

function SetParam(){
	/*Width,Height*/
	if (window.innerWidth){
		InnerWidth=window.innerWidth;
		InnerHeight=window.innerHeight;
	}
	else
	if (document.documentElement.offsetWidth){
		InnerWidth=document.documentElement.offsetWidth;
		InnerHeight=document.documentElement.offsetHeight;

	}
	else {
		InnerWidth=document.body.offsetWidth;
		InnerHeight=document.body.offsetHeight;
	}


    /*Scroll left,top*/
	if (window.pageXOffset || window.pageYOffset){
		ScrollLeft=window.pageXOffset;
		ScrollTop=window.pageYOffset;
	}
	else
	if (document.documentElement.scrollLeft || document.documentElement.scrollTop){
		ScrollLeft=document.documentElement.scrollLeft;
		ScrollTop=document.documentElement.scrollTop;

	}
	else
	if (document.body.scrollLeft || document.body.scrollTop){
		ScrollLeft=document.body.scrollLeft;
		ScrollTop=document.body.scrollTop;
	}

}

/*Show Element(id) CenterX,CenterY*/
function showWin(id) {
    SetParam();
	var x,y;
    node=document.getElementById(id);

	x = InnerWidth+ScrollLeft;
	y = InnerHeight+ScrollTop;;

	node.style.left = ((x-node.offsetWidth)/2)+'px';
	node.style.top = y-((node.offsetHeight+InnerHeight)/2)+'px';
}

/*Hide Element(id) */
function hideWin(id) {
    node=document.getElementById(id);
	node.style.top = -5000+'px';
}

/*Show Element X,Y*/
function showWinXY(id, x, y, scroll) {
	SetParam();
	if (scroll){
		x=x+ScrollLeft;
		y=y+ScrollTop;
		}
	node=document.getElementById(id);
	//node.style.left = (x)+'px';
	node.style.top = (y)+'px';
}


/*Show Element & insert HTML */
function showWinHtml(id,HTML,x,y,scroll){
node=document.getElementById(id);
node.innerHTML=HTML;
if (!scroll) scroll=0;
if (!isNaN(x) && !isNaN(y)) showWinXY(id,x,y,scroll);else showWin(id);
}

/*Show Element & insert PHP */
function showWinPhp(id,php,parametr,x,y,scroll){
	var myAjax = new Ajax.Request(php,{method: 'get', parameters: parametr, onComplete: showResponse});
	function showResponse(r){
		$(id).innerHTML=r.responseText;
	}
if (!scroll) scroll=0;
if (!isNaN(x) && !isNaN(y)) showWinXY(id,x,y,scroll); else showWin(id);
}

function ShowError(text){
	var scrolledX, scrolledY;
	if( self.pageYOffset ) {
	scrolledX = self.pageXOffset;
	scrolledY = self.pageYOffset;
	} else if( document.documentElement && document.documentElement.scrollTop ) {
	scrolledX = document.documentElement.scrollLeft;
	scrolledY = document.documentElement.scrollTop;
	} else if( document.body ) {
	scrolledX = document.body.scrollLeft;
	scrolledY = document.body.scrollTop;
	}

	// Next, determine the coordinates of the center of browser's window

	var centerX, centerY;
	if( self.innerHeight ) {
	centerX = self.innerWidth;
	centerY = self.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight ) {
	centerX = document.documentElement.clientWidth;
	centerY = document.documentElement.clientHeight;
	} else if( document.body ) {
	centerX = document.body.clientWidth;
	centerY = document.body.clientHeight;
	}

	var leftOffset = 400;
	//var leftOffset = scrolledX + (centerX - 520) / 2;
	var topOffset = scrolledY + (centerY - 80) / 2;

	showWinHtml('hinweis',text+"<p>&raquo; <a href=\"javascript:hideWin('hinweis')\">Hinweis schließen</a></p>", leftOffset, topOffset);
}

function ShowCustomError(text){
	var scrolledX, scrolledY;
	if( self.pageYOffset ) {
	scrolledX = self.pageXOffset;
	scrolledY = self.pageYOffset;
	} else if( document.documentElement && document.documentElement.scrollTop ) {
	scrolledX = document.documentElement.scrollLeft;
	scrolledY = document.documentElement.scrollTop;
	} else if( document.body ) {
	scrolledX = document.body.scrollLeft;
	scrolledY = document.body.scrollTop;
	}

	// Next, determine the coordinates of the center of browser's window

	var centerX, centerY;
	if( self.innerHeight ) {
	centerX = self.innerWidth;
	centerY = self.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight ) {
	centerX = document.documentElement.clientWidth;
	centerY = document.documentElement.clientHeight;
	} else if( document.body ) {
	centerX = document.body.clientWidth;
	centerY = document.body.clientHeight;
	}

	var leftOffset = 400;
	//var leftOffset = scrolledX + (centerX - 520) / 2;
	var topOffset = scrolledY + (centerY - 80) / 2;

	showWinHtml('hinweis',text+"<div style='margin-left:6px;'><a href=\"javascript:hideWin('hinweis')\" style='color:5a5a5a; text-decoration:underline;'>Fenster schließen</a></div>", leftOffset, topOffset);
}

function ShowCustomErrorMonitorCenter(text){
	var scrolledX, scrolledY;
	if( self.pageYOffset ) {
	scrolledX = self.pageXOffset;
	scrolledY = self.pageYOffset;
	} else if( document.documentElement && document.documentElement.scrollTop ) {
	scrolledX = document.documentElement.scrollLeft;
	scrolledY = document.documentElement.scrollTop;
	} else if( document.body ) {
	scrolledX = document.body.scrollLeft;
	scrolledY = document.body.scrollTop;
	}

	// Next, determine the coordinates of the center of browser's window

	var centerX, centerY;
	if( self.innerHeight ) {
	centerX = self.innerWidth;
	centerY = self.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight ) {
	centerX = document.documentElement.clientWidth;
	centerY = document.documentElement.clientHeight;
	} else if( document.body ) {
	centerX = document.body.clientWidth;
	centerY = document.body.clientHeight;
	}

	var leftOffset = 400;
	//var leftOffset = scrolledX + (centerX - 520) / 2;
	var topOffset = scrolledY + (centerY - 80) / 2;

	showWinHtml('hinweis',text+"<div style='margin-left:6px;'><a href=\"javascript:hideWin('hinweis')\" style='color:5a5a5a; text-decoration:underline;'>Fenster schließen</a></div>", leftOffset, topOffset);
}

function ShowTooltip(e){
	if (!e) e=event;
	$('tooltip').style.left=(e.clientX-480)+'px';
	$('tooltip').style.top='10px';
}
function CloseTooltip(){
	$('tooltip').style.top='-5000px';
}

