Popup 	=	{}
Browser = 	{}  

Browser.IsSafari = (navigator.userAgent.search(/Safari/i) != -1)|| false;
Browser.GetClientWidth = function()
{
	return(window.innerWidth||
		  (document.documentElement && document.documentElement.clientWidth)||
		  (document.body && document.body.clientWidth)||
		  0);
}
Browser.GetClientHeight = function()
{
	return(window.innerHeight||
		  (document.documentElement && document.documentElement.clientHeight)||
		  (document.body && document.body.clientHeight)||
		  0);
}
Browser.GetPageScrollTop = function()
{
	return(document.documentElement && document.documentElement.scrollTop)||
		  (document.body && document.body.scrollTop)||
		  0;
}
Browser.GetPageScrollLeft = function()
{
	return(document.documentElement && document.documentElement.scrollLeft)||
		  (document.body && document.body.scrollLeft)||
		  0;
}
Browser.GetPageSize = function()
{
	var xScroll,yScroll;
	if(window.innerHeight && window.scrollMaxY)
	{
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if(document.body.scrollHeight > document.body.offsetHeight)
	{
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else
	{
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth,windowHeight;
	if(self.innerHeight)
	{
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientHeight)
	{
		windowWidth  = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if(document.body)
	{
		windowWidth  = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	var pageHeight,pageWidth;
	
	if(yScroll < windowHeight) pageHeight = windowHeight;
	else pageHeight = yScroll;
	
	if(xScroll < windowWidth) pageWidth = windowWidth;
	else pageWidth = xScroll;
	
	return {pageWidth:pageWidth, pageHeight:pageHeight, windowWidth:windowWidth, windowHeight:windowHeight};
}

Browser.getScrollXY	= function() 
{
 	 var scrOfX = 0, scrOfY = 0;
  	if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return { ScrollX:scrOfX, ScrollY:scrOfY };
}

Popup.ComboElem       	=	[];
Popup.Popup_Loaded	  	=	false;
Popup.popupId			=	'';
Popup.popupName			=	'';
Popup.className			=	'';
Popup.Background		=	null;
Popup.Window			=	null;
Popup.objCount			=	null;
Popup.ObjectElem		=	[];
Popup.divIdBackground = 'divPanel_popup_parent';

Popup.createBackground	= function()
{
	Popup.Background		=	document.createElement('div');
	Popup.Background.id 	= 	Popup.divIdBackground;
	var PageSize 				= 	Browser.GetPageSize();
	
	Scroll					=	Browser.getScrollXY();
	
	Popup.Background.style.width 	=	PageSize.pageWidth+'px'; 
	Popup.Background.style.height 	= 	PageSize.pageHeight+'px';
	
	Popup.Background.style.left 	= 	'0px';
	Popup.Background.style.top 		= 	'0px';
	
	Popup.Background.className 		= 	(Browser.IsSafari) ? "popupBackgroundSafari" : "popupBackground";
	document.body.appendChild(Popup.Background);
	return;
}

Popup.showDiv =	function(divId,divName,divClass,txt)
{
	//--	Create div object
	Popup.Window		=	document.createElement('div');
	
	//--	assign div id,name and class name
	Popup.Window.id 			= 	divId;
	Popup.Window.name 			= 	divName;
	Popup.Window.className		= 	divClass;
	Popup.Window.innerHTML		=	txt;
	
	Popup.Window.popupId			=	divId;
	Popup.Window.popupName			=	divName;
	Popup.Window.className			=	divClass;
	
	//--	set div to display
	Popup.Window.style.position	=	'absolute';
	Popup.Window.style.display	=	'block';
	
	Popup.Popup_Loaded	=	true;
	
	//--	create hidden backgroud
	Popup.createBackground();
	Popup.HideComboElement();
	Popup.HideEmbeded();
	
	//--	append the divc to the body
	document.body.appendChild(Popup.Window);
	
	PageSize 			= 	Browser.GetPageSize();
	
	Scroll				=	Browser.getScrollXY();
	
	
		
	var vDivLeft		=	( (PageSize.windowWidth  - Popup.Window.scrollWidth) / 2) + Scroll.ScrollX;
	var vDivTop			=	( (PageSize.windowHeight - Popup.Window.scrollHeight) / 2) + Scroll.ScrollY;
	
	Popup.Window.style.left		=	vDivLeft+"px";
	Popup.Window.style.top		=	vDivTop+"px";
}

Popup.HideComboElement = function()
{
	Element    = document.getElementsByTagName('select');
	this.count = Element.length;
	
	for( vLoop=0; vLoop<this.count; vLoop++ )
	{
		Popup.ComboElem.push(Element[vLoop]);
		Element[vLoop].style.display = 'none';
	}
	
}

Popup.HideEmbeded = function()
{
	
	Element	=	document.getElementsByTagName('embed');
	this.objCount = Element.length;
	for( vLoop=0; vLoop<this.objCount; vLoop++ )
	{
		Popup.ObjectElem.push(Element[vLoop]);
		Element[vLoop].style.visibility = 'hidden';
	}
}

Popup.showEmbeded = function()
{
	
		for ( vLoop=0; vLoop<Popup.ObjectElem.length; vLoop++ )
		{
				Popup.ObjectElem[vLoop].style.visibility = 'visible';
		}
}

Popup.ShowComboElement = function()
{
	for ( vLoop=0; vLoop<Popup.ComboElem.length; vLoop++ )
		Popup.ComboElem[vLoop].style.display = 'inline';
}

Popup.Hide = function() 
{		
	 if(Popup.Popup_Loaded == true) {		 
			Popup.ShowComboElement();
			Popup.showEmbeded();
			if(typeof(Popup.Background) == "object") {
				document.body.removeChild(Popup.Background);			
				Popup.Background.className 	= "panelPopupTableBorder"; 
			}
			if(typeof(Popup.Window) == "object" ) {
				document.body.removeChild(Popup.Window);
			}  
		 Popup.Popup_Loaded = false;  
	   }	
	if(Browser.IsSafari){
		ShowObjectTags();
	}		   	
}