/* Simon Willison - http://www.sitepoint.com/blog-post-view.php?id=171578 */


// addLoadEvent Handler
/////////////////////////////
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

//function destroycatfish()
//{
//	var catfish = document.getElementById('catfish');
//	document.body.removeChild(catfish); /* clip catfish off the tree */
//	document.getElementsByTagName('html')[0].style.padding= '0'; /* reset the padding at the bottom */
//	return false;
//}
//function closeme()
//{
//	var closelink = document.getElementById('closeme');
//	closelink.onclick = destroycatfish;
//
//}
//addLoadEvent(function() {
//	closeme();
//}
//);
//
//
//
//// Deploy the Catfish
//
//// The Catfish should be located in an element of id 'catfish' and should be hidden
//// out of view
//
//var catfish; 
//function deploycatfish() 
//// initializing 
//{ 
//	catfish = document.getElementById('catfish'); 
//	catfishheight = 100; // total height of catfish in pixels 
//	catfishoverlap = 100; // height of the 'overlap' portion only (semi-transparent) 
//	catfishtimeout = setTimeout(startcatfish, 1000); 
//} 
//
//function startcatfish()
//// starts the catfish sliding up
//{
//	catfishposition = 0; // catfishposition is expressed in percentage points (out of 100)
//	catfishtimeout = setInterval(positioncatfish, 25);
//}
//
//function positioncatfish()
//{
//	catfishposition += 10;
//	catfish.style.marginBottom = '-' + (((100 - catfishposition) / 100) * catfishheight) + 'px';
//	if (catfishposition >= 100)
//	{
//		clearTimeout(catfishtimeout);
//		catfishtimeout = setTimeout(finishcatfish, 1);
//	}
//}
//
//function finishcatfish()
//{
//	catfish.style.marginBottom = '0';	
//	// jump the bottom of the document to give room for the catfish when scrolled right down
//	document.body.parentNode.style.paddingBottom = (catfishheight - catfishoverlap) +'px';
//	
//	// here you could use AJAX (or similar) to log the popup hit for tracking purposes	
//}
//
//addLoadEvent(deploycatfish);



// Nav Menu
/////////////////////////////
	stuHover = function() {
	var cssRule;
	var newSelector;
	for (var i = 0; i < document.styleSheets.length; i++)
		for (var x = 0; x < document.styleSheets[i].rules.length ; x++)
			{
			cssRule = document.styleSheets[i].rules[x];
			if (cssRule.selectorText.indexOf("LI:hover") != -1)
			{
				 newSelector = cssRule.selectorText.replace(/LI:hover/gi, "LI.iehover");
				document.styleSheets[i].addRule(newSelector , cssRule.style.cssText);
			}
		}
	var getElm = document.getElementById("navMenu").getElementsByTagName("LI"); 
	for (var i=0; i<getElm.length; i++) {
		getElm[i].onmouseover=function() {
			this.className+=" iehover";
		}
		getElm[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
//if (window.attachEvent) window.attachEvent("onload", stuHover);


if (window.attachEvent) addLoadEvent(function() {
	stuHover();
}
);




// Easy Tabs 1.2
/////////////////////////////
//Set the id names of your tablink (without a number at the end)
var tablink_idname = new Array("tablink")
//Set the id name of your tabcontentarea (without a number at the end)
var tabcontent_idname = new Array("tabcontent") 
//Set the number of your tabs
var tabcount = new Array("2")
//Set the Tab wich should load at start
var loadtabs = new Array("1")  
//Set the Number of the Menu which should autochange (if you dont't want to have a change menu set it to 0)
var autochangemenu = 0;
//the speed in seconds when the tabs should change
var changespeed = 2;
//should the autochange stop if the user hover over a tab from the autochangemenu? 0=no 1=yes
var stoponhover = 0;
//END MENU SETTINGS

/* EasyTabs Functions*/
function easytabs(menunr, active) {if (menunr == autochangemenu){currenttab=active;}if ((menunr == autochangemenu)&&(stoponhover==1)) {stop_autochange()} else if ((menunr == autochangemenu)&&(stoponhover==0))  {counter=0;}menunr = menunr-1;for (i=1; i <= tabcount[menunr]; i++){document.getElementById(tablink_idname[menunr]+i).className='tab'+i;document.getElementById(tabcontent_idname[menunr]+i).style.display = 'none';}document.getElementById(tablink_idname[menunr]+active).className='tab'+active+' tabactive';document.getElementById(tabcontent_idname[menunr]+active).style.display = 'block';}var timer; counter=0; var totaltabs=tabcount[autochangemenu-1];var currenttab=loadtabs[autochangemenu-1];function start_autochange(){counter=counter+1;timer=setTimeout("start_autochange()",1000);if (counter == changespeed+1) {currenttab++;if (currenttab>totaltabs) {currenttab=1}easytabs(autochangemenu,currenttab);restart_autochange();}}function restart_autochange(){clearTimeout(timer);counter=0;start_autochange();}function stop_autochange(){clearTimeout(timer);counter=0;}

addLoadEvent(function() {
	easytabs(1,loadtabs[0]);
}
);