﻿
//
// Global Variables
//
var objSiteControl = new Array();
var iScrollID = null;

//
// Global Register
//
this.RegisterPage( 'login', 'Login', '#7B979B', '#D7DDDD', 'header-link-on', 'header-login-off' );
this.RegisterPage( 'logout', 'Logout', '#7B979B', '#D7DDDD', 'header-link-on', 'header-login-off' );
this.RegisterPage( 'site', 'Site', '#7B979B', '#D7DDDD', 'header-link-on', 'header-link-off' );
this.RegisterPage( 'admin', 'Admin', '#7B979B', '#D7DDDD', 'header-link-on', 'header-link-off' );
this.RegisterPage( 'error', 'Error', '#E8B54F', '#DCE0B6', 'header-link-on', 'header-link-off' );

this.RegisterPage( 'journals', 'Journals', '#A07CA0', '#C0B8C1', 'header-link-on', 'header-link-off' );
this.RegisterPage( 'events', 'Calendar', '#8AC961', '#CEDDC3', 'header-link-on', 'header-link-off' );
this.RegisterPage( 'forms', 'Forms', '#74AA5B', '#C8D1C3', 'header-link-on', 'header-link-off' );
this.RegisterPage( 'studio', 'Studio', '#666691', '#BFBECC', 'header-link-on', 'header-link-off' );

this.RegisterPage( 'home', 'Home', '#6F81AA', '#DAE4EA', 'menu-text-on', 'menu-text-off' );
this.RegisterPage( 'philosophy', 'Philosophy', '#6F81AA', '#DAE4EA', 'menu-text-on', 'menu-text-off' );
this.RegisterPage( 'program', 'Program', '#6F81AA', '#DAE4EA', 'menu-text-on', 'menu-text-off' );
this.RegisterPage( 'summer', 'Summer Camp', '#67999E', '#D4DCDD', 'menu-text-on', 'menu-text-off' );
this.RegisterPage( 'staff', 'Administrative Staff', '#6F81AA', '#DAE4EA', 'menu-text-on', 'menu-text-off' );
this.RegisterPage( 'calendar', 'Calendar', '#74AA5B', '#C8D1C3', 'menu-text-on', 'menu-text-off' );
this.RegisterPage( 'slide', 'Slide Show', '#74AA5B', '#C8D1C3', 'menu-text-on', 'menu-text-off' );
this.RegisterPage( 'resources', 'Resources', '#74AA5B', '#C8D1C3', 'menu-text-on', 'menu-text-off' );
this.RegisterPage( 'contact', 'Contact', '#E8B54F', '#DCE0B6', 'menu-text-on', 'menu-text-off' );
this.RegisterPage( 'admissions', 'Admissions', '#E8B54F', '#DCE0B6', 'menu-text-on', 'menu-text-off' );

this.RegisterPage( 'news', 'News', '', '', '', '' );
this.RegisterPage( 'robin', 'Robin', '', '', '', '' );
this.RegisterPage( 'user', 'User', '', '', 'header-link-on', 'header-link-off' );
this.RegisterPage( 'schoolnews', 'Inside the Blue Door', '#6D99AF', '#C3D2D8', '', '' );

this.RegisterPage( 'auction', 'The Silver Ball Auction', '#9B9B9B', '#E0E0E0', '', '' );
this.RegisterPage( 'auction_form', 'The Silver Ball Auction', '#9B9B9B', '#E0E0E0', '', '' );
this.RegisterPage( 'auction_thank', 'The Silver Ball Auction', '#9B9B9B', '#E0E0E0', '', '' );



/*************************************************************************************************/
/*************************************************************************************************/



//
// Initialize Site
//
function InitializeSite( strPageID )
{
    strPageID = strPageID.toLowerCase();

    document.getElementById('header-title').firstChild.data = this.objSiteControl[strPageID][0];
    document.getElementById('header-bar').style.backgroundColor = this.objSiteControl[strPageID][1];
    document.getElementById('footer-bar').style.backgroundColor = this.objSiteControl[strPageID][2];

    if (document.getElementById(strPageID) != null)
    {
        this.objSiteControl[strPageID][4] = this.objSiteControl[strPageID][3];
        document.getElementById(strPageID).className = this.objSiteControl[strPageID][3];
    }

    this.InitializeLocal();
}

//
// Initialize Admin
//
function InitializeAdmin( strPageID )
{
    strPageID = strPageID.toLowerCase();

    document.getElementById(strPageID).className = 'menu-text-on';
}

//
// Initialize Empty
//
function InitializeEmpty( strPageID )
{
    strPageID = strPageID.toLowerCase();

    this.InitializeLocal();
}



/*************************************************************************************************/
/*************************************************************************************************/



//
// Register Page
//
function RegisterPage( strPageID, strTitle, strHeaderColor, strFooterColor, strLinkOn, strLinkOff )
{
    this.objSiteControl[strPageID] = new Array();
    this.objSiteControl[strPageID][0] = strTitle;
    this.objSiteControl[strPageID][1] = strHeaderColor;
    this.objSiteControl[strPageID][2] = strFooterColor;
    this.objSiteControl[strPageID][3] = strLinkOn;
    this.objSiteControl[strPageID][4] = strLinkOff;
}

//
// Roll over
//
function RollOver( strPageID )
{
    document.getElementById(strPageID).className = this.objSiteControl[strPageID][3];
}

//
// Roll out
//
function RollOut( strPageID )
{
    document.getElementById(strPageID).className  = this.objSiteControl[strPageID][4];
}



/*************************************************************************************************/
/*************************************************************************************************/



//
// Show Scroll
//
function ShowScroll( strPanelID )
{
    var objPanel = document.getElementById(strPanelID);
	var objScrollBlock = document.getElementById(strPanelID + '_Scroll');

	if (objPanel.offsetHeight > objPanel.parentNode.offsetHeight)
	    objScrollBlock.style.display = 'block';

    objPanel.style.top = '0px';
}

//
// Scroll
//
function Scroll( strPanelID, iDirection )
{
    this.StopScroll();
    
    var objPanel = document.getElementById(strPanelID);
    var iScrollSpeed = iDirection;
    var iPanelMinHeight = 0;
    var iPanelMaxHeight = objPanel.parentNode.offsetHeight - objPanel.offsetHeight;
    var iPanelPosition = parseInt(objPanel.style.top);

    if (iDirection > 0)
    {
        iPanelPosition = iPanelPosition + iScrollSpeed;
        if (iPanelPosition >= iPanelMinHeight)
            iPanelPosition = iPanelMinHeight;
    }
    else
    {
        iPanelPosition = iPanelPosition + iScrollSpeed;
        if (iPanelPosition <= iPanelMaxHeight)
            iPanelPosition = iPanelMaxHeight;
    }
   
    objPanel.style.top = iPanelPosition + 'px';
   
    iScrollID = setTimeout( function() { Scroll(strPanelID, iDirection); }, 10 );
}

//
// Stop Scroll
//
function StopScroll()
{
    clearTimeout( iScrollID );
}



/*************************************************************************************************/
/*************************************************************************************************/



//
// Change Class
//
function ChangeClass( strClassID, strUrl )
{
    location.replace( '/Resources/ChangeClass.aspx?ClassID=' + strClassID + '&Url=' + strUrl );
}

//
// Pop Window
//
function PopWindow( strUrl, strName, iWidth, iHeight )
{
    window.open( strUrl, strName, 'width=' + iWidth + ' ,height=' + iHeight );
}

//
// Pop Window Detail
//
function PopWindowDetail( strUrl, strName, iWidth, iHeight, strSpecs )
{
    window.open( strUrl, strName, 'width=' + iWidth + ' ,height=' + iHeight + strSpecs );
}

