var gDefaultPage = "http://offers.thumbplay.com/plp/smooth/landing.do?method=home&pname=184a&ptrx=smooth&thpcampid=1111&iframe=true";
var localThumbPlay ="includes/mfly.php";
var gMinHeight = 0;
var gPopFrame = null;
var myFrame = null;
var width=500;
var height=1200;

function initPopUp() {
	//inject the locally hosted clone of thumbplay into a hidden div
	theBody = document.getElementsByTagName('BODY')[0];
	popcont = document.createElement('div');
	popcont.id = 'popupContainer';
	popcont.innerHTML = ''+'<iframe src="'+ localThumbPlay +'" style="width:100%;height:100%;background-color:transparent;" scrolling="yes" frameborder="0" allowtransparency="true" id="myFrame" name="myFrame" width="100%" height="100%"></iframe>' + '';
	theBody.appendChild(popcont);
	gPopupContainer = document.getElementById("popupContainer");
	gPopupContainer.style.height = 1 + "px";
	divHolder = document.getElementById("frameHolder");	
	divHolder.innerHTML = '' + '<iframe src="'+ gDefaultPage +'" style="width:571px;height:100%;background-color:transparent;" scrolling="no" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="571" height="100%"></iframe>'+'';
	gPopFrame = document.getElementById("popupFrame");
	myFrame = document.getElementById('myFrame');

	showPopWin(this.href,width,height); return false;
}

addEvent(window, "load", initPopUp);

function showPopWin(url, width, height) {
	//gPopupIsShown = true;
	gMinHeight = height;
	
	gPopFrame.style.height = parseInt(gMinHeight) + "px";
	
	//set height dynamically
	gSetHeight();
	// set the url
	gPopFrame.src = url;
} 

function gSetHeight() {
	if((myFrame.contentWindow.document.body == null) || (myFrame.contentWindow.document.body.scrollHeight == null)) {
		setTimeout("gSetHeight()",500);
		}
	if((myFrame.contentWindow.document.body.scrollHeight) > gMinHeight){
		gPopFrame.style.height = parseInt(myFrame.contentWindow.document.body.scrollHeight) + "px";
		}
	else{	
	//do something
	//gPopFrame.style.height = parseInt(gMinHeight) + "px";
	}
	setTimeout("gSetHeight()",250);
}