/***************

Show and hide the homepage popup links

***************/

//set the number of seconds the menu should be visible after mousing off
var visibility_time = .5;
//a timer
var vis_timer = 0;
//a tracker for whether or not we are moused off of the menu
var mouseoff = true;

//a layer visibility toggling function
function showPop(num) {
	document.getElementById('hm_case_selectpop1').style.visibility = 'hidden';
	document.getElementById('hm_case_selectpop2').style.visibility = 'hidden';
	for (i=1;i<100;i++) {
		if (document.getElementById('hm_case_select_who_sub' + i)) document.getElementById('hm_case_select_who_sub' + i).style.visibility = 'hidden';
		if (document.getElementById('hm_case_select_what_sub' + i)) document.getElementById('hm_case_select_what_sub' + i).style.visibility = 'hidden';
	}
	document.getElementById('hm_case_selectpop' + num).style.visibility = 'visible';
}

//function activated whenever a popup link is moused over or moused out
function menuMouseoff(truefalse,menutype,menunum) {
	//if we have a submenu number set, 
	//turn off all submenus then turn that submenu on
	if (menunum) {
		for (i=1;i<100;i++) {
			if (document.getElementById('hm_case_select_' + menutype + '_sub' + i)) {
				document.getElementById('hm_case_select_' + menutype + '_sub' + i).style.visibility = 'hidden';
			} else {
				break;
			}
		}
		document.getElementById('hm_case_select_' + menutype + '_sub' + menunum).style.visibility = 'visible';
	}
			
	//set the mouseoff value to match whether the item has been moused on or off
	mouseoff = truefalse;
	//if we have moused off, start our timer
	if (mouseoff) setTimeout(hideMenuCheck,10);
}

//a repeater function to track the amount of time the menu has been moused off
function hideMenuCheck() {
	//if we have moused back over an item, reset the timer and stop the repeater
	if (!mouseoff) {
		vis_timer = 0;
	//if we have reached our time limit, reset the timer and hide the layer
	} else if (vis_timer >= visibility_time * 100) {
		vis_timer = 0;
		document.getElementById('hm_case_selectpop1').style.visibility = 'hidden';
		document.getElementById('hm_case_selectpop2').style.visibility = 'hidden';
		for (i=1;i<100;i++) {
			if (document.getElementById('hm_case_select_who_sub' + i)) document.getElementById('hm_case_select_who_sub' + i).style.visibility = 'hidden';
			if (document.getElementById('hm_case_select_what_sub' + i)) document.getElementById('hm_case_select_what_sub' + i).style.visibility = 'hidden';
		}
	//otherwise, update the timer and loop back through the function
	} else {
		vis_timer++;
		setTimeout(hideMenuCheck,10);
	}
}



/***************

Scroll the homepage news content area

***************/

//Manual Scroller- © Dynamic Drive 2001
//For full source code, visit http://www.dynamicdrive.com

//specify speed of scroll (greater=faster)

var speed=2

iens6=document.all||document.getElementById
ns4=document.layers
var crossobj = 0
var contentheight = 0

function movedown(){
	if (!crossobj) getcontent_height()
	if (window.moveupvar) clearTimeout(moveupvar)
	if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+180))
	crossobj.style.top=parseInt(crossobj.style.top)-speed+"px"
	else if (ns4&&crossobj.top>=(contentheight*(-1)+180))
	crossobj.top-=speed
	movedownvar=setTimeout("movedown()",20)
}

function moveup(){
	if (!crossobj) getcontent_height()
	if (window.movedownvar) clearTimeout(movedownvar)
	if (iens6&&parseInt(crossobj.style.top)<=0)
	crossobj.style.top=parseInt(crossobj.style.top)+speed+"px"
	else if (ns4&&crossobj.top<=0)
	crossobj.top+=speed
	moveupvar=setTimeout("moveup()",20)
}

function stopscroll(){
	if (!crossobj) getcontent_height()
	if (window.moveupvar) clearTimeout(moveupvar)
	if (window.movedownvar) clearTimeout(movedownvar)
}

function movetop(){
	if (!crossobj) getcontent_height()
	stopscroll()
	if (iens6)
	crossobj.style.top=0+"px"
	else if (ns4)
	crossobj.top=0
}

function getcontent_height(){
	if (iens6) {
		crossobj=document.getElementById? document.getElementById("hm_news_content") : document.all.hm_news_content
		contentheight=crossobj.offsetHeight
		contentheight=crossobj.offsetHeight - 50
	} else if (ns4) {
		crossobj=document.nscontainer.document.nscontent
		contentheight=crossobj.clip.height
		document.nscontainer.document.nscontent.visibility="show"
	}
}


/***************

Replace the spotlight headings with Flash movies

***************/

function replace_spotlight(headline, spotlight) {
	if ( MM_FlashCanPlay )  {
		headline = headline.toUpperCase();
		flashstring = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
		flashstring += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ';
		flashstring += ' width="225" height="32">';
		flashstring += ' <PARAM NAME=movie VALUE="/assets/headline_spotlight.swf?headline=' + headline + '">'; 
		flashstring += ' <PARAM NAME=quality VALUE=high>'; 
		flashstring += ' <PARAM NAME=wmode VALUE=transparent>'; 
		flashstring += ' <PARAM NAME=bgcolor VALUE=#FFFFFF>'; 
		flashstring += ' <EMBED src="/assets/headline_spotlight.swf?headline=' + headline + '" quality=high bgcolor=#FFFFFF wmode=transparent ';
		flashstring += ' WIDTH="225" HEIGHT="32" ';
		flashstring += ' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
		flashstring += ' </EMBED>';
		flashstring += ' </OBJECT>';
		document.getElementById("hm_spotlight_heading" + spotlight).innerHTML = flashstring;
	}
}

//make the dropdowns on the homepage visible (they were invisible to help viewabilitiy in Contribute)
function hm_update() {
	document.getElementById("hm_secondary_container").style.visibility = "visible";
}