 // popup menu
function pop(name_info, path_info, width, height, scroll, resizable) {
	var str = "toolbar=0,location=0,directories=0,copyhistory=0,status=1";
	if (width != null) {
		str += ",width=" + width; }
	if (height != null) {
		str += ",height=" + height; }
	if (scroll != null) {
		str += ",scrollbars=" + scroll; }
	if (resizable != null) {
		str += ",resizable=" + resizable; }
	name_info = window.open(path_info, name_info, str);}

// show Layer || DIV
function show(DIVname) {
	if (document.layers) {
		eval("document.layers['" + DIVname + "'].visibility = 'show';") }
	else if (document.all) {
		eval("document.all['" + DIVname + "'].style.visibility = 'visible';") }}

// hide Layer || DIV
function hide(DIVname) {
	if (document.layers) {
		eval("document.layers['" + DIVname + "'].visibility = 'hide';") }
	else if (document.all) {
		eval("document.all['" + DIVname + "'].style.visibility = 'hidden';") }}

function doNothing() {
	return true;}

//Navigation Bar
var blnMoveMenu = false;

function getLayer(inName) {
	if ( document.all ) {
		return eval("document.all."+inName);	}
	else if ( document.getElementById )	{
		return document.getElementById(inName);	}
	else if ( document.layers )	{
		var lyr = eval("document." + inName); return lyr;}}

function showMenu(menuNum){
	selects = document.getElementsByTagName("SELECT");
	for ( i = 0; i < selects.length ; i++ )	{
//selects[i].style.visibility = 'hidden';
	}
	if (!blnMoveMenu)
		moveMenus();
	if (blnMoveMenu){
		getLayer("menu" + menuNum).style.visibility = 'visible';
		if ( document.all )		{
			if ((document.all.sortOption) && ((menuNum==9) || (menuNum==7)))
				document.all.sortOption.style.visibility = 'hidden';
			if ((document.all.ModelNumber) && ((menuNum==9) || (menuNum==7)))
				document.all.ModelNumber.style.visibility = 'hidden';}}}

function hideMenu(menuNum){
	selects = document.getElementsByTagName("SELECT");
	for ( i = 0; i < selects.length ; i++ )	{
		//selects[i].style.visibility = 'visible';
	}
	getLayer("menu" + menuNum).style.visibility = 'hidden';
	if ( document.all )	{
		if (document.all.sortOption)
			document.all.sortOption.style.visibility = 'visible';
		if (document.all.ModelNumber)
			document.all.ModelNumber.style.visibility = 'visible';}}

var menuName = new Array();
menuName[0] = "m_home";
menuName[1] = "m_faculty";
menuName[2] = "m_residents";
menuName[3] = "m_applicantinfo";
menuName[4] = "m_staff";
menuName[5] = "m_alumni";
menuName[6] = "m_news";
menuName[7] = "m_links";
menuName[8] = "m_contact";

var numOfMenus = 9;

function moveMenus(){
	for ( i = 0 ; i < numOfMenus ; i++ ){
		// Set X Coord of menu
		getLayer("menu" + (i+1)).style.left = getLeft(getLayer(menuName[i]))+"px";
		// Set Y Coord of menu
		getLayer("menu" + (i+1)).style.top = getTop(getLayer(menuName[i]))+getLayer(menuName[i]).offsetHeight+"px";
		// Set Z Coord of menu
		getLayer("menu" + (i+1)).style.zIndex = 1;
		// Set Width of menu
		getLayer("menu" + (i+1) + "table").width = getLayer(menuName[i]).offsetWidth+1;	}
	blnMoveMenu = true;}

function getLeft(inObj){
	var returning = 0;
	var element = inObj;
	while ( element ){
		returning += element.offsetLeft;
		element = element.offsetParent;	}
	return returning;}

function getTop(inObj){
	var returning = 0;
	var element = inObj;
	while ( element )	{
		returning += element.offsetTop;
		element = element.offsetParent;	}
	return returning;}

function getPageCoords (element){
	var coords = {x: 0, y: 0};
	while (element)	{
		coords.x += element.offsetLeft;
		coords.y += element.offsetTop;
		element = element.offsetParent;	}
	return coords;}

function openTentoeVsrWin(vsr_server, _sVsrParams){
	var sLink = 'http://'+ vsr_server +'/Syndicate/SynMaster?'+ _sVsrParams +'&ParentUrl=' + escape(window.location.href);
	window.open(sLink,'_blank', 'width=536,height=525,scrollbars=no,toolbar=no,personalbar=no,statusbar=no,directories=no,location=no,resizable=no,menubar=no,locationbar=no');}

function openNewPopUp(url, width, height){
	var w = window.open(url, 'newPopUp', 'width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes,left=100,top=50');
	if (w != null)	{
		if (w.opener == null)
			w.opener = self;
		else
			w.focus();}}

function placeImagesInMemory(){
	this.over = new Array();
	this.src = new Array();
	this.store = store;
 
    function store(src, over)	{
		var AL = this.src.length;
		this.src[AL] = new Image();
		this.src[AL].src = src;
		this.over[AL] = new Image();
		this.over[AL].src = over;}}

var imageInMemory = new placeImagesInMemory();
var mouseisdown = 0;

function preloadImages(whatTag){
	for(i=0; i<whatTag.length; i++)	{
		if(whatTag[i].getAttribute('hsrc'))	{
			storeimages(whatTag[i]);
			var valImgAttributes = '';
			valImgAttributes = (whatTag[i].getAttribute('hsrc')) ? valImgAttributes + 'A' : valImgAttributes + '';
			mouseover(whatTag[i]);
			mouseout(whatTag[i]);
			if(whatTag[i].src){
				whatTag[i].setAttribute("oldsrc", whatTag[i].src);}}}}

function mouseover(t){
	var newmouseover;
	if(t.onmouseover)	{
		t.oldmouseover=t.onmouseover;
		newmouseover= function(){
			this.src = this.getAttribute("hsrc");
			this.oldmouseover();}}
	else{
		newmouseover = function(){
			this.src = this.getAttribute("hsrc");}}
	t.onmouseover = newmouseover;}

function mouseout(t){
	var newmouseout;
	if(t.onmouseout){
		t.oldmouseout=t.onmouseout;
		newmouseout = function(){
			this.src = this.getAttribute("oldsrc");
			this.oldmouseout();}}
	else{
		newmouseout = function(){
			this.src = this.getAttribute("oldsrc");}}
	t.onmouseout = newmouseout;}

function storeimages(t){
	var s = (t.getAttribute('src'))?t.getAttribute('src'):'';
	var o = (t.getAttribute('hsrc'))?t.getAttribute('hsrc'):'';
	imageInMemory.store(s,o);}

function preloadimgsrc(){
	if(!document.getElementById) return;
	var imgTag = document.getElementsByTagName('IMG');
	var inputTag = document.getElementsByTagName('INPUT');
	preloadImages(imgTag);
	preloadImages(inputTag);}

if(window.addEventListener){
	window.addEventListener("load", preloadimgsrc, false);} 
else{
	if(window.attachEvent){
		window.attachEvent("onload", preloadimgsrc);}
	else{
		if(document.getElementById)	{
			window.onload = preloadimgsrc;}}}