﻿// JScript File
var openWindow;
var divScrollUp = false;
var menu = "";
var height = 0;
var origHt = 0;
var extot = 0;
var div;
//------------------------------------------------------------------------------------------------------------------------------
function menuDown(curMenu){
    //  if menu is already down do nothing and exit
    if (menu == curMenu) { return; }
    //  if a different menu is dropping, stop it
    if (extot != 0) { clearTimeout(extot); extot = 0; }
    //  if a different menu is down, hide it
    if (menu != "" && curMenu != menu) { hideMenu(); }
    //  set new menu
    menu = curMenu;
    //  get the full height of the menu items so we know when to stop dropping
    origHT = document.getElementById("items" + menu).offsetHeight;
    div = document.getElementById("menu" + menu);
    //  set the top, left and width, make it visible and the top most element on the page
    div.style.top = document.getElementById("ASAP_side").offsetTop - 11 + "px";
    div.style.left = document.getElementById("img" + menu).offsetLeft + "px";
    div.style.width = document.getElementById("img" + menu).width + "px";
    div.style.visibility = "visible";
    div.style.zIndex = 500;
    //  drop the menu
    dropDown();
}
//------------------------------------------------------------------------------------------------------------------------------
function hideMenu() {
    //  hide the currently opened menu and reset variables
    div.style.height = "0px"
    div.style.visibility = "hidden";
	div.zIndex = "1";
	menu = "";
	height = 0;
}
//------------------------------------------------------------------------------------------------------------------------------
function moveOut(evt){
    //  decide what to do when mouse leaves element
    //  where did the mouse go TO (IE/Foxfire)
    if(!evt) {evt = window.event}
    var eTo = (evt.toElement) ? evt.toElement : (evt.relatedTarget) ? evt.relatedTarget : null;
    //  if TO is part of the menu in some way do nothing and exit
    if (eTo.id.indexOf(menu)>0) { return; }
    
    // if we moved out of the menu while it is still dropping, stop it
    if (extot != 0) { clearTimeout(extot); extot = 0;}
    //  raise the menu
    pullUp();
}
//------------------------------------------------------------------------------------------------------------------------------
function pullUp(){
    //  decrease the height by 10
    height-=10;
    if (height < 0) { height = 0 }
    div.style.height = height + "px";

    // if not fully raised, keep pulling up. else hide the menu
	if (height > 0) {
		extot = setTimeout('pullUp()',5);
	}
	else{
	    extot = 0;
	    hideMenu();
    }
}	
//------------------------------------------------------------------------------------------------------------------------------
function dropDown(){
    //  increase the height by 10
    height+=10;
    if (height > origHT) { height = origHT; extot = 0; }
    div.style.height = height + "px";

    // if we're not at the full menu height, keep dropping
	if (height < origHT) {
		extot = setTimeout('dropDown()',5);
	}
}
//------------------------------------------------------------------------------------------------------------------------------
function ShowModallessWindow(pURL,pHeight,pWidth,pHasScrollBars)
{
	var strWindowWidth = pWidth;
	var strWindowHeight = pHeight;
	
	var strLeft = window.screen.availWidth;
	var strTop = window.screen.availHeight;
	strLeft = ( (strLeft - strWindowWidth) / 2);
	strTop = ( (strTop - strWindowHeight) / 2);
	
	
openWindow = window.open(''+pURL+'',"","top="+strTop+",left="+strLeft+",height="+strWindowHeight+",width="+strWindowWidth+",status=0,resizable=1,scrollbars="+pHasScrollBars+",toolbar=0");
}
//------------------------------------------------------------------------------------------------------------------------------
function openEvent(el, id){
    if(document.getElementById('Events').style.display=='block'){
        closeEvent();
    }
    
    var obj = el;
    var tp = 0;
    if (obj.offsetParent) {
        do {
			tp += obj.offsetTop;
        } while (obj = obj.offsetParent);

    }
    document.getElementById('Event'+id).style.display='block';
    //document.getElementById('Events').style.top=tp+'px';
    document.getElementById('Events').style.display='block';
    return false;
}
//------------------------------------------------------------------------------------------------------------------------------
function closeEvent(){
    if(document.getElementById('Events').style.display=='block'){
        for(var ediv=1;ediv<=6;ediv++){
            document.getElementById('Event'+ediv).style.display='none';
        }
        document.getElementById('Events').style.display='none';
    }
    return false;
}
//------------------------------------------------------------------------------------------------------------------------------
function openFunder(el,id){
    if(document.getElementById('funders').style.display=='block'){
        closeFunder();
    }
    
    var obj = el;
    var tp = 0;
    if (obj.offsetParent) {
        do {
			tp += obj.offsetTop;
        } while (obj = obj.offsetParent);

    }
    document.getElementById(id).style.display='block';
    document.getElementById('funders').style.display='block';
}
//------------------------------------------------------------------------------------------------------------------------------
function closeFunder(){
    if(document.getElementById('funders').style.display=='block'){
        document.getElementById('chess').style.display='none';
        document.getElementById('dance').style.display='none';
        document.getElementById('debate').style.display='none'; 
       document.getElementById('scrabble').style.display='none';  
        document.getElementById('funders').style.display='none';
    }
    return false;
}
