﻿/**********************************************************************************************************************
IT-Event Management © 2007
Version 1.004 alpha

Author: Clarice Billowes, Marais Bouwer

Issues:
-------

- Does not move loading object to correct position in Firefox. (1.5+)
- Scrolling with the mouse does not correctly postion in Netscape (8.+)
- When right horizontal:
	- infinite scrolling occurs in Netscape (8.+)
	- padding / margin should be set properly for Firefox (1.+)
- When using IE6-, dropdownlists display above background object.

**********************************************************************************************************************/
// Allow the user to vertically align the object: top (0), middle (1), bottom (2)
// Allow the user to horizontally align the object: left (0), center (1), right (2)
// Set objectHeight (divloading)
// Set objectWidth (divLoading)
// Default is middle, center

window.onload = Init; //Not permanent - only for display purposes
window.onscroll = Init; 
window.onresize = Init;
 
var floating_menu, background_splash;
var windowWidth = 0, windowHeight = 0, maxHeight = 0, maxWidth = 0;

var valign = 1, halign = 1;

var fm_id = 'divLoading';

var objectWidth = 100;
var objectHeight = 85;

var has_element = document.documentElement && document.documentElement.clientWidth;
var has_inner = typeof(window.innerWidth) == 'number';
 
function SetLoadingImageID(newID)
{
    fm_id=newID;
}

function SetVerticalAlign()
{
    switch (valign)
    {
	case 0:
	    //left
	    return 2 + (has_element? document.documentElement.scrollLeft: document.body.scrollLeft);
	case 1:
	    //center;
	   	    return ((windowWidth - objectWidth)/2) + (has_element? document.documentElement.scrollLeft: document.body.scrollLeft);
	case 2:
	    //right
//do browser detect to fix padding issues.
	    return ((windowWidth - objectWidth) - 5) + (has_element? document.documentElement.scrollLeft: document.body.scrollLeft);
	default:
	    return 0;
    }
	
}

function SetHorizontalAlign()
{
    switch (halign)
    {
	case 0:
	    //top
	    return 2 + (has_element? document.documentElement.scrollTop: document.body.scrollTop);
	case 1:
	    //middle;
	    return ((windowHeight - objectHeight)/2) + (has_element? document.documentElement.scrollTop: document.body.scrollTop);
	case 2:
	    //bottom
	    return ((windowHeight - objectHeight) - 5) + (has_element? document.documentElement.scrollTop: document.body.scrollTop);
        default:
	    return 0;
    }
}

function SetValues()
{
    // Determine the max width & height allowed for scrolling
    maxHeight = document.body.scrollHeight;
    maxWidth = document.body.scrollWidth;

   
    if (typeof(window.innerWidth) == 'number')
    {
      // Non-IE browser
      windowWidth = window.innerWidth;
      windowHeight = window.innerHeight;
    }
    else if (document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight))
    {
      //IE 6+ in 'standards compliant mode'
      windowWidth = document.documentElement.clientWidth;
      windowHeight = document.documentElement.clientHeight;
    }
    else if (document.body && ( document.body.clientWidth || document.body.clientHeight))
    {
      windowWidth = document.body.clientWidth;
      windowHeight = document.body.clientHeight;
    }
}

function Init()
{
    SetValues();
    if (floating_menu == null) 
    {   
        floating_menu = document.getElementById? document.getElementById(fm_id): document.all? document.all[fm_id]: document.layers[fm_id];
    }
     
    if (document.layers)
    {
	    floating_menu.left = SetVerticalAlign();
	    floating_menu.top = SetHorizontalAlign();
    }
    else
    {    
	    floating_menu.style.left = SetVerticalAlign();
	    floating_menu.style.top = SetHorizontalAlign();
    }         
}