function doOnloadStuff(){
	if(!document.getElementById('start')){
    		hideAllSubnavigations("onload");
    		checkTable();
	}
    	setContentHeight();   
}

// --- Navigation
function hideAllSubnavigations(source){
	headNavigationLevel = document.getElementById('navigation').getElementsByTagName('ul')[0];
	
	subNavigationLevel1 = headNavigationLevel.getElementsByTagName('ul');
	
	subNavigationLevel = new Array();
	for(var i=0; i<subNavigationLevel1.length; i++){
		subNavigationLevel[i] = subNavigationLevel1[i];
	}	
	
	for(i=0; i<subNavigationLevel.length; i++){
		if(source == "onload" && subNavigationLevel[i].style.display == "block"){
			subNavigationLevel[i].style.display = 'block';
		}else{
			subNavigationLevel[i].style.display = 'none';
		}
	}  	
}

function showSubNavigation(subnavigation){
	hideAllSubnavigations("");
	subNavigationLevel[subnavigation].style.display = 'block';
}

function setContentHeight(){
	height = (window.innerHeight) ? window.innerHeight : document.body.clientHeight;

	if(height - 65  > document.getElementById('content').clientHeight){
		document.getElementById('content').style.height = (height - 65) + "px";
	}
}

function checkTable(){
	if(typeof(highlightRow) == "undefined"){
		highlightRow = 0;
	}
	var contentTables = document.getElementById('contentText').getElementsByTagName('table');
	for(var i=0; i<contentTables.length; i++){
		var trs = contentTables[i].getElementsByTagName("tr");
		for(var j=0; j<trs.length; j++){
			if(j + 1 == Number(highlightRow)){
				trs[j].setAttribute("class", "tableBackgroundHighlight");
				trs[j].setAttribute("className", "tableBackgroundHighlight");
				window.scrollTo(0, getAbsoluteY(trs[j]) - 10);
			}else if(j % 2 == 0){
				trs[j].setAttribute("class", "tableBackground1");
				trs[j].setAttribute("className", "tableBackground1");
			}else{
				trs[j].setAttribute("class", "tableBackground2");
				trs[j].setAttribute("className", "tableBackground2");			
			}
		}
	}
}


// --- Effects
window.addEvent('domready', function(){
	
	/*var mySlide = new Fx.Slide('tab1Text', {duration: 200});
	mySlide.hide();
	
	$('tab1').addEvent('mouseover', function(e){
		e = new Event(e);
		mySlide.slideIn();
		e.stop();
	});
	
	$('tab1').addEvent('mouseout', function(e){
		e = new Event(e);
		mySlide.slideOut();
		e.stop();
	});*/
	
	var myTips = new Tips($$('.tabTip'));	
}); 

window.onload = function(){
	doOnloadStuff(); 	
}

function getAbsoluteY(elm){
   var y = 0;
   if (elm && typeof elm.offsetParent != "undefined") {
     while (elm && typeof elm.offsetTop == "number") {
       y += elm.offsetTop;
       elm = elm.offsetParent;
     }
   }
   return y;
}
