function change(id, newClass) {
	document.getElementById(id).className=newClass;
}

function movepic(imgname, source) {
	document[imgname].src=source;
}

function clearTextBox (inputId) {
	if (document.getElementById(inputId).value == "- geen voorkeur -") {
		document.getElementById(inputId).value = "";
	}
	if (document.getElementById(inputId).value == "gebruikersnaam") {
		document.getElementById(inputId).value = "";
	}
}

function fillTextBox (inputId,fillText) {
	if (document.getElementById(inputId).value == "") {
		document.getElementById(inputId).value = fillText;
	}
}

function clearPassBox (inputId) {
	if (document.getElementById(inputId).value == "wachtwoord") {
		document.getElementById(inputId).value = "";
		document.getElementById(inputId).type = "password";
	}
}

function fillPassBox(inputId,Pass) {
	if (document.getElementById(inputId).value == "") {
		document.getElementById(inputId).value = Pass;
		document.getElementById(inputId).type = "text";
	}
}

function toggle(definitionId) {
	if (document.getElementById(definitionId).style.display=="block") {
		document.getElementById(definitionId).style.display="none";
	}
	else {
		document.getElementById(definitionId).style.display="block";
	}
}

function Preload() {
	var arImages=new Array();
	var temp = Preload.arguments;
	for(x=0; x < temp.length; x++) {
		arImages[x]=new Image();
		arImages[x].src=Preload.arguments[x];
	}
}

//addEvent() by John Resig

function addEvent( obj, type, fn ){ 
   if (obj.addEventListener){ 
	  obj.addEventListener( type, fn, false );
   }
   else if (obj.attachEvent){ 
	  obj["e"+type+fn] = fn; 
	  obj[type+fn] = function(){ obj["e"+type+fn]( window.event ); } 
	  obj.attachEvent( "on"+type, obj[type+fn] ); 
   } 
} 
	
//Run dynamicLayout function when page loads and when it resizes.

addEvent(window, 'load', footer);
addEvent(window, 'load', addHoverToSummary);
addEvent(window, 'load', addScriptToSearchBox);
addEvent(window, 'resize', footer);

function addHoverToSummary() {
	// Haal een array op met alle h2'tjes in het document
	var dashboard = document.getElementById('dashboard');
	if (dashboard) {
		var summary = dashboard.childNodes;
	
		// Loop door de array en voeg er een event aan toe
		for(var i=0;i<summary.length;i++) {
			// Voeg aan iedere h2 een event(onmouseover) die de functie change() aanroept
			summary[i].onmouseover=function(){this.className="summary active";};
			summary[i].onmouseout=function(){this.className="summary";};
			summary[i].onclick=function(){
				var linkLocation = null;
				var children = this.childNodes;
				for (i=0; i<children.length; i++) {
					var grandChildren = children[i].childNodes;
					for (j=0; j<grandChildren.length; j++) {
						 if(grandChildren[j].tagName && grandChildren[j].tagName.toLowerCase() == 'a') {
						 	linkLocation = grandChildren[j];
						 }
					 }
				}
				window.location=linkLocation;
			};
		}
	}
	
	var items = document.getElementsByTagName("li");
	if (items) {
		for (var i = 0; i < items.length; i++) {
			if (items[i].className == 'orderLi') {
				var item = items[i];
				item.onmouseover=function(){this.className="active";};
				item.onmouseout=function(){this.className="";};
				
				item.onclick=function(){
					var linkLocation = null;
					var children = this.childNodes;
					for (i=0; i<children.length; i++) {
						 if(children[i].tagName && children[i].tagName.toLowerCase() == 'a') {
						 	linkLocation = children[i];
						 }
					}
					window.location=linkLocation;
				};
			}
		}
	}
	
	// Mouse over highlight voor het 'Customer Barge Planning'-document
	var bargePlanning = document.getElementById('bargePlanning');
	if (bargePlanning) {
		bargePlanning.onmouseover=function(){this.className="bargePlanning active";};
		bargePlanning.onmouseout=function(){this.className="bargePlanning";};
	}
}

function addScriptToSearchBox() {
	var searchBox = document.getElementById('searchBox');

	if (searchBox) {
		var boxText = "Order number";
		if (!searchBox.value || searchBox.value == boxText) {
			searchBox.className="queryBlurred";
			searchBox.value=boxText;
			searchBox.onfocus=function(){
				if (this.value == boxText) {
					this.value="";
					this.className="query";
				}
			};
			searchBox.onblur=function(){
				if (this.value == "") {
					this.className="queryBlurred";
					this.value=boxText;
				}
			};
		}
	}
}

function footer() {
	var ie5=document.all&&document.getElementById;
	var bottomedge=ie5? document.documentElement.clientHeight : window.innerHeight;	
	var containerHeight = document.getElementById('main').offsetHeight+document.getElementById('footer').offsetHeight;

	var el = document.getElementById('footer');  
  
	if (bottomedge>containerHeight) {
		el.style.position='fixed';
		el.style.bottom='0';
		el.style.left='auto';		
	}
	else {
		el.style.position='relative';
	}
}

function showBargeInfo(bargeOrDraft, bargeId, divId) {
	params = 'bargeId='+escape(bargeId)+'&bargeOrDraft='+escape(bargeOrDraft);
	var loader=new net.ContentLoader('fleet020.php', dirDivContent,'' ,'' ,params,'', divId);	
	footer();
	return false;
}

function toggleBargeInfo(elementOn, elementOff) {
	document.getElementById(elementOn).style.display="block";	
	document.getElementById(elementOff).style.display="none";
	footer();	
	return false;
}

function writeChart(content) {
	document.write(content);
}