
function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

var xOffset = 137;
var yOffset = 187;

function showPopup (targetObjectId, eventObj) {
    if(eventObj) {
	// hide any currently-visible popups
	hideCurrentPopup();
	// stop event from bubbling up any farther
	eventObj.cancelBubble = true;
	// move popup div to current cursor position 
	// (add scrollTop to account for scrolling for IE)
	targetObjectId.left = xOffset;
	targetObjectId.top = yOffset;
	if( changeObjectVisibility(targetObjectId, 'visible') ) {
	    // if we successfully showed the popup
	    // store its Id on a globally-accessible object
	    window.currentlyVisiblePopup = targetObjectId;
	    return true;
	} else {
	    // we couldn't show the popup, boo hoo!
	    return false;
	}
    } else {
	// there was no event object, so we won't be able to position anything, so give up
	return false;
    }
} // showPopup

function hideCurrentPopup() {
    // note: we've stored the currently-visible popup on the global object window.currentlyVisiblePopup
    if(window.currentlyVisiblePopup) {
	changeObjectVisibility(window.currentlyVisiblePopup, 'hidden');
	window.currentlyVisiblePopup = false;
    }
} // hideCurrentPopup

// ***********************
// hacks and workarounds *
// ***********************

// initialize hacks whenever the page loads
window.onload = initializeHacks;

// setup an event handler to hide popups for generic clicks on the document
document.onclick = hideCurrentPopup;

function initializeHacks() {
    // this ugly little hack resizes a blank div to make sure you can click
    // anywhere in the window for Mac MSIE 5
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	window.onresize = explorerMacResizeFix;
    }
    resizeBlankDiv();
    // this next function creates a placeholder object for older browsers
    createFakeEventObj();
}

function createFakeEventObj() {
    // create a fake event object for older browsers to avoid errors in function call
    // when we need to pass the event object to functions
    if (!window.event) {
	window.event = false;
    }
} // createFakeEventObj

function resizeBlankDiv() {
    // resize blank placeholder div so IE 5 on mac will get all clicks in window
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	getStyleObject('blankDiv').width = document.body.clientWidth - 20;
	getStyleObject('blankDiv').height = document.body.clientHeight - 20;
    }
}

function explorerMacResizeFix () {
    location.reload(false);
}
// countdown specific stuff
var today = new Date();
function startCount() {
	secsLeft = 888; // 30 minutes
	now = today.getTime();	
	if(secsLeft > 0){
		timer_setupCountDown(secsLeft, 'countHere', '');
	} else {
		// time expired
		honorCountDown();
	}
}

var d=document;
ndc=new Array();
coc=new Array();
var gV=new Array();
kg=true;

function  showTimer(dtw,ctr){
    es=stimer_getElementsBySelector(dtw);
    if(ndc[dtw]==null){ndc[dtw]=0;coc[coc.length]="showTimer('"+dtw+"', '"+ctr+"')";}
    if(es.length>ndc[dtw]){nes=es.length;for(var x=ndc[dtw];x<nes;x++){theTarget=es[x];
    eval(ctr);
    }ndc[dtw]=nes;
    }if(kg==true){setTimeout("showTimer('"+dtw+"', '"+ctr+"')",100);
    }
    return true;
    }
    
function  stimer_getElementsBySelector(selector){var i;var s=[];var selid="";var selclass="";var tag=selector;var objlist=[];if(selector.indexOf(" ")>0){s=selector.split(" ");var fs=s[0].split("#");if(fs.length==1)return(objlist);if(d.getElementById(fs[1])){return(d.getElementById(fs[1]).getElementsByTagName(s[1]));}return false;}if(selector.indexOf("#")>0){s=selector.split("#");tag=s[0];selid=s[1];}if(selid!=""){if(d.getElementById(selid)){objlist.push(d.getElementById(selid));return(objlist);}return false;}if(selector.indexOf(".")>0){s=selector.split(".");tag=s[0];selclass=s[1];}var v=d.getElementsByTagName(tag);if(selclass=="")return(v);for(i=0;i<v.length;i++){curClass=" "+v[i].className+" ";if(curClass.indexOf(" "+selclass+" ")!="-1"){objlist.push(v[i]);}}return(objlist);}
function  stimer_stopIt(){kg="";for(x=0;x<coc.length;x++){eval(coc[x]);}}
function  timer_doCountDown(targetTime,targetID,endCode){curTime=new Date().getTime();targTime=new Date(targetTime).getTime();timeLeft=Math.ceil((targTime-curTime)/1000);gV['timeLeft'] = timeLeft;minsLeft=Math.floor(timeLeft/60);secsLeft=Math.floor(timeLeft-(minsLeft*60));countdown=timer_zeroPad(minsLeft,2)+":"+timer_zeroPad(secsLeft,2);var foo=document.getElementById(targetID);if(foo.getAttribute("type")){foo.value=countdown;}else{foo.innerHTML=countdown;}if(minsLeft=="00"&&secsLeft=="00"){eval(endCode);}else{var foo=setTimeout("timer_doCountDown("+targetTime+",'"+targetID+"','"+endCode+"')",999);}}monthNames=new Array('','January','February','March','April','May','June','July','August','September','October','November','December');
function  timer_zeroPad(numToPad,numDigits){numToPad=numToPad+"";curLen=numToPad.length;if(curLen<numDigits){zeros="0";for(x=curLen;x<numDigits-1;x++)zeros+="0";newNum=zeros+numToPad;return newNum;}return numToPad;}
		
function timer_setupCountDown(secs,targetID,endCode){
	var now = new Date();
	//secs = 10;
	targetTime = now.getTime()+secs*1000;
	//timer_doCountDown(targetTime,targetID,endCode);
	timer_doCountDown(targetTime,targetID,'honorCountDown("'+targetID+'")');
}
		
function honorCountDown(){
	d.getElementById('countHere').innerHTML = "00:00";
	alert('The alotted time has run out.  To extend your time and proceed, press OK.');
	timer_setupCountDown(1200,'countHere',"");
}