/* Fragment Highlight version 0.1; this JavaScript highlight code is copyright 2003 by David Dorward; http://dorward.me.uk; this JavaScript library is copyright 2002 by Gavin Kistner and Refinery; www.refinery.com */

/* Mark external links */
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function extLinks () {
	if (document.getElementsByTagName) {
		var an = document.getElementsByTagName("a");
		var obj;
		for (var i=0; i<an.length; i++) {
			obj = an.item(i);
	    if (obj.href.indexOf(location.host) == -1 && obj.href && obj.className.indexOf("noLinkImg")) {
				obj.rel = "external";
				obj.title = "Externe site: " + obj.title;
				var mark = document.createElement("img");
				mark.src = "http://www.waddenacademie.knaw.nl/fileadmin/gen_m/js/exit2.png";
				mark.alt = "(externe site)";
				mark.width = "10";
				mark.height = "8";
				mark.className = "exit";
				mark.border = "0";
				obj.appendChild(mark);
			}
		}
	}
}
function createTopButton () {
	var t = document.getElementById("innerContent");
	var div = document.createElement("div");
	div.id = "toThePageTop";
	t.appendChild(div);
	var a;
	var img;
	for(var u = 0; u < 2; u++) {
		a = document.createElement("a");
		a.className = "off";
		a.href = "#top";
		//a.title = "Top";
		if(u == 0) a.title = "top";
		else a.title = "top";
		//a.onclick = "return scrollToTop();"
		if(u == 0) a.id = "top-links";
		else a.id = "top-rechts";
		div.appendChild(a);
		img = document.createElement("img");
		img.alt = "Top";
		img.src = "http://www.waddenacademie.knaw.nl/fileadmin/gen_m/js/top.png";
		img.width = "16";
		img.height = "16";
		img.border = "0";
		a.appendChild(img);
	}
}

function adjustTopButton() {

	var tl = document.getElementById("top-links");

	var tr = document.getElementById("top-rechts");
	var s = document.body.scrollTop || (document.documentElement && document.documentElement.scrollTop);
	
	if(s > 0) {
		tl.className = tr.className = "on";
		// determine support for position: fixed and apply hack if necessary
		var pos;
		if(document.getElementById("toThePageTop").currentStyle)
			pos = document.getElementById("toThePageTop").getElementsByTagName("a")[1].currentStyle.position;
			
		else
			pos = 0;

		if(pos == "absolute") {
			 var docHeight = document.getElementById("contentMain").clientHeight;
			var winHeight = document.documentElement.clientHeight;
			var p = s + winHeight - 510 + "px";
			alert(winHeight );
			tl.style.top = tr.style.top = p;
				
		}
	}
	else
		tl.className = tr.className = "off";
}

/* Init the script */
window.onload = function(){
	extLinks();
	/*fragHLload();*/
	/*fragHLlink();*/
	
	
	if (document.getElementById && document.documentElement) {
		createTopButton();
		setInterval("adjustTopButton()", 100);
	}
}

