//
//sathomemenu_com.js is the file that will hold the necessary javascript components to make the homepage
//function correctly.  
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//
// findDOM.js  use this to find the DOM
////////////////////////////////////////
var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;
var isNS6 = 0;
var isWindows = 0;
var isMac = 0;
var isOtherOS = 0;

if(document.getElementById)
{
	isID = 1;
	isDHTML = 1;
	if(navigator.appName.indexOf('Netscape') != -1)
		isNS6 = 1;
}
else
{
	if(document.all)
	{
		isAll = 1;
		isDHTML = 1;
	}
	else
	{
		browserVersion = parseInt(navigator.appVersion);
		if((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4))
		{
			isLayers = 1;
			isDHTML = 1;
		}
	}
}

if (navigator.appVersion.indexOf("Win")!=-1) isWindows = 1;
else if (navigator.appVersion.indexOf("Mac")!=-1) isMac = 1;
else isOtherOS = 1;

if(isLayers)
{
	window.location.href = "http://www.netscape.com";
	alert('Netscape 4 is not supported. Please download more recent version of Netscape.');
		
}




function findDOM(objectID, withStyle){
	if(withStyle == 1){
		if(isID){
			return (document.getElementById(objectID).style);
		}
		
		else{
			if(isAll){
				return (document.all[objectID].style);
			}
			else{
				if (isLayers){
					return (document.layers[objectID]);
				}
			};
		}
	}
	else {
		if(isID){
			return (document.getElementById(objectID));
		}
		else{
			if(isAll){
				return (document.all[objectID]);
			}
			else{
				if(isLayers){
					return (document.layers[objectID]);
				}
			};
		}
	}
}

//
// popMenu
///////////////////////
var oldDOM = null;
var oldPicId = null;
function popMenu(picId)
{
	var menuTop = 0;		//position of top edge of menu (will be reassigned)
	var menuLeft = 0;		//position of left edge of menu (will be reassigned)
	var menuDOM = null;		//records DOM for the current menu
	var picDOM = null;
	
	if (isDHTML)		
	{
		
		//determine image DOM and menu DOM
		if (picId == 'faculty')
		{
			if(oldDOM)
			{
				if((oldPicId != null) && (oldPicId == 'faculty')) return;
				oldDOM.visibility = 'hidden';
				oldDOM.zIndex = '0';
			}			
			picDOM = findDOM(picId,0);
			menuDOM = findDOM('facultyMenu', 1);		
		}
		else if (picId == 'general')
		{
			if(oldDOM)
			{
				if((oldPicId != null) && (oldPicId == 'general')) return;
				oldDOM.visibility = 'hidden';
				oldDOM.zIndex = '0';
			}
			picDOM = findDOM(picId,0);
			menuDOM = findDOM('generalMenu', 1);
		}
		else if (picId == 'miscellanea')
		{
			if(oldDOM)
			{
				if((oldPicId != null) && (oldPicId == 'miscellanea')) return;
				oldDOM.visibility = 'hidden';
				oldDOM.zIndex = '0';
			}	
			picDOM = findDOM(picId,0);
			menuDOM = findDOM('miscellaneaMenu', 1);
		}
		else if (picId == 'registration')
		{
			if(oldDOM)
			{
				if((oldPicId != null) && (oldPicId == 'registration')) return;
				oldDOM.visibility = 'hidden';
				oldDOM.zIndex = '0';
			}
			
			picDOM = findDOM(picId,0);
			menuDOM = findDOM('registrationMenu', 1);	
		
		}
		else if (picId == 'gallery')
		{
			if(oldDOM)
			{
				if((oldPicId != null) && (oldPicId == 'gallery')) return;
				oldDOM.visibility = 'hidden';
				oldDOM.zIndex = '0';
				oldDOM = null;
				oldPicId = null;
				return;
			}
			return;
		}
		else if (picId == 'faqs')
		{
			if(oldDOM)
			{
				if((oldPicId != null) && (oldPicId == 'faqs')) return;
				oldDOM.visibility = 'hidden';
				oldDOM.zIndex = '0';
				oldDOM = null;
				oldPicId = null;
				return;
			}
			return;
		}
	
		else return null;

		if (isID || isAll)
		{
			if (picId == 'faculty')
			{
				menuLeft = (picDOM.offsetLeft) + 15;
				menuTop = (picDOM.offsetTop) + 63;
				//document.images.facultyPic.src = "art/faculty_open.gif";
			}
			else if (picId == 'general')
			{
				menuLeft = (picDOM.offsetLeft) + 11;
				menuTop = (picDOM.offsetTop) + 44;	
				//document.images.generalPic.src = "art/general_open.gif";
			}
			else if (picId == 'miscellanea')
			{
				menuLeft = (picDOM.offsetLeft) + 13;
				menuTop = (picDOM.offsetTop) + 63;	
				//document.images.miscellaneaPic.src = "art/mix_open.gif";
			}
			else if (picId == 'registration')
			{
				menuLeft = (picDOM.offsetLeft) + 13;
				menuTop = (picDOM.offsetTop) + 45;	
				//document.images.registrationPic.src = "art/register_open.gif";
			}
		}

		if (isLayers)
		{
			menuLeft = document.layers[picId].pageX + 5;
			menuTop = document.layers[picId].pageY + 5;		
		}
		
		
		menuDOM.left = menuLeft;
		menuDOM.top = menuTop;
		menuDOM.zIndex = '100';
		menuDOM.visibility = 'visible';
		oldDOM = menuDOM;
		oldPicId = picId;
		
	}
	else
	{
		return null;
	}
}

function findX(evt)
{
	if(evt.x) 
	{
		return (evt.x);
	}
	if(evt.pageX) 
	{
		
		return evt.pageX;
	}
}

function findY(evt)
{
	if(evt.y) return evt.y;
	if(evt.pageY) return evt.pageY;
}

//
// hideMenu
/////////////////////////////////////////////////////////////////////////////

var mouseX = null;
var mouseY = null;

function getXY(evt)
{
	mouseX = evt.pageX;
	mouseY = evt.pageY;
}


function hideMenu(menu)
{
	
	if(isNS6)
	{
		window.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = getXY;
	}
	else
	{
		mouseX = findX(event);
		mouseY = findY(event);
	}

	if (menu == 'facultyMenu')
	{
		if(!isNS6 && !isMac)
		{
			if((mouseX >= 155 && mouseX <= 273) && (mouseY >= 518)) return;
			else
			{	
				menuDOM = findDOM(menu, 1);
				if(menuDOM.visibility == 'visible')
				{	
					menuDOM.visibility = 'hidden';
					menuDOM.zIndex = '0';
					oldDOM = null;
					oldPicId = null;
				}
			}
		}
	}
	else if (menu == 'generalMenu')
	{
		if(!isNS6 && !isMac)
		{
			if((mouseX >= 136 && mouseX <= 263) && (mouseY >= 324)) return;
			else
			{	
				menuDOM = findDOM(menu, 1);
				if(menuDOM.visibility == 'visible')
				{	
					menuDOM.visibility = 'hidden';
					menuDOM.zIndex = '0';
					oldDOM = null;
					oldPicId = null;
				}
			}
		}
	}
	else if (menu == 'miscellaneaMenu')
	{	
		if(!isNS6 && !isMac)
		{
			if((mouseX >= 415 && mouseX <= 571) && (mouseY >= 486)) return;
			else
			{	
				menuDOM = findDOM(menu, 1);
				if(menuDOM.visibility == 'visible')
				{	
					menuDOM.visibility = 'hidden';
					menuDOM.zIndex = '0';
					oldDOM = null;
					oldPicId = null;
				}
			}
		}
	}
	else if (menu == 'registrationMenu')
	{
		if(!isNS6 && !isMac)
		{
			if((mouseX >= 476 && mouseX <= 641) && (mouseY >= 395)) return;
			else
			{	
				menuDOM = findDOM(menu, 1);
				if(menuDOM.visibility == 'visible')
				{	
					menuDOM.visibility = 'hidden';
					menuDOM.zIndex = '0';
					oldDOM = null;
					oldPicId = null;
				}
			}
		}
		
	}
	
}
	