var x = parseInt((screen.width-w)/2);
var y = parseInt((screen.height-h)/2);

var yoffset = 120;
var sdw = 10;
var popup, shadow;

var popuphtml="<div class='popupContainer' id='popup' style='overflow: hidden; position: absolute; top: "+yoffset+"; z-index: 2; left: 200; width: "+w+"px; height: "+h+"px; border: 1px solid black; background-color: white;'>" +
				 "<div class='menuContainer' style='text-align: right; border: 0px solid black;'><a class='menu' style='color: #fff;' href='#' style='cursor: pointer; margin: 2px; padding: 2px;' onclick=\"javascript: closePopup(); return false;\">Close</a>&nbsp;&nbsp;</div>" +
				 "<div style='border-top: 1px solid black; height: "+(h-20)+"px; overflow: hidden; align:center;'><iframe src='popup.php' style='border: 0px solid black; width: "+(w-4)+"px; height: "+(h-27)+"px;' frameborder='0' scrolling='yes'></iframe></div></div>" +
				 "<div id='dropshadow' style='background-color: black; position: absolute; top: "+(120+sdw)+"; left: 205; width: "+w+"px; height: "+h+"px; z-index: 1; filter: alpha(opacity=40); -moz-opacity: .4;'>&nbsp;</div>";
onload = function() { window.setTimeout( "showPopup();", 1000 ); }

// Initialize popup and shadow objects
function init() {
	popup = document.getElementById('popup');
	shadow = document.getElementById('dropshadow');
}

function showPopup() {
	
//	alert(document.body);
	if( document.body ) {
		document.body.innerHTML += popuphtml;
		init();
		while( !popup || !shadow ) {
			popup=document.getElementById('popup');
			shadow = document.getElementById('dropshadow');	
		}
		if( popup && shadow ) {
			popup.style.left  = parseInt( ( document.body.clientWidth - w ) / 2 )+'px';
			shadow.style.left = ( parseInt( ( document.body.clientWidth - w ) / 2 ) + sdw)+'px';
			
			yoffset = parseInt( ( document.body.clientHeight - h ) / 2 );
			
			popup.style.top  = '251px';
			shadow.style.top = '261px';
		}
	} else {
		window.setTimeout( "showPopup();", 500 );
	}
}

function closePopup() {
	popup.style.visibility = "hidden";
	shadow.style.visibility = "hidden";
}

function dump( variable, printVals ) {
	var str = "";
	for( j in variable ) {
		str += "<LI>"+j;
		if( printVals )
			str += " = " + variable[j];
	}
	document.write( str );
}

window.onscroll = function(e) {
	var dif = document.body.scrollTop;
	if( popup && shadow ) {
	  popup.style.top = dif + yoffset;
	  shadow.style.top = dif + yoffset + sdw;
	}
}
