function startup() {
    document.imageBaseUrl = webSiteRoot+'MasterPages/';
	MM_preloadImages('../MasterPages/images/about-rollover.gif','../MasterPages/images/admissions-rollover.gif','../MasterPages/images/academics-rollover.gif','../MasterPages/images/athletics_rollover.gif','../MasterPages/images/studentlife-rollover.gif','../MasterPages/images/news-rollover.gif','../MasterPages/images/giving-rollover.gif','../MasterPages/images/alumni-rollover.gif','../MasterPages/images/about-rollover.gif','../MasterPages/images/studentslink_rollover_noyellow.gif','../MasterPages/images/parentslink_rollover_noyellow.gif','../MasterPages/images/newshomebuttonoff.png','../MasterPages/images/sportshomebuttonon.png')
	
	var el = document.getElementById("SideMenu");
	var bodyEl = document.getElementById("SiteContent");
	var bodyTextEl = document.getElementById("ScrollableBodyCopy");//Named in child templates that want a scrollable region
	if ( el != null && bodyEl != null && bodyTextEl != null ) {
	    //alert("el=" + el.clientHeight + " body=" + bodyEl.clientHeight);
		if ( el.clientHeight > bodyEl.clientHeight ) {
			bodyTextEl.style.height = (el.clientHeight - bodyEl.clientHeight) + 'px';
		}
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var webSiteRoot = window.location.protocol + "//" + window.location.host + "/";

function OpenMediaFile( mediaID )
{
	openWindow(webSiteRoot + 'ShowMedia.aspx?type=radwindow&MediaID=' + mediaID, 'mediaWindow', 'width=800,height=600,status=0,location=0,menubar=0');
    //var win = radopen(webSiteRoot + "ShowMedia.aspx?type=radwindow&MediaID=" + mediaID, "radMediaWindow")
    //win.set_title("OpenMedia Title");
    //win.set_status("OpenMedia Status");
}

function ShowFaculty(facultyId) {
  var win = radopen(webSiteRoot + "pages/FacultyBio.aspx?FacultyId=" + facultyId, "radFacultyWindow");
  win.setSize(500, 540);
  win.center();
}

/* Return a handle to the current rad window. Can be used inside an open radwindow */
function GetRadWindow()
{
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;//Will work in Moz in all cases, including clasic dialog
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz az well)
    return oWindow;
} 

function ShowSiteMap() {
    var win = radopen(webSiteRoot + "pages/SiteMap.aspx", "radMediaWindow");
    win.setSize(400, 600);
    win.center();
}

function ShowCriticalNews() {
    var win = radopen(webSiteRoot + "pages/CriticalNews.aspx", "rwCriticalNews");
    win.setSize(400, 300);
    win.center();
}

/* 
* Scan all the news section blocks. If they are larger than 100 then resize down to 100 
* if they are a good size then leave them alone but delete the contents of the next div
* which contains the readme block
*/
function ResizeNewsSections() {
    ResizeDivSections('newsBox', 'newsBoxCopy', 105);
    }
    
/*
 * Scan the div specified by the wrapperDiv
 * Find all div's inside which have the class name divClassName
 * Resize the div down to divHeight. If already that hight then clear out the readMore div for that block
 */
function ResizeDivSections( wrapperDiv, divClassName, divHeight )
{    
	var div = document.getElementById(wrapperDiv);
	var divList = div.getElementsByTagName('div');
	for( var i=0; i<divList.length; ++i ) {
		var el = divList[i];
		if ( el.className == divClassName ) {
		    if (el.clientHeight > divHeight) {
		        el.style.height = divHeight + "px";
		    }
		    else {
		        // clear out the read more
		        for (var j = i + 1; j < divList.length; ++j) {
		            if (divList[j].className == 'readMore') {
		                divList[j].innerHTML = "";
		                break;
		            }
		        }
		    }
		}
    }
}

/* Quicklinks javascript */
var qlTimeout = null;
function showQuickLinksMenu (ev) {
	clearQuickLinksHideTimer();
	//get the position of the placeholder element
	var qlpos = $("#qlLink").offset();  
	var qlheight = $("#qlLink").height() - 53;
	//show the menu directly over the placeholder
	$("#divQuickLinks").css( { "left": (qlpos.left-13) + "px", "top":(qlpos.top + qlheight) + "px" } );
	$("#divQuickLinks").show();
}

function clearQuickLinksHideTimer()
{
	clearTimeout(qlTimeout);
}

function hideQuickLinksMenu (ev) {
	qlTimeout = setTimeout('$("#divQuickLinks").hide()', 1000);
}
/* End Quicklinks stuff */

$(document).ready(function(){
	// Add quicklinks functions
	if ($('#qlLink') != null)
	{
		$("#qlLink").mouseover(showQuickLinksMenu);
		$("#qlLink").mouseleave(hideQuickLinksMenu);
		$("#divQuickLinks").mouseenter(clearQuickLinksHideTimer).mouseleave(hideQuickLinksMenu);
	}
});