// JavaScript Document

/******************** ie dropdown menu fix ********************************/
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i]
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over"
				}
				node.onmouseout=function() {
 					this.className=this.className.replace(" over", "");
 				}
			}
 		}
 	}
}

/***************** set the width for tabbed pannels ***********************/
function getElementwidth(Elem) {
	var xPos = 9
	var space = 2
	var tabID = document.getElementById(Elem)
	var emNodes = tabID.getElementsByTagName('h4')
	var max = emNodes.length
	for(var i = 0;i < max;i++) {
	   var nodeObj = emNodes.item(i)
	   //nodeObj.onclick = tabs(this);
	   nodeObj.parentNode.style.position = 'absolute' // needed for ie7 bug
	   //if((nodeObj.getAttribute('class') == cl) || (nodeObj.getAttribute('className') == cl)) { // For lt IE8 className is used instead of class Really Lame
	   		//nodeObj.setAttribute('onClick', 'tabs(\''+Elem+'\',this)'); //no good for ie7 use nodeObj.onclick = function() {tabs('m',this);}

			nodeObj.style.left = xPos + 'px'
	   		if ( 'undefined' != typeof ( nodeObj.offsetWidth ) ) {
				xPos = xPos + parseInt ( nodeObj.offsetWidth ) + space;
			} else if ( 'undefined' != typeof ( nodeObj.style.pixelWidth ) ) {
				xPos = xPos + parseInt ( nodeObj.style.pixelWidth ) + space
			}
		//}
	}
		   document.getElementById('default').style.position = 'static' // needed for ie7 bug

}
/***************** tabbed pannels ***********************/
function tabs(par, elem) {
	var tabID = document.getElementById(par)
	var emNodes = tabID.getElementsByTagName('div')
	var max = emNodes.length
	for(var i = 0;i < max;i++) {
   		var nodeObj = emNodes.item(i)
   		nodeObj.style.display = 'none'
		nodeObj.parentNode.style.position = 'absolute' //needed for ie7 bug
   	}
	var liNodes = tabID.getElementsByTagName('h4')
	var max = emNodes.length
	for(var i = 0;i < max;i++) {
   		var nodeObj = liNodes.item(i)
   		nodeObj.style.backgroundColor = '#fff'
   		nodeObj.style.color = '#005598'
   	}
	spanNade = elem.parentNode.getElementsByTagName('div').item(0);
	spanNade.style.display='block'
	spanNade.parentNode.style.position='static' //needed for ie7 bug
	elem.style.backgroundColor = '#005598'
	elem.style.color = '#fff'
	if (document.getElementById('n')) getElementwidth('n','bar');
	//if (sec == 1) {document.getElementById('second').style.display='block';}

	return null
}

/* features */
function MM_showHideLayers() { //v9.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) 
	with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
/******************** sliding panels ***********************/
//This code was created by the fine folks at Switch On The Code - http://blog.paranoidferret.com
//This code can be used for any purpose

function animate(elementID, newLeft, newTop, newWidth,
      newHeight, time, callback)
{
  var el = document.getElementById(elementID);
  if(el == null)
    return;
 
  var cLeft = parseInt(el.style.left);
  var cTop = parseInt(el.style.top);
  var cWidth = parseInt(el.style.width);
  var cHeight = parseInt(el.style.height);
 
  var totalFrames = 1;
  if(time> 0)
    totalFrames = time/40;

  var fLeft = newLeft - cLeft;
  if(fLeft != 0)
    fLeft /= totalFrames;
 
  var fTop = newTop - cTop;
  if(fTop != 0)
    fTop /= totalFrames;
 
  var fWidth = newWidth - cWidth;
  if(fWidth != 0)
    fWidth /= totalFrames;
 
  var fHeight = newHeight - cHeight;
  if(fHeight != 0)
    fHeight /= totalFrames;
   
  doFrame(elementID, cLeft, newLeft, fLeft,
      cTop, newTop, fTop, cWidth, newWidth, fWidth,
      cHeight, newHeight, fHeight, callback);
}

function doFrame(eID, cLeft, nLeft, fLeft,
      cTop, nTop, fTop, cWidth, nWidth, fWidth,
      cHeight, nHeight, fHeight, callback)
{
   var el = document.getElementById(eID);
   if(el == null)
     return;

  cLeft = moveSingleVal(cLeft, nLeft, fLeft);
  cTop = moveSingleVal(cTop, nTop, fTop);
  cWidth = moveSingleVal(cWidth, nWidth, fWidth);
  cHeight = moveSingleVal(cHeight, nHeight, fHeight);

  el.style.left = Math.round(cLeft) + 'px';
  el.style.top = Math.round(cTop) + 'px';
  el.style.width = Math.round(cWidth) + 'px';
  el.style.height = Math.round(cHeight) + 'px';
 
  if(cLeft == nLeft && cTop == nTop && cHeight == nHeight
    && cWidth == nWidth)
  {
    if(callback != null)
      callback();
    return;
  }
   
  setTimeout( 'doFrame("'+eID+'",'+cLeft+','+nLeft+','+fLeft+','
    +cTop+','+nTop+','+fTop+','+cWidth+','+nWidth+','+fWidth+','
    +cHeight+','+nHeight+','+fHeight+','+callback+')', 40);
}

function moveSingleVal(currentVal, finalVal, frameAmt)
{
  if(frameAmt == 0 || currentVal == finalVal)
    return finalVal;
 
  currentVal += frameAmt;
  if((frameAmt> 0 && currentVal>= finalVal)
    || (frameAmt <0 && currentVal <= finalVal))
  {
    return finalVal;
  }
  return currentVal;
}
//----------------------------------