// Returns the width and height of the window
window.size = function()
{
	var w = 0;
	var h = 0;

	//IE
	if(!window.innerWidth)
	{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};
}

// Returns the calculated center point of the viewport
window.center = function() {
    var hWnd = (arguments[0] != null) ? arguments[0] : { width: 0, height: 0 };

    var _x = 0;
    var _y = 0;
    var offsetX = 0;
    var offsetY = 0;
    
    //IE
    if (!window.pageYOffset) {
        //strict mode
        if (!(document.documentElement.scrollTop == 0)) {
            offsetY = document.documentElement.scrollTop;
            offsetX = document.documentElement.scrollLeft;
        }
        //quirks mode
        else {
            offsetY = document.body.scrollTop;
            offsetX = document.body.scrollLeft;
        }
    }
    //w3c
    else {
        offsetX = window.pageXOffset;
        offsetY = window.pageYOffset;
    }
    
    _x = ((this.size().width - hWnd.width) / 2) + offsetX;
    _y = ((this.size().height - hWnd.height) / 2) + offsetY;

    return { x: _x, y: _y };
}

window.right = function()
{
	var hWnd = (arguments[0] != null) ? arguments[0] : {width:0,height:0};

	var _x = 0;
	var _y = 0;
	var offsetX = 0;
	var offsetY = 0;

	//IE
	if(!window.pageYOffset)
	{
		//strict mode
		if(!(document.documentElement.scrollTop == 0))
		{
			offsetY = document.documentElement.scrollTop;
			offsetX = document.documentElement.scrollLeft;
		}
		//quirks mode
		else
		{
			offsetY = document.body.scrollTop;
			offsetX = document.body.scrollLeft;
		}
	}
	//w3c
	else
	{
		offsetX = window.pageXOffset;
		offsetY = window.pageYOffset;
	}

	_x = ((this.size().width-hWnd.width)/2)+offsetX;
	_y = ((this.size().height-hWnd.height)/2)+offsetY;

	return{x:_x,y:_y};
}

var attemptToSetHeight = 0;
function setHeight() {
    //document.getElementById("facultySearchIframePopup").style.height = document.getElementById("facultySearchIframePopup").contentWindow.document.document.getElementById("basicinfocontainer").offsetHeight + "px";

    var iframe = document.getElementById("facultySearchIframePopup");
    var topwrapper = iframe.contentWindow.document.getElementById("basicinfocontainer");
    if (iframe.contentWindow.document.innerHTML != "" && topwrapper) {
        var newwindowheight = ((topwrapper.offsetHeight) + 46) + "px";
        var newscrollableheight = ((topwrapper.offsetHeight) - 0) + "px";

        if (iframe.style.height == newwindowheight || iframe.style.height == "" || iframe.style.height == "233px") {
            iframe.style.height = topwrapper.offsetHeight + "px";
        }
        else {
            iframe.style.height = newwindowheight;
            topwrapper.style.height = newscrollableheight;
        }
    }
    else if (attemptToSetHeight < 40) {
        attemptToSetHeight++;
        setTimeout("setHeight();", 250);
    }

}
