


this.popupOverlay =null;

window.onload= function()

{

popupInit();

	

	/*this.closePopupImage = GetObject('CloseImage');
	this.backDiv = GetObject("popupBackDiv");
	this.closePopupImage.onclick = closePopup;*/



}



function OnCloseDialog(ReturnValue)

{

closePopup();

}


function ShowDialog(titulek,text,butonsType,icoType)

{


	switchOnOverlay();
	
/*
	for(var i in DialogButtons)
	{
		var obj = GetObject(DialogButtons[i]);	
		obj.style.display = 'none';
	}
	
	
	for(var i in butonsType)	
	{	
		var obj = GetObject(DialogButtons[butonsType[i]]);	
		obj.style.display = 'block';
	
	}
	
	
	GetObject("DialogBoxTitle").innerHTML = titulek;
	
	GetObject("DialogBoxText").innerHTML = text;
	
	openPopup('DialogBox');
*/

}

function ShowInfoDialog(titulek,text)

{

	ShowDialog(titulek,text,[YES],1);

}

function ShowYesNoDialog(titulek,text)

{

ShowDialog(titulek,text,[YES,NO],1);

}

function ShowOkStornoDialog(titulek,text,icoType)

{

ShowDialog(titulek,text,[OK,STORNO],icoType);

}



function ShowCustomDialog(titulek,DIV_ID,butonsType)

{


}

function ShowCustomDialog(titulek,DIV_ID)

{


}

function ShowHelp(help_id)
{


}


function getNumber(str)
{
  return Number(str.substring(0,str.length-2));
}
function getPageScroller(){

	var yScroll,xScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;
	}

	var arrayPageScroll = {"xScroll":xScroll, "yScroll":yScroll}
	return arrayPageScroll;
}
function getPageDimension(){
	
	var xScroll, yScroll;
	var scrollLeft=0, scrollTop=0;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	var arrayPageSize = {"pageWidth":pageWidth,"pageHeight":pageHeight,"windowWidth":windowWidth,"windowHeight":windowHeight};
	return arrayPageSize;
}
 function createBackground()
{
	
		var objBody = document.getElementsByTagName("body").item(0);		
		var objOverlay = document.createElement("div");
		
		objOverlay.className = "popupOverlay";
		objOverlay.id = 'overlay';	
		objOverlay.style.position = "absolute";
		objOverlay.style.filter = 'alpha(opacity='+20+')';

		objOverlay.style.top = 0;
		objOverlay.style.left = 0;
		
		objBody.appendChild(objOverlay);
		objOverlay.style.visibility = 'hidden';
		
				
		return objOverlay;
}
function switchOnOverlay()
{
	var pgDimensions = getPageDimension();
	this.popupOverlay.style.visibility = 'visible';
	this.popupOverlay.style.height = pgDimensions.pageHeight;
	this.popupOverlay.style.width = pgDimensions.pageWidth;
	

	
		
	
}

this.popupDialog = null;
this.centerInterval  = null;
this.closeImage = null;

function setCenter(element)
{
	

	var pgdim = getPageDimension();
	var scrl = getPageScroller();
	var x = pgdim.windowWidth/2 - getNumber(element.style.width)  / 2 + scrl.xScroll;
	var y = pgdim.windowHeight/2 - getNumber(element.style.height) / 2 + scrl.yScroll;
	
	element.style.top = y+'px';
	element.style.left = x+'px';	
	
	if (this.closeImage != null)
	{
	   this.closeImage.style.top = y + 10;
	   this.closeImage.style.left = x + getNumber(element.style.width) - 10;
	}
	
	//this.closeImage.style.top = 10;
	//this.closeImage.style.left = 410;
}

function setCenterMinY(element,min_y,offsetx,offsety)
{
	var pgdim = getPageDimension();
	var scrl = getPageScroller();
	var x = pgdim.windowWidth/2 - getNumber(element.style.width)  / 2 + scrl.xScroll;
	var y = pgdim.windowHeight/2 - getNumber(element.style.height) / 2 + scrl.yScroll;
	
	if (y < min_y) y = min_y;
	if (offsetx != 0) x += offsetx
	if (offsety != 0) y += offsety	
	element.style.top = y+'px';
	element.style.left = x+'px';
}

function closeDialog()
{
		
	
}
function trim (str) 
{
        str = this != window? this : str;
        return str.replace(/^s+/, '').replace(/s+$/, '');
}


function ShowInputDialog(title,editName)
{
	switchOnOverlay();
	var inputDialog = document.getElementById("InputDialog");
	var titlespan = document.getElementById("inputdialogtitle");
	if(editName != undefined)
		document.getElementById("InputDialogTextBox").value  = trim(editName);
	titlespan.innerHTML=title;
	this.popupDialog = inputDialog;
	this.closeImage = 	document.getElementById("CloseImage");
	this.closeImage.style.visibility = 'visible';
	this.closeImage.onclick = function ()
	{
		destroyPopup();		
	}
	this.popupDialog.getInputText  = function()
	{		
		return document.getElementById("InputDialogTextBox").value;
	}
	setCenter(this.popupDialog);
	inputDialog.style.visibility = "visible";	
	this.centerInterval = setInterval("setCenter(this.popupDialog)", 100);
	return inputDialog;
}
function destroyPopup()
{
	clearInterval(this.centerInterval);
	this.popupDialog.style.visibility = 'hidden';
	this.closeImage.style.visibility = 'hidden';
	this.popupOverlay.style.visibility = 'hidden';
}
function popupInit()
{
	this.popupOverlay = document.getElementById("popupBackDiv");	
}

