//script for showing and hiding layers, use of Timeouts included.
//it doesn't need editing to provide this functionality.
// constructs a browser information object
function checkBrowser() {
	var b = navigator.appName;
	if (b=="Netscape") {
		this.b = "ns";
	} else if (b=="Microsoft Internet Explorer") {
		this.b = "ie";
	}else {
		this.b = b;
	}
	this.v = parseFloat(navigator.appVersion);

	this.ie4=(navigator.userAgent.indexOf('MSIE 4')>0);
	this.ie5=(navigator.userAgent.indexOf('MSIE 5')>0);
	this.ie6=(navigator.userAgent.indexOf('MSIE 6')>0);
	this.ns4=(this.b=="ns" && this.v>=4.08 && this.v<5);
	this.ns6=(this.b=="ns" && this.v>=5);
	this.mac = (navigator.appVersion.indexOf("Macintosh")>0);
	this.win = (navigator.appVersion.indexOf("Win")>0);
	this.ie5mac = (this.ie5) && (this.mac);
	this.ie4mac = (this.ie4) && (this.mac);
		
	// is the users browser compatible with the webapplication?
	this.ie = (this.ie5 || this.ie6 || (this.ie4 && !this.mac))
	this.ns = (this.ns4);
	this.compatible=(this.ie || this.ns);
	return (this)
}

var browser = new checkBrowser();

//browsertest
var ns4 = (document.layers)? true:false
//var ie4 = (document.all)? true:false
var ie4 = (browser.ie4 || browser.ie || browser.ns6)? true:false
//alert(ie4 + " ie4");
if (ns4 || ie4) {
	//constructor function Layers objects
	function Layers(naamlayer) {
		//alert("j");
		this.aid = naamlayer
		this.show = ns4 ? ShowLayerNS : ShowLayerIE
		this.hide = ns4 ? HideLayerNS : HideLayerIE
		this.showtime = ns4 ? ShowTimeNS : ShowTimeIE
		this.hidetime = ns4 ? HideTimeNS : HideTimeIE
		this.showinlayer = ShowInLayerNS
		this.hideinlayer = HideInLayerNS
		this.moveme = ns4 ? MoveMeNS : MoveMeIE
	}
	
	//Netscape functions
	function ShowLayerNS() {	
		//alert("L")
		var LayerItems = this.aid.split(",");
		for (var i=0; i<LayerItems.length; i++) {					
			eval("document."+LayerItems[i]+".visibility='show'")
			eval("document."+LayerItems[i]+".display='block'")
		}
	}
	function HideLayerNS() {	
		//alert("K")
		var LayerItems = this.aid.split(",");
		for (var i=0; i<LayerItems.length; i++) {		
			eval("document."+LayerItems[i]+".visibility='hide'")
			eval("document."+LayerItems[i]+".display='none'")
		}
	}
	function ShowTimeNS(tijd) {
		this.showtimeout = setTimeout("ShowLayerNSafter('"+this.aid+"')", tijd);
	}
	function HideTimeNS(tijd) {
		this.hidetimeout = setTimeout("HideLayerNSafter('"+this.aid+"')", tijd);
	}
	function ShowLayerNSafter(aid) {	
		eval("document."+aid+".visibility='show'")
	}
	function HideLayerNSafter(aid) {	
		eval("document."+aid+".visibility='hide'")
	}
	function ShowInLayerNS(naammylayer) {	
		eval("document."+naammylayer+".document."+this.aid+".visibility='show'")
	}
	function HideInLayerNS(naammylayer) {	
		eval("document."+naammylayer+".document."+this.aid+".visibility='hide'")	
	}
	function MoveMeNS(x,y) {
		eval("document."+this.aid+".moveTo("+x+","+y+")")
	}
	
	//Internet Explorer functions
	function ShowLayerIE() {	
		var LayerItems = this.aid.split(",");
		for (var i=0; i<LayerItems.length; i++) {			
			eval("document.all."+LayerItems[i]+".style.visibility='visible'")
			eval("document.all."+LayerItems[i]+".style.display='inline'")
		}
	}
	function HideLayerIE() {		
		//alert("g")	
		var LayerItems = this.aid.split(",");
		for (var i=0; i<LayerItems.length; i++) {			
			eval("document.all."+LayerItems[i]+".style.visibility='hidden'")
			eval("document.all."+LayerItems[i]+".style.display='none'")
		}
	}
	function ShowTimeIE(tijd) {
		this.showtimeout = setTimeout("ShowLayerIEafter('"+this.aid+"')", tijd);
	}
	function HideTimeIE(tijd) {
		this.hidetimeout = setTimeout("HideLayerIEafter('"+this.aid+"')", tijd);
	}
	function ShowLayerIEafter(aid) {	
		eval("document.all."+aid+".style.visibility='visible'")
	}
	function HideLayerIEafter(aid) {	
		eval("document.all."+aid+".style.visibility='hidden'")
	}
	function MoveMeIE(x,y) {
		eval("document.all."+this.aid+".style.left = " +x);
		eval("document.all."+this.aid+".style.top = " +y);	
	}	
}

//Functions to trigger the Objects
function Show() {
	//alert(ie4 + " ie4");
	if (ns4 || ie4) {				
		for (var i=0; i<arguments.length; i++) {
			eval("myLayers["+arguments[i]+"].show()");
		}
	}		
}

function Hide() {
	var ie4 = (browser.ie4 || browser.ie || browser.ns6)? true:false	
	if (ns4 || ie4) {
		for (var i=0; i<arguments.length; i++) {
			//alert("myLayers["+arguments[i]+"].hide()");
			eval("myLayers["+arguments[i]+"].hide()");
		}	
	}	
}

function ShowTime(tijd) {
	if (ns4 || ie4) {
		for (var i=1; i<arguments.length; i++) {
			eval("myLayers["+arguments[i]+"].showtime("+tijd+")");
		}	
	}	
}

function HideTime(tijd) {
	if (ns4 || ie4) {
		for (var i=1; i<arguments.length; i++) {
			eval("myLayers["+arguments[i]+"].hidetime("+tijd+")");
		}
	}		
}

function CancelShow() {
	if (ns4 || ie4) {
		for (var i=0; i<arguments.length; i++) {
			eval("clearTimeout(myLayers["+arguments[i]+"].showtimeout)");
		}
	}	
}

function CancelHide() {
	if (ns4 || ie4) {
		for (var i=0; i<arguments.length; i++) {
			eval("clearTimeout(myLayers["+arguments[i]+"].hidetimeout)");
		}
	}	
}

//Functions to trigger the Objects
function DB_Show() {
	if (ns4 || ie4) {
		for (var i=0; i<arguments.length; i++) {
			eval("myDBLayers["+arguments[i]+"].show()");
		}
	}		
}

function DB_Hide() {
	if (ns4 || ie4) {
		for (var i=0; i<arguments.length; i++) {
			eval("myDBLayers["+arguments[i]+"].hide()");
		}	
	}	
}

function DB_ShowTime(tijd) {
	if (ns4 || ie4) {
		for (var i=1; i<arguments.length; i++) {
			eval("myDBLayers["+arguments[i]+"].showtime("+tijd+")");
		}	
	}	
}

function DB_HideTime(tijd) {
	if (ns4 || ie4) {
		for (var i=1; i<arguments.length; i++) {
			eval("myDBLayers["+arguments[i]+"].hidetime("+tijd+")");
		}
	}		
}

function DB_CancelShow() {
	if (ns4 || ie4) {
		for (var i=0; i<arguments.length; i++) {
			eval("clearTimeout(myDBLayers["+arguments[i]+"].showtimeout)");
		}
	}	
}

function DB_CancelHide() {
	if (ns4 || ie4) {
		for (var i=0; i<arguments.length; i++) {
			eval("clearTimeout(myDBLayers["+arguments[i]+"].hidetimeout)");
		}
	}	
}

function DB_MoveMe(x,y) {
	if (ns4 || ie4) {
		for (var i=2; i<arguments.length; i++) {
			eval("myDBLayers["+arguments[i]+"].moveme("+x+","+y+")");
		}
	}		
}
// Copyright Richard Berendsen & Gerben van Eerten, BPi.

