// JavaScript Document

function showPopup(id, topSlide, leftSlide) {
	if (!document.getElementById) 	
		return;
	
	var obj = document.getElementById(id);
	var winh, winw, x, y, sx, sy;
	
	// get the dimensions of the window
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	
	// get the srolling of the page
	if (self.pageYOffset) // all except Explorer
	{
		sx = self.pageXOffset;
		sy = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		sx = document.documentElement.scrollLeft;
		sy = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		sx = document.body.scrollLeft;
		sy = document.body.scrollTop;
	}
	
	winh = y + sy;
	winw = x + sx;
	
	var w = parseInt(getStyle(obj, 'width'));
	var h = parseInt(getStyle(obj, 'height'));		
	//alert(h);
	//alert(winh);
	var x = Math.round((winw - w) / 2);	
        var y = Math.round((winh - h) / 2);  		
	//alert(y);
	obj.style.visibility = "visible";	
	if (topSlide)
		slide(-550, y, id, "top");
	else
		obj.style.top = y + "px";
	if (leftSlide)
		slide(-500, x, id, "left");
	else
		obj.style.left = x + "px"; 	
}

function slide(x, target, id, attr) {
	var obj = document.getElementById(id);
	eval("obj.style." + attr + "= '" + x + "px';");
	if (x < target) {
		//alert(x);
		setTimeout("slide(" + (x + 50) + ", " + target + ", '" + id + "', '" + attr + "')", 1);
	} else
		eval("obj.style." + attr + "= '" + target + "px';");
}

function closePopup(id) {
	if (!document.getElementById)
		return;
	document.getElementById(id).style.visibility = "hidden";
}

function getStyle(obj,cAttribute){
	//if IE
	if (obj.currentStyle){
	 return eval('obj.currentStyle.'+cAttribute)
	} else if (document.defaultView) {
	 //if Mozilla/FF
	 return eval('document.defaultView.getComputedStyle(obj, null).'+cAttribute)
	}	
}

function openCenteredWindowWithOptions(url, name, w, h, options) {      
  var screenh = window.screen.height;
  var screenw = window.screen.width;      
  var y = Math.round((screenh - h) / 2);
  var x = Math.round((screenw - w) / 2);
  var atts = "height=" + h + ",width=" + w + ",top=" + y + ",left=" + x + ",screenX=" + x + ",screenY=" + y + ",resizable"
  if (options != null)
    atts += "," + options;
  return window.open(url, name, atts);
}

//returns a window of specified url, height and width centered in the screen
function openCenteredWindow(url, name, w, h) {
  return openCenteredWindowWithOptions(url, name, w, h, null);
}
