<!--

sfHover = function() {
	// for top menus
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	// end top menus

	// for datatable hovers
	var tables = document.getElementsByTagName('table');
	var k = 0;
	for (var i = 0;i<tables.length;i++) {
		if (tables[i].className == "datatable") {
			var rows = tables[i].getElementsByTagName('tr');
			for (var j = 0;j<rows.length;j++) {
				rows[j].onmouseover=function() {
					this.className+=" dthover";
				}
				rows[j].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" dthover\\b"), "");
				}
			}
		}
	}
	// end datatable hovers
	
	// now for side menus
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav2");
		for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
		if (node.nodeName=="LI") {
		node.onmouseover=function() {
		//alert(this.className)
		this.className+="over";
		  }
		  node.onmouseout=function() {
		 // alert(this.className)
		  this.className=this.className.replace("over", "");
		   }
		   }
		  }
		 }
	// end side menus code
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


function getAbsoluteTop(oNodeName) { // as string 
   var oCurrentNode=document.getElementById(oNodeName);
   var iTop=0;
   while(oCurrentNode.tagName!="BODY"){
      iTop+=oCurrentNode.offsetTop;
      oCurrentNode=oCurrentNode.offsetParent;
   }
   return iTop
}

function getAbsoluteLeft(oNodeName) { // as string 
   var oCurrentNode=document.getElementById(oNodeName);
   var iTop=0;
   while(oCurrentNode.tagName!="BODY"){
      iTop+=oCurrentNode.offsetLeft;
      oCurrentNode=oCurrentNode.offsetParent;
   }
   return iTop
}

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return myWidth;
}

function placeFooter() {
	if (layout != 'hybrid') {
		document.getElementById("sitemap2").style.display = "none";
	}
	// Find the heights of the three columns - left menu, content, marketing. (tall)
	// - or - Find the heights of the two columns - left menu, content (wide)
	// Then the top of the footer needs to line up with the bottom of the longest column.
	tops = new Array();
	heights = new Array();
	bases = new Array();
	tops[0] = getAbsoluteTop("mainmenu");
	tops[1] = getAbsoluteTop("maincontent");
	if (layout == "tall") { tops[2] = getAbsoluteTop("marketing"); }
	
	heights[0] = document.getElementById("mainmenu").offsetHeight;
	heights[1] = document.getElementById("maincontent").offsetHeight;
	if (layout == "tall") { heights[2] = document.getElementById("marketing").offsetHeight; }
	
	var factor = 2;
	if (layout == "wide" || layout == "hybrid") { factor = 1; }
	for (f=0; f<=factor; f++) {
		bases[f] = tops[f] + heights[f];
	}
	
	highest = 0
	for (f=0; f<=2; f++) {
		if (bases[f] > bases[highest]) { highest = f }
	}

	if (layout != 'hybrid') {
		document.getElementById("sitemap").style.marginTop = heights[highest] - 323;
	}

	var padding = heights[highest] - heights[1];
	if (layout != 'hybrid' && padding > 0) { document.getElementById('maincontent').style.paddingBottom = padding + 'px'; }

	document.getElementById("sitemap").style.visibility = "visible";
	
	sizePointlessBlock()
}

function Is() {
  var agent = navigator.userAgent.toLowerCase();
  this.safari = (agent.indexOf("safari") != -1);
  this.opera = (agent.indexOf("opera") != -1);
 this.oldFF = (agent.indexOf("firefox/1.5") != -1);
}
var is = new Is()

function sizePointlessBlock() {
	mehObjLeft = getAbsoluteLeft("pointlessblock");
	winWidth = alertSize();
	reqWidth = winWidth - mehObjLeft;
	 if(( typeof( window.innerWidth ) == 'number' ) && !(is.safari)) {
	 	reqWidth -= 17.5;
		if (is.opera) {
			reqWidth += 0.5
		}
		if (is.oldFF) {
			reqWidth -= 2;
		}
	}

	if (layout == "hybrid") {
		var contentwidth = 565 + reqWidth;
		document.getElementById('maincontent').style.width = contentwidth + 'px';

		heights[0] = document.getElementById("mainmenu").offsetHeight;
		heights[1] = document.getElementById("maincontent").offsetHeight;
		if (heights[highest] > heights[1]) { document.getElementById('sitemap').style.marginTop = (heights[highest]-heights[1]+30)+ 'px'; }
		document.getElementById('page2').style.height = heights[highest] - 20 + 'px';
	}

	if (layout == "wide" && typeof( window.innerWidth ) == 'number') {
		siteMapLeft = getAbsoluteLeft("maincontent") - 10
		document.getElementById("sitemap").style.left = siteMapLeft + "px";
	}

	if (winWidth > 740) {
		document.getElementById("pointlessblock").style.width = reqWidth + "px";	
	}
}

function fix_fluid() {
	// Position the nav menu
	winWidth = alertSize();
	document.getElementById('nav').style.display = 'block';
	newLeft = parseInt(210 + ((winWidth - 760)/2));
	document.getElementById('nav').style.left = newLeft + 'px';

	// Add padding to the maincontent in case the marketing or mainmenu
	// divs are taller than it
	var heights = new Array();
	heights[0] = document.getElementById('mainmenu').offsetHeight;
	heights[1] = document.getElementById('maincontent').offsetHeight;
	heights[2] = document.getElementById('marketing').offsetHeight;

	var tallest = 1;
	for (var i = 0; i<3; i++) {
		if (heights[i] > heights[tallest]) { tallest = i; }
	}

	if (heights[tallest] - heights[1] > 0) {
		document.getElementById('maincontent').style.paddingBottom = (heights[tallest] - heights[1] + 50)+'px';
	}

}


//-->
