function putwin(){
	
	var JH = 0;
	var JW = 0;
	var JX = 0;
	var JY = 0;
	
	var wm = document.getElementById('popup');
	
	JH = document.body.clientHeight;
	JW = document.body.clientWidth;
	JX = document.body.scrollLeft;
	JY = document.body.scrollTop;
	
	
	l_top = JH + JY - parseInt(parseFloat(JH/2) + parseFloat(470)/2);
	l_left = JW + JX - parseInt(parseFloat(JW/2) + parseFloat(640)/2);
	
	
	wm.style.top = l_top;
	wm.style.left = l_left;
	
}
function showFlash(fileName, width, height, flashvars) {	
	var text;
	text = "";
	
	if ((null == flashvars)||(flashvars == "")) {
		paramflashvars = "";
		embedflashvars = "";
	} else {
		paramflashvars = "<param value=\"" + flashvars + "\" name=\"flashvars\" />";
		embedflashvars = " flashvars=\"" + flashvars + "\"";
	}
	 
	text +="<object id=\"main\" height=\"" + height + "\" width=\"" + width + "\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\">";
	text +="<param value=\"" + fileName + "\" name=\"movie\" />";
	text +="<param value=\"high\" name=\"quality\" />";
	text +="<param value=\"transparent\" name=\"wmode\" />";
	text += paramflashvars;
	text += "<embed pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" name=\"main\" quality=\"high\" height=\"" + height + "\" width=\"" + width + "\" src=\"" + fileName + "\"" + embedflashvars + " wmode=\"transparent\"></embed></object>";
	document.write(text);
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getContent(update,url) {
	new Ajax.Updater(update, url, {asynchronous:true, evalScripts:true, requestHeaders:['X-Update', update]});
}

function showpopup(url,floor){
	putwin();
	var url='popup.php?id='+url;
	if(floor)url+='&k='+floor;
	
	$('popup').style.display='block';
	var objBody = document.getElementsByTagName("body").item(0);

	var objOverlay = document.createElement("div");
	objOverlay.id = "overlay";
	var pagesize = getPageSize();

	objOverlay.style['width'] = pagesize[0]+'px';
	objOverlay.style['height'] = pagesize[1]+'px';

	objBody.appendChild(objOverlay);
	
	getContent('popup_content',url);

}
	
function closepopup(){
	$('popup').style.display='none';
	var objBody = document.getElementsByTagName("body").item(0);
	objBody.removeChild($('overlay'));
}

function getPageSize(){
	
	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){ // 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;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}