addOnload(setfooter);
addOnload(sfHover);
addOnload(alternate);
addOnload(intro_menu_modification);
window.onresize = setfooter;

function addOnload(newFunction) {
	var oldOnload = window.onload;
	
	if (typeof oldOnload == "function") {
		window.onload = function() {
			if (oldOnload) {
				oldOnload();
			}
			newFunction();
		}
	}
	else {
		window.onload = newFunction;
	} 
}



function setfooter(){
	var footer = document.getElementById('stickyfooter');
	if(footer){
	var vHeight = getHeight();
    	if(vHeight - footer.offsetTop>30)
		{
		footer.style.height = vHeight - footer.offsetTop + 'px'; 
		}
	}
}

function getHeight() {
  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;
  }
  return myHeight; 
}

function sfHover() {
	var sfEls = document.getElementById("main-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"), "");
		}
	}
}

function alternate()
{
	if(document.getElementById('faqtable'))
	{
 		if(document.getElementsByTagName)
		{  
   			var table = document.getElementById('faqtable');  
   			var rows = table.getElementsByTagName("tr");  
   			
				for(i = 0; i < rows.length; i++)
				{          
 				//manipulate rows
     				if(i % 2 == 0)
					{
       				rows[i].className = "even";
     				}
					else
					{
       				rows[i].className = "odd";
     				}      
   				}
 		}
	}
}


function intro_menu_modification()
{

	var menu = document.getElementById('main-nav');
	var menu_uls = menu.getElementsByTagName('ul');

	//every ul will have a parent li so 
	//get this and use this title as the duplicate necessary text
	for(var i=0; i< menu_uls.length; i++)
	{
		var parent = menu_uls[i].parentNode.getElementsByTagName('a')[0];
		var parent_title = parent.innerHTML;
			parent_title += ' Introduction';
	
		parent.innerHTML = parent_title;
		//alert(parent);
		
		var first_li = menu_uls[i].getElementsByTagName('li')[0];
		
		
		//create the new list item
		var intro_li = document.createElement('li');
		var	parent_link = document.createElement('a');
			parent_link.href = parent;
			parent_link.innerHTML = parent.innerHTML;
			
			intro_li.appendChild(parent_link);
			
		menu_uls[i].insertBefore(intro_li,first_li);
	}
	
}