function isPopup ()
{
	this.Background = null;
	this.Popup	= null;
	this.TitleBar	= null;
	this.Title	= null;
	this.Content	= null;
	this.Controls	= null;
	this.cbFunction	= null;
	this.cbObject	= null;
	this.cbParams	= null;
	this.visible	= false;
	this.tabTags	= new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME");	
	this.tabIndexes	= new Array();

	this.Background = document.getElementById("popBackground");
	this.Popup	= document.getElementById("popWindow");
	this.TitleBar	= document.getElementById("popTitleBar");
	this.Title	= document.getElementById("popTitle");
	this.Frame	= document.getElementById("popFrame");
	this.Content	= document.getElementById("popContent");
	this.Controls	= document.getElementById("popControls");

	this.registerEvent(window, 'resize');
	this.registerEvent(window, 'scroll');
}

isPopup.prototype = {
	registerEvent : function(target, type, args) 
	{
		var self = this;
			
		if (target.addEventListener) {
			target.addEventListener(type,onEvent,true);
		} else if (target.attachEvent) {
			target.attachEvent('on'+type,onEvent);
		}
		
		function onEvent(e)
		{
			e = e||window.event;
			e.element = target;
			return self["on"+type](e, args);
		}
	}
	,
	show : function(sTitle, iWidth, iHeight, sHTML, sClose, cbObject, cbFunction, cbParams)
	{
		this.visible = true;
		this.disableTabs();
		this.hideSelectBoxes();
		this.center(iWidth, iHeight);

		/* padding for content */
		var padding = 5;
		
		// create callback function
		if (cbObject != "") {
			this.cbObject = cbObject;
		}
		if (cbFunction != "") {
			this.cbFunction = cbFunction;
		}
		if (cbParams != "") {
			this.cbParams = cbParams;
		}
		
		this.Background.style.display	= "block";
		this.Popup.style.display	= "block";
		var TitleHeight			= parseInt(this.TitleBar.offsetHeight, 10);
		var ControlsHeight		= parseInt(this.Controls.offsetHeight, 10);
		this.Popup.style.width		= iWidth + "px";
		this.Popup.style.height		= (iHeight + TitleHeight) + "px";
		this.Frame.style.width		= iWidth + "px";
		this.Frame.style.height		= iHeight + "px";
		this.Content.style.padding	= padding + "px";
		this.Content.style.width	= (iWidth - (2*padding)) + "px";
		this.Content.style.height	= (iHeight - ControlsHeight - (2*padding)) + "px";
		this.Title.innerHTML		= sTitle;
		this.Content.innerHTML		= sHTML;
		this.Controls.innerHTML		= '<button class="FormButton" onclick="document.popup.hide(true);">' + sClose + '</button>';
	}
	,
	hide : function(delLink)
	{
		this.visible = false;
		this.restoreTabs();
		this.showSelectBoxes();

		if (this.Background == null) {
			return;
		}
		this.Background.style.display	= "none";
		this.Popup.style.display	= "none";
		this.Title.innerHTML		= "";
		this.Content.innerHTML		= "";

		if (this.hideSelects == true) {
			this.displaySelectBoxes();
		}

		//callback function
		if(this.cbObject != null && this.cbFunction != null) {
			parent[this.cbObject][this.cbFunction](this.cbParams);
		}
		else if(this.cbObject == null && this.cbFunction != null) {
			parent[this.cbFunction](this.cbParams);
		}
	}
	,
	center : function(iWidth, iHeight) 
	{
		if (this.visible == true) {
			if (iWidth == null || isNaN(iWidth)) {
				iWidth = this.Popup.offsetWidth;
			}
			if (iHeight == null) {
				iHeight = this.Popup.offsetHeight;
			}
		
			var fullHeight		= this.getHeight();
			var fullWidth		= this.getWidth();
			var Body		= document.documentElement;
			var TitleHeight		= parseInt(this.Title.offsetHeight, 10);
			var Top			= 0;
			var Left		= 0;
			if(document.all) Top	= parseInt(Body.scrollTop,10);
			if(document.all) Left	= parseInt(Body.scrollLeft,10);
			
			this.Popup.style.top		= Top + ((fullHeight - (iHeight + TitleHeight)) / 2) + "px";
			this.Popup.style.left		= Left + ((fullWidth - iWidth) / 2) + "px";
			this.Background.style.height	= fullWidth + "px";
			this.Background.style.width	= fullWidth + "px";
		}
	}
	,
	onresize : function(event, args)
	{
		this.center();
	}
	,

	onscroll : function(event, args)
	{
		this.center();
	}
	,
	disableTabs: function() 
	{
		if (document.all) {
			var i = 0;
			for (var j = 0; j < this.tabTags.length; j++) {
				var tagElements = document.getElementsByTagName(this.tabTags[j]);
				for (var k = 0 ; k < tagElements.length; k++) {
					this.tabIndexes[i] = tagElements[k].tabIndex;
					tagElements[k].tabIndex="-1";
					i++;
				}
			}
		}
	}
	,
	restoreTabs: function() 
	{
		if (document.all) {
			var i = 0;
			for (var j = 0; j < this.tabTags.length; j++) {
				var tagElements = document.getElementsByTagName(this.tabTags[j]);
				for (var k = 0 ; k < tagElements.length; k++) {
					tagElements[k].tabIndex = this.tabIndexes[i];
					tagElements[k].tabEnabled = true;
					i++;
				}
			}
		}
	}
	,
	getHeight:function() {
		if (window.innerHeight!=window.undefined) return window.innerHeight;
		if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
		if (document.body) return document.body.clientHeight;
		return window.undefined;
	}
	,
	getWidth:function() {
		if (window.innerWidth!=window.undefined) return window.innerWidth;
		if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth;
		if (document.body) return document.body.clientWidth;
		return window.undefined;
	}
	,
	showSelectBoxes : function()
	{
		aSelects = document.getElementsByTagName("select");
		for (i = 0; i != aSelects.length; i++) {
			//Workaround for scw Datetimepicker in AdminProjects
			if (!(aSelects[i].id == "scwMonths" || aSelects[i].id == "scwYears" )) {
				aSelects[i].style.visibility = "visible";
			}
		}
	}
	,
	hideSelectBoxes : function()
	{
		aSelects = document.getElementsByTagName("select");
		for (i = 0; i != aSelects.length; i++) {
			//Workaround for scw Datetimepicker in AdminProjects
			if (!(aSelects[i].id == "scwMonths" || aSelects[i].id == "scwYears" )) {
				aSelects[i].style.visibility = "hidden";
			}
		}
	}
}