
//  ******* MENU ITEM POPUPS *******
//  Two-layered popup hypertext.  First layer (hideText) blanks base text so it won't flash when moving cursor between buttons.
//  This works slightly differently with different browsers.  

if (document.getElementById ) {
var popup_switch=null
var popup_switch = getCookie('hquw')  // 0 = display(default) popups   1 = don't display popups
var objPopUp = null;
var objWrapper = null;
}

function popUp(event,objectID) {
 if (!document.getElementById ) return;
 if (popup_switch == 1) return;
				objPopTrig = document.getElementById(event);
				objPopUp = document.getElementById(objectID);
				xPos = objPopTrig.offsetLeft;
				yPos = objPopTrig.offsetTop + objPopTrig.offsetHeight;
				if (xPos + objPopUp.offsetWidth >  document.body.clientWidth) xPos = xPos - objPopUp.offsetWidth;
				if (yPos + objPopUp.offsetHeight >  document.body.clientHeight) yPos = yPos - objPopUp.offsetHeight - objPopTrig.offsetHeight;
				objPopUp.style.visibility = 'visible';
			}
	
function popHide() {
 if (!document.getElementById ) return;
 if (popup_switch == 1) return;
				objPopUp.style.visibility = 'hidden';
				objPopUp = null;
			}
				
function hideText(event,objectID) {
 if (!document.getElementById ) return;
 if (popup_switch == 1) return;
				objPopTrig = document.getElementById(event);
				objWrapper = document.getElementById(objectID);
				xPos = objPopTrig.offsetLeft;
				yPos = objPopTrig.offsetTop + objPopTrig.offsetHeight;
				if (xPos + objWrapper.offsetWidth >  document.body.clientWidth) xPos = xPos - objWrapper.offsetWidth;
				if (yPos + objWrapper.offsetHeight >  document.body.clientHeight) yPos = yPos - objWrapper.offsetHeight - objPopTrig.offsetHeight;
				objWrapper.style.visibility = 'visible';
			}
		
function unhideText() {
 if (!document.getElementById ) return;
 if (popup_switch == 1) return;
				objWrapper.style.visibility = 'hidden';
				objWrapper = null;
			}

//  ******* END MENU ITEM POPUPS *******			


// ******** ROTATE CONTENT *******
// DECISION TIME: WHETHER TO USE CONTENT ROTATOR OR JUST DISPLAY LIST OF CLASSES
var rotate_content_switch=null
rotate_content_switch = getCookie('rc')  // 0 = rotate(default)   1 = don't rotate 

if (rotate_content_switch == 0 || rotate_content_switch == null) {
if (document.all || document.getElementById){   //if IE4+ or NS6+
document.write('<style type="text/css">')
document.write('.featured_class{display:none; padding-left:6px; padding-right:6px; font-size:15px;}')
document.write('#billboard{height: 282px; padding-top: 8px;}')
document.write('</style>')
}
}
// GLOBALS
var curcontentindex=0
var timerID = null
var messages=new Array()

function load_array(classname){
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
messages[inc++]=alltags[i]
}
curcontentindex=(Math.floor(Math.random() * inc));
prevcontentindex=(curcontentindex==0)? messages.length-1 : curcontentindex-1
messages[curcontentindex].style.display="block" //display first message
objBillboard=document.getElementById ("billboard")
}

// ROTATOR
function rotatecontent(){
//get current message index (to show it):
curcontentindex=(curcontentindex<messages.length-1)? curcontentindex+1 : 0
//get previous message index (to hide it):
prevcontentindex=(curcontentindex==0)? messages.length-1 : curcontentindex-1
messages[prevcontentindex].style.display="none" //hide previous message
setTimeout ('messages[curcontentindex].style.display="block"',200);  //show current message after 1/5 second delay
}

window.onload=function(){
if (rotate_content_switch == 1) return;
//if (document.all || document.getElementById){
  load_array("featured_class")
  timerID = setInterval('rotatecontent()',5500)  // display featured classes at 5 1/2 second intervals
  }

function pause_rotate() {
      if (timerID != null) {
            clearInterval(timerID)
            objBillboard.style.background="#ECECEC";     // gray background
    	    objBillboard.style.border="0px"  // make border invisible 
            timerID = null
      }
   }
   
function restart_rotate() {
      if (timerID == null) { 
         objBillboard.style.backgroundColor='';
         objBillboard.style.border="0px";  // make border invisible 
         timerID = setInterval('rotatecontent()',5500);  // display featured classes at 5 1/2 second intervals
      }
	}
// ******** END ROTATE CONTENT *******

// ******** UTILITY FUNCTIONS ********

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return null
}

addEvent (window, 'load', init, false);  // assign listeners after page load is complete

function init () {
 window.onerror = errorHandler;  // trap errors
 if (document.getElementById ) {
 objLoading = document.getElementById("loading");
 objLoading.style.visibility = 'hidden';
 objFullPage = document.getElementById("fullPage");
 objFullPage.style.visibility = 'visible';
 }
}

function addEvent(elm, evType, fn, useCapture)
// cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko
// By Scott Andrew
  {
    if (elm.addEventListener) {
          elm.addEventListener(evType, fn, useCapture); 
          return true; 
        } else if (elm.attachEvent) {
          var r = elm.attachEvent('on' + evType, fn); 
          return r; 
        } else {
          elm['on' + evType] = fn;
        }
   }

function errorHandler () {
// do nothing
}
