var pop_visible;
var pop_resizes;

function getscrolly() {
	//http://www.quirksmode.org/viewport/compatibility.html
	var x,y;
	if (self.pageYOffset) // all except Explorer
	{
		x = self.pageXOffset;
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	return y;
}

function getwindowy() {
	//http://www.quirksmode.org/viewport/compatibility.html
	var x,y;
	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;
	}
	return y;	
}

function getwindowx() {
	//http://www.quirksmode.org/viewport/compatibility.html
	var x,y;
	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;
	}
	return x;	
}
function fixsize() {
	//prevent bouncing:
	if (pop_resizes < 3) {
		pop_resizes++;
		if (pop_visible) {
			var p = document.getElementById('pop_container').style;
			if (ismoz()) {	 //do it properly
				p.position = "fixed";
				p.top=55;
			} else { //hack around generally broken position:fixed implementation
				p.top = getscrolly() + 55;
			}
			p.left = "10px";
			p.width = (getwindowx() - 20) + "px";
			p.height = (getwindowy() - 80) + "px";
			//alert ("was " + p.height);
			//alert ("Setting pop_container height to " + (getwindowy() - 80) + "px");
			//alert ("now " + p.height);
			document.getElementById('pop_win').style.height=p.height;
			document.getElementById('pop_win').style.width=(getwindowx() - 60) + "px";
		}
	}
}

function pop(url) {
	//alert (url);
	pop_visible = true;
	document.getElementById('pop_iframe').src = url;
	document.getElementById('pop_container').style.visibility="visible";
	pop_resizes = 0;
	fixsize();
	return false; //tell browser not to fallback to just navigating to the page
}

function unpop() {
	pop_visible = false;
	var p = document.getElementById('pop_container').style;	
	p.visibility="hidden";
	p.left=-2000;
	return true;
}

