﻿// JScript File

// Show/hide magic... 
function showhide(layer_ref) {

	if (document.all) 
	{ //IS IE 4 or 5 (or 6 beta)
		// alert(document.all[layer_ref].style.display);
		// eval( "document.all." + layer_ref + ".style.display = 'block'");
		document.all[layer_ref].style.display = DisplayState(document.all[layer_ref].style.display);
	}

	if (document.layers) 
	{ //IS NETSCAPE 4 or below		
		document.layers[layer_ref].display = DisplayState(document.layers[layer_ref].display);
	}

	if (document.getElementById &&!document.all) {
		hza = document.getElementById(layer_ref);
		hza.style.display = DisplayState(hza.style.display);
	}
} 

function hide(layer_ref) {

	if (document.all) 
	{ //IS IE 4 or 5 (or 6 beta)
		// alert(document.all[layer_ref].style.display);
		// eval( "document.all." + layer_ref + ".style.display = 'block'");
		document.all[layer_ref].style.display = 'none';
	}

	if (document.layers) 
	{ //IS NETSCAPE 4 or below		
		document.layers[layer_ref].display = 'none';
	}

	if (document.getElementById &&!document.all) {
		hza = document.getElementById(layer_ref);
		hza.style.display = 'none';
	}
}

function show(layer_ref) {

	if (document.all) 
	{ //IS IE 4 or 5 (or 6 beta)
		// alert(document.all[layer_ref].style.display);
		// eval( "document.all." + layer_ref + ".style.display = 'block'");
		document.all[layer_ref].style.display = 'block';
	}

	if (document.layers) 
	{ //IS NETSCAPE 4 or below		
		document.layers[layer_ref].display = 'block';
	}

	if (document.getElementById &&!document.all) {
		hza = document.getElementById(layer_ref);
		hza.style.display = 'block';
	}
}

function DisplayState(state)
{
    if (state == 'block') 
    {
        state = 'none';
    }
    else 
    {
        state = 'block';
    }
    return state;
}

// Some Coookie stuff...
function createCookie(name,value,days) 
{
	if (days) 
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else 
	{
		var expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');

	for(var i=0;i < ca.length;i++) 
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) 
		{
			return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}

function eraseCookie(name) 
{
	createCookie(name,"",-1);
}

// Call the action...
function closepoppy(theopt)
{
    hide('overlay');
    hide('overlay2');
    
    if (theopt == 'hide')
    {
        createCookie('showpanelhome', 'no', 30);
    }
}

function checkhomepanel()
{
    if (readCookie('showpanelhome') == 'no')
    {
        closepoppy('hide');
    }
}

// Moves the 'flyout' course list to the correct position, adjacent to the links....
function setInnerPosition(leDiv)
{    
    var iW = 0;
    
    if(window.innerWidth) // Mozilla etc...
    {
        iW = window.innerWidth > 1025 ? (window.innerWidth / 2) - 440 : 80;
    }
    else // IE etc...
    {
        iW = document.body.clientWidth > 1025 ? (document.body.clientWidth / 2) - 425 : 80;   
    }
    
    var sS = iW+"px"
    
    var iTop = 260 + (leDiv * 12);
    
    var sT = iTop+"px";
    
    document.getElementById(leDiv).style.left = sS;
    document.getElementById(leDiv).style.top = sT;
}
