// JavaScript Document

window.onresize = function() {
	var size = getBrowserContentSize();
}

//////////////////////////////////
//		COMMON EXT.JS USE		//
//////////////////////////////////

Ext.onReady(function() { autoShowWindowOnLoad(); });

function autoShowWindowOnLoad() {
	var page = "http://saas.byu.edu/ebrochure/BYU_Financial_Aid_and_Scholarships_Guide/";
	var url = top.window.location.toString();
	var temp;
	
	if (url.indexOf("?") != -1) {
		temp = url.split("?")[1];
		if (temp.indexOf("=") != -1) {
			temp = temp.split("=")[1];
			page = temp;
		}
	}
	
	openExtWindow(page, "Financial Aid and Scholarships");
}

function openExtWindow(elemOrURL, title) {
	var url;
	var size = getBrowserContentSize();
	var w, h;
	
	//get url
	if (typeof(elemOrURL) == "string") {
		url = elemOrURL;
	} else {
		url = elemOrURL.getAttribute("href");	
	}
	
	//get width and height
	w = 900;
	h = Math.round(size[1] * .9);
	if (size[0] < 900) w = size[0] - 20;
	if (size[1] < 600) h = size[1] - 20;
	
	new Ext.Window({
		title: title,
		width: w,
		height: h,
		maximizable: true,
		resizable: true,
		closable: true,
		modal: true,
		html: "<iframe id='" + this.id + "_iframe' src='" + url + "' width='100%' frameborder='0'></iframe>",
		listeners: {
			resize: function(panel, w, h) {
				Ext.get(panel.id).dom.getElementsByTagName("iframe")[0].style.height = (h - 32) + "px";
			}
		}
	}).show();
}