function showPopupPage(file1, file2, appInfo, width, height, callback){

    if(isIE6()) hideSelects();

    var html = "<br />" + appInfo + "<br /><img src='pics/floorplans/" + file1 + "'/>";
    //html += "<div style='float:left;'><img src='pics/floorplans/" + file2 + "'/>";
    //html += "<br />" + appInfo;
    //html += "</div><div style='clear:both'></div>";


    setHtmlTo("photo-content", html);
    resizePopup(width, height);
    showElements("photo-popup");
    
	/*
    if(isIE6()) hideSelects();
    if(loadDoc(page, createDelegate(this, setPopupContent, callback || null))){
		if(element("photo-content").innerHTML.length == 0){
			setHtmlTo("photo-content", "loading content, please wait...");
		}
		resizePopup(width, height);
		showElements("photo-popup");
		//movePopupOnScroll();
		return false;
	}*/
	return true;
}
function setPopupContent(callback, doc){
	setHtmlTo('photo-content', doc.responseText);
	if(callback) callback();
}
function movePopupOnScroll(){
	if(isVisible("photo-popup")){
		var xOffset = getXOffset();
		var yOffset = getYOffset();
		var width = styleToNum(getStyle("photo-popup", "width"));
		var height = styleToNum(getStyle("photo-popup", "height"));
		//var margin = Math.max(0, Math.floor(yOffset-height/2))+"px 0 0 "+Math.max(0, Math.floor(xOffset-width/2))+"px";
		var margin = Math.max(-getInnerHeight()/2, Math.floor(yOffset-height/2))+"px 0 0 "+Math.max(-getInnerWidth()/2, Math.floor(xOffset-width/2))+"px";
		setStyle("photo-popup", "margin", margin);
		//setHtmlTo("photo-content", "time: "+(new Date().getTime())+"<br/>scrollLeft: "+xOffset+"<br/>scrollTop: "+yOffset+"<br/>width: "+width+"<br/>height: "+height+"<br/>margin: "+margin);
	}
}
function resizePopup(width, height){
	var xOffset = getXOffset();
	var yOffset = getYOffset();
	//var margin = Math.max(0, Math.floor(yOffset-height/2))+"px 0 0 "+Math.max(0, Math.floor(xOffset-width/2))+"px";
	var margin = Math.max(-getInnerHeight()/2, Math.floor(yOffset-height/2))+"px 0 0 "+Math.max(-getInnerWidth()/2, Math.floor(xOffset-width/2))+"px";
	//setStyles("photo-content", [["width",width+"px"], ["height", height+"px"]]);
	//setStyles("photo-popup", [["width",width+"px"], ["height", height+"px"], ["margin", margin]]);
	setStyles("photo-popup", [["margin", "50px 0 0 -" + (width/2) + "px"]]);
	setStyles("photo-popup", [["width", width + "px"]]);
    document.getElementById("curtain").style.display = "block";
}
function closePopup(){
	hideElements("photo-popup");
	element("photo-content").innerHTML = "";
	if(isIE6()) showSelects();
    document.getElementById("curtain").style.display = "none";
}

// dropdowns
function showSelects(){
	var selects = document.getElementsByTagName("select");
	for(var i=0; i < selects.length; i++){
		selects[i].style.visibility = "visible";
	}
}
function hideSelects(){
	var selects = document.getElementsByTagName("select");
	for(var i=0; i < selects.length; i++){
		selects[i].style.visibility = "hidden";
	}
}

//=============================== POPUP OPENER ==========================
function openBrWindow(theURL, Name, popW, popH, scrollbars) {
	if (!(theURL.length>0))
		return false;
	var winleft = Math.max(0, (screen.width-popW)/2);
	var wintop = Math.max(0, (screen.height-popH)/2);
	popFullH = popH + 60;
	popFullW = popW + 24;
	winProp = 'width='+popFullH+',height='+popFullW+',left='+winleft+',top='+wintop+',scrollbars='+(scrollbars?1:0)+',status=1,resizable=0';
	Name = window.open(theURL, Name, winProp)
//	if (Number(navigator.appVersion) >= 4) { 
//		Name.window.focus();
//	}
	Name.focus();
}
//=============================== text resizer ==========================

// scroll scruct
var scrollStruct = new Struct();
var popupScrollId = scrollStruct.add(createDelegate(this, movePopupOnScroll));

//window.onscroll = 
window.onresize = function(){
	scrollStruct.dispatch();
}
