<!--

var __currentPopup = null;

function Popup(id) {
	this.id = id;
	this.color = '';
	this.contentReadyStater;
	this.contentReady = false;
	this.contentReadyCallBack;
  this.topRelativeTo = '';
  this.showOnInit = false;
  this.showInterval = null;
  this.onClose = '';
  this.onBeforeClose = '';
  this.top;
  this.left;
  this.height;
  this.width;
}

Popup.prototype.Initialize = function() {

	// pre-load images
	var imgs = new Array();
/*	imgs[0] = 'Images/BoxMenu/' + this.color + '-upper-left.png';
	imgs[1] = 'Images/BoxMenu/' + this.color + '-upper.png';
	imgs[2] = 'Images/BoxMenu/' + this.color + '-upper-right.png';
	imgs[3] = 'Images/BoxMenu/' + this.color + '-left.png';
	imgs[4] = 'Images/BoxMenu/' + this.color + '-right.png';
	imgs[5] = 'Images/BoxMenu/' + this.color + '-lower-left.png';
	imgs[6] = 'Images/BoxMenu/' + this.color + '-lower.png';
	imgs[7] = 'Images/BoxMenu/' + this.color + '-lower-right.png';
*/
	imgs[0] = 'Images/BoxMenu/' + this.color + '-upper-left-active.png';
	imgs[1] = 'Images/BoxMenu/' + this.color + '-upper-active.png';
	imgs[2] = 'Images/BoxMenu/' + this.color + '-upper-right-active.png';
	imgs[3] = 'Images/BoxMenu/' + this.color + '-left-active.png';
	imgs[4] = 'Images/BoxMenu/' + this.color + '-active.png';
	imgs[5] = 'Images/BoxMenu/' + this.color + '-right-active.png';
	imgs[6] = 'Images/BoxMenu/' + this.color + '-lower-left-active.png';
	imgs[7] = 'Images/BoxMenu/' + this.color + '-lower-active.png';
	imgs[8] = 'Images/BoxMenu/' + this.color + '-lower-right-active.png';

	var img = new Image();
	for (var i = 0; i < imgs.length; i++)
		img.src = imgs[i];

    if(this.showOnInit)
        this.ShowPopup();
}


Popup.prototype.ShowPopup = function() {
    __currentPopup = this;

    if(document.getElementById(this.id+'_container')) {
        clearTimeout(this.showInterval);
	    doShowPopup();
    } else {
        this.showInterval = setTimeout('__currentPopup.ShowPopup()', 100);
    }
}

Popup.prototype.HidePopup = function() {

	__currentPopup = this;
	doHidePopup();
}

Popup.prototype.Resize = function(newHeight, newWidth, newTop, newTopRelativeTo) {
		
		if(newHeight!=undefined)
			this.height = newHeight;
		if(newWidth!=undefined)
			this.width = newWidth;
		if(newTop!=undefined) 
			this.top = newTop;
		this.topRelativeTo = (newTopRelativeTo!=undefined) ? newTopRelativeTo: '';

		var pbox = document.getElementById(__currentPopup.id);
		pbox.style.width = parseInt(__currentPopup.width, 10).toString() + 'px';
		pbox.style.height = parseInt(__currentPopup.height, 10).toString() + 'px';
		
		this.ResizeChildWidth('td_top_width_' + this.id, this.width-8);
		this.ResizeChildWidth('td_bottom_width_' + this.id, this.width-8);
		this.ResizeChildHeight('td_left_height_' + this.id, this.height);
		this.ResizeChildHeight('td_right_height_' + this.id, this.height);
		this.ResizeChildHeight('td_content_height_' + this.id, this.height);		
	
		this.ShowPopup();
}

Popup.prototype.ResizeChildHeight = function(id, newHeight) {
	
	var c = document.getElementById(id);
	if(c)
		c.style.height = newHeight;
}

Popup.prototype.ResizeChildWidth = function(id, newWidth) {
	
	var c = document.getElementById(id);
	if(c)
		c.style.width = newWidth;
}


function doShowPopup() {

	if(__currentPopup != null) {
		if(__currentPopup.contentReadyStater!=null) {
			__currentPopup.contentReadyCallBack = afterContentReady;
			__currentPopup.contentReadyStater(__currentPopup);
					
		} else {
			afterContentReady();
		}

	}
}

function beforeContentReady() {

}

function afterContentReady() {

		var p = document.getElementById(__currentPopup.id+'_container');
		p.style.display = 'block';
		p.style.width = parseInt(getBrowserWidth(), 10).toString() + 'px';
		p.style.height = parseInt(getBrowserHeight(), 10).toString() + 'px';


		var pbox = document.getElementById(__currentPopup.id);
		pbox.style.display = 'block';
		var pboxw = parseInt(pbox.style.width, 10) / 2;
		var w = parseInt(getBrowserWidth() / 2,10);
		pbox.style.left = parseInt(w - pboxw,10).toString() + 'px';
        
        if(__currentPopup.topRelativeTo!='' && document.getElementById(__currentPopup.topRelativeTo)) {
            var relElement = document.getElementById(__currentPopup.topRelativeTo);
            var relTop = parseInt(relElement.offsetTop, 10) + parseInt(relElement.offsetHeight, 10);
            pbox.style.top = parseInt(relTop, 10) + __currentPopup.top + 'px';
        } else {
        	pbox.style.top = __currentPopup.top + 'px';
        }

		var iconClose = document.getElementById(__currentPopup.id+'_icon_close');
		var iconLeft = parseInt(pbox.style.left, 10) + parseInt(pbox.style.width, 10) -25;
		iconClose.style.left = iconLeft.toString() + 'px';
		var iconTop =  parseInt(pbox.style.top, 10)+1;
		iconClose.style.top = iconTop.toString() + 'px';
}

function doHidePopup() {

	if(__currentPopup != null) {

		if(__currentPopup.onBeforeClose!='')
			eval(__currentPopup.onBeforeClose);

		
		var pbox = document.getElementById(__currentPopup.id);
		pbox.style.display = 'none';
		var p = document.getElementById(__currentPopup.id+'_container');
		p.style.display = 'none';
		
		if(__currentPopup.onClose!='')
			eval(__currentPopup.onClose);
			
		__currentPopup = null;
	}
	
	

}
       
	
function getBrowserWidth() {
	if (navigator.appName=='Netscape')	
		return window.innerWidth;
	else if (navigator.appName.indexOf("Microsoft")!=-1)
	  return parseInt(document.body.offsetWidth, 10)-20;
}

function getBrowserHeight() {
	if (navigator.appName=='Netscape')
	  return window.innerHeight;
	else if (navigator.appName.indexOf("Microsoft")!=-1)
	  return parseInt(document.body.offsetHeight, 10)-4;
}

window.onresize = doShowPopup;

-->
