﻿// JScript File

/////////////////////////////////////////////////////////////
//Global Variables For Use With Dynamic FlyOut Menus
/////////////////////////////////////////////////////////////
var timerID = null;
var timerOn = false;
var timecount = 400;

/////////////////////////////////////////////////////////////
//Makes Sure All Necessary Absolutely Positioned Elements Stay In Correct State/Position On window.onresize Event
/////////////////////////////////////////////////////////////
window.onresize = PlaceChilrenChessBottomImage;
window.onresize = PlaceHeaderText;

/////////////////////////////////////////////////////////////
//Shows Dynamic Sub Menu, Need The TD ID To Get The Correct X,Y Lccation Of TD Tag
//So We Can Place The Dynamic Sub Menu Div Element In The Correct Position
/////////////////////////////////////////////////////////////
function ShowDynamicMenu(tdID, divSubMenuName) {
    var offsetTrail = document.getElementById(tdID);
    var offsetLeft = 0;
    var offsetTop = 0;

    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    //Set Position/Visibility Of Dynamic Menu
	document.getElementById(divSubMenuName).style.visibility = "visible";
	document.getElementById(divSubMenuName).style.display = 'block';
    document.getElementById(divSubMenuName).style.position = 'absolute';
	document.getElementById(divSubMenuName).style.left = offsetLeft + 120;	
	document.getElementById(divSubMenuName).style.top = offsetTop;
}

/////////////////////////////////////////////////////////////
//Set The CSS Style Of The Static MousedOver TD Cell
/////////////////////////////////////////////////////////////
function StopTime(tdCell) {
	document.getElementById(tdCell).style.cursor = "pointer";
	document.getElementById(tdCell).style.backgroundColor = "#1B2D05";
	document.getElementById(tdCell).style.color = "#FFFFFF";

	if (timerOn) {
    	clearTimeout(timerID);
        timerID = null;
        timerOn = false;
	}
}

/////////////////////////////////////////////////////////////
//Sets Dynamic MenuItems Style When MousedOver
/////////////////////////////////////////////////////////////
function DynamicMenuItemStyleHover(tdCell) {
	tdCell.style.cursor = "pointer";
    tdCell.style.backgroundColor = "#E5DD9E";
}

/////////////////////////////////////////////////////////////
//Sets Dynamic MenuItems Style When MousedOut
/////////////////////////////////////////////////////////////
function DynamicMenuItemStyle(tdCell) {
    tdCell.style.backgroundColor = "#FFFADF";
}

/////////////////////////////////////////////////////////////
//Set The CSS Style Of The Static MousedOut TD Cell
/////////////////////////////////////////////////////////////
function StartTime(tdCell) {
	document.getElementById(tdCell).style.backgroundColor = "#FFFFFF";
	document.getElementById(tdCell).style.color = "#0E1800";
	
	if (timerOn == false) {
         timerID=setTimeout( "HideAllDynamicMenus()" , timecount);
         timerOn = true;
	}
}

/////////////////////////////////////////////////////////////
// Navigates To Supplied URL
/////////////////////////////////////////////////////////////
function NavigateURL(URL) {
	window.location = URL;
}

/////////////////////////////////////////////////////////////
//Hides All Dynamic Menus
/////////////////////////////////////////////////////////////
function HideAllDynamicMenus() {
	HideDynamicMenu('divCounseling');
	HideDynamicMenu('divAboutUs');
	HideDynamicMenu('divAcademics');
	HideDynamicMenu('divHealthCenter');
	HideDynamicMenu('divAdmissions');
	HideDynamicMenu('divStaff');
	HideDynamicMenu('divStudent');
	HideDynamicMenu('divLocation');
}

/////////////////////////////////////////////////////////////
//Hides Single Dynamic Menu, Used By Function HideAllDynamicMenus()
/////////////////////////////////////////////////////////////
function HideDynamicMenu(divDynamicMenu) {
    if (document.getElementById(divDynamicMenu).style.display != "none")
    {
        document.getElementById(divDynamicMenu).style.display = "none"
    }
}

/////////////////////////////////////////////////////////////
//Note No Longer In Use
//Places Bottom Of Children Playing Chess In The Body Content
/////////////////////////////////////////////////////////////
function PlaceChilrenChessBottomImage() {
    var offsetTrail = document.getElementById('tdContent');
    var offsetLeft = 0;
    var offsetTop = 0;

    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    
	document.getElementById('chilren_chess_bottom').style.display = 'block';
    document.getElementById('chilren_chess_bottom').style.position = 'absolute';
	document.getElementById('chilren_chess_bottom').style.left = offsetLeft + 382;	
	document.getElementById('chilren_chess_bottom').style.top = offsetTop;	
	document.getElementById('chilren_chess_bottom').style.visibility = "visible";	
}


/////////////////////////////////////////////////////////////
//Places Header Text In Header
/////////////////////////////////////////////////////////////
function PlaceHeaderText() {
    var offsetTrail = document.getElementById('tdHeader');
    var offsetLeft = 0;
    var offsetTop = 0;

    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    
	document.getElementById('divHeaderText').style.display = 'block';
    document.getElementById('divHeaderText').style.position = 'absolute';
	document.getElementById('divHeaderText').style.left = offsetLeft + 15;	
	document.getElementById('divHeaderText').style.top = offsetTop + 155;	
	document.getElementById('divHeaderText').style.visibility = "visible";	
}


/////////////////////////////////////////////////////////////
//Places Semi-Random Image In The Top Right Of Header Image
/////////////////////////////////////////////////////////////
function PlaceImageInHeader() {
    var offsetTrail = document.getElementById('tdHeader');
    var offsetLeft = 0;
    var offsetTop = 0;

    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    
	document.getElementById('divDynamicHeaderImage').style.display = 'block';
    document.getElementById('divDynamicHeaderImage').style.position = 'absolute';
	document.getElementById('divDynamicHeaderImage').style.left = offsetLeft + 388;	
	document.getElementById('divDynamicHeaderImage').style.top = offsetTop + 165;	
	document.getElementById('divDynamicHeaderImage').style.visibility = "visible";	
}


//Code Below Is Used To Disable contextMenu
//Needed For Netscape, Firefox, etc.
if (document.captureEvents)
{
	document.captureEvents(Event.MOUSEDOWN);
}

//Used To Disable contextMenu
function DisableContextMenu() {
	//alert("Sorry, this action is not permitted.");
	//return false;
}

document.oncontextmenu = DisableContextMenu;

//Opens New Window
function WindowOpen(URL) {
	window.open(URL, 'Photos', 'menubar=0,width=820,height=600,scrollbars=1');
}

//Adds Hand Pointer To Moused Over Images
function MakePointer(id) {
	id.style.cursor = "pointer";
}

