/* disclosure triangle type show/hide script */

function myswitch(id){
	myimg = "img_"+id;

	if (document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "";
		document.getElementById(myimg).src = "_pix/arrow_down.gif";
	}
	else {
		document.getElementById(id).style.display = "none";
		document.getElementById(myimg).src = "_pix/arrow_right.gif";
	}
}


/* simple turn 1 on, turn another off script */
function myswitch2(id,id2){
	
	document.getElementById(id).style.display = "";
	document.getElementById(id2).style.display = "none";
	
}


/* mkaes the glow effect work on the navbar */
function glowSwitch(id, io){

	 j = "nav"+id;
	 j2 = "nav"+(parseInt(id)+1);
	
/*	alert('j is ' +j+ ' and j2 is ' +j2);	*/
	
	if(io == "i"){
		document.getElementById(j).style.backgroundPosition= "0px -97px";
		document.getElementById(j2).style.backgroundImage =  "url(_pix/bar_glow_right2.png)";
		document.getElementById(j2).style.backgroundPosition= "0px -97px";
	}
	
	if(io == "o"){
		document.getElementById(j).style.backgroundPosition= "0px 0px";
		document.getElementById(j2).style.backgroundImage =  "url(_pix/bar_glow_left2.png)";
		document.getElementById(j2).style.backgroundPosition= "0px 0px";
	}
	
	if(io == "d"){
		document.getElementById(j).style.backgroundPosition= "0px -194px";
		document.getElementById(j2).style.backgroundImage =  "url(_pix/bar_glow_right2.png)";
		document.getElementById(j2).style.backgroundPosition= "0px -194px";
	}

	if(io == "u"){
		document.getElementById(j).style.backgroundPosition= "0px -97px";
		document.getElementById(j2).style.backgroundImage =  "url(_pix/bar_glow_right2.png)";
		document.getElementById(j2).style.backgroundPosition= "0px -97px";
	}

	
}



/* super simple focus field or element script */
function myFocus(foo){
	if(document.getElementById(foo)){
		document.getElementById(foo).focus();
	}
}



/* put this on the actual page that needs to show/hide multiple elements */
	function showHide(linx){
		var eleArray = ['div1','div2','div3','div4'];
		offon(linx,eleArray);
	}



/* hides all elements in the list, then enables the one element goOn */
	function offon(goOn, fullList){
	
	var j = 1;
	if(document.getElementById(goOn).style.display=="")
		j = 0;

	for(var i in fullList){
		document.getElementById(fullList[i]).style.display = "none";
	}
	
	/* if item was visible before, now hide it */
	if(j==1)
		document.getElementById(goOn).style.display = "";
		
}




/* accordion menu, modified from paranoidferret.com */

/*  use it like this: 

<dt><a onclick="runAccordion(3,150);">stuff</a></dt>
			<dd id="acrd3Content" class="AccordionContent">
			
*/

var TimeToSlide = 200.0;
var openAccordion = '';



function runAccordion(index,ContentHeight)
{
  var nID = "acrd" + index + "Content";
  if(openAccordion == nID)
    nID = '';
    
	setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide + ",'" + openAccordion + "','" + nID + "','"+ContentHeight+"')", 33);
  

  
  openAccordion = nID;
}


function animate(lastTick, timeLeft, closingId, openingId, ContentHeight)
{  
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
  
  var opening = (openingId == '') ? null : document.getElementById(openingId);
  var closing = (closingId == '') ? null : document.getElementById(closingId);
 
  if(timeLeft <= elapsedTicks)
  {
    if(opening != null)
      opening.style.height = ContentHeight + 'em';
    
    if(closing != null)
    {
      closing.style.display = 'none';
      closing.style.height = '0em';
    }
    return;
  }
 
  timeLeft -= elapsedTicks;
  var newClosedHeight = Math.round((timeLeft/TimeToSlide) * ContentHeight);

  if(opening != null)
  {
    if(opening.style.display != 'block')
      opening.style.display = 'block';
    opening.style.height = (ContentHeight - newClosedHeight) + 'em';
  }
  
  if(closing != null)
    closing.style.height = newClosedHeight + 'em';

  setTimeout("animate(" + curTick + "," + timeLeft +",'" + closingId + "','" + openingId + "','"+ContentHeight+"')", 33);
}
