// ver. 1.3.0 RAMAC
// 1.1 first public
// 1.2 edit: fading verbeterd
// 1.3 edit: menu blijft staan als actief

var unself;
var activeMenu = null;
var activePage = "home";

function activateMenu(menuLayerRef) {
	if (activeMenu==menuLayerRef) return;
	if (activeMenu) hideMenu(activeMenu);
	activeMenu = menuLayerRef;
	layerShow(menuLayerRef);
	if (menuLayerRef=="diensten_sub") {
		fadein('diensten_computers',0, 1, menuLayerRef);
		fadein('diensten_netwerken',0, 500, menuLayerRef);
		fadein('diensten_internet',0, 1000, menuLayerRef);
	}
	if (menuLayerRef=="aanpak_sub") {
		fadein('aanpak_projecten',0, 1, menuLayerRef);
		fadein('aanpak_systeembeheer',0, 500, menuLayerRef);
	}
	if (menuLayerRef=="support_sub") {
		fadein('support_contactformulier',0, 1, menuLayerRef);
		fadein('support_faq',0, 500, menuLayerRef);
	}
}

function hideMenu(layerID) {
	layerHide(layerID);
}

function turnOff(nr) {
	if (activeMenu && activeMenu!=(activePage+"_sub")) {
		hideMenu(activeMenu);
		activeMenu = null;
		if (activePage=="diensten" || activePage=="aanpak" || activePage=="support") telf = setTimeout('laterstart(activePage+"_sub")', 100);
	}
}

function timer(offon) {
	if (offon == 0)	{
		unself = setTimeout('turnOff()', 1200);
	}
	if (offon ==1)	{
		clearTimeout(unself);
	}
}

function laterstart(menuLayerRef) {
	if (activeMenu) {
	} else {
		activateMenu(menuLayerRef);
	}
}

function init() {
	initBrowserComp();
}

function preload() {
	menu = new Array()
	menu[01] = "menu/home.gif";
	menu[02] = "menu/home-a.gif";
	menu[03] = "menu/diensten.gif";
	menu[04] = "menu/diensten-a.gif";
	menu[05] = "menu/aampak.gif";
	menu[06] = "menu/aanpak-a.gif";
	menu[07] = "menu/support.gif";
	menu[08] = "menu/support-a.gif";
	menu[09] = "menu/contact.gif";
	menu[10] = "menu/contact-a.gif";
	im = new Array()
	for (var i = 1; i < menu.length; i++){
		im[i] = new Image()
		im[i].src = menu[i]
	}
	loadcheck = 1;
}

function display(imgname){
	document.images[activePage].src = "menu/"+activePage+".gif";
	document.images[imgname].src = "menu/"+imgname+"-a.gif";
	activePage=imgname;
	turnOff();
}

var browser = new browserObject();

function browserObject() {
	this.ver = navigator.appVersion;
	this.dom = document.getElementById?1:0;
	this.ie = (navigator.appName == "Microsoft Internet Explorer");
	this.ns = (navigator.appName == "Netscape");
	this.moz = ((navigator.userAgent.indexOf("Mozilla")!=-1)&&(navigator.userAgent.indexOf("Gecko")!=-1)&&(navigator.userAgent.indexOf("Netscape6")==-1));
	this.mac = (navigator.appVersion.indexOf("Mac")>0);
	this.win = (navigator.appVersion.indexOf("Win")>0);
	this.xwin = (navigator.appVersion.indexOf("X11")>0);
	this.opera = (navigator.userAgent.indexOf('Opera')!=-1);
	this.ie4 = (this.ie && !this.dom);
	this.ie5 = (this.ie && this.ver.indexOf("MSIE 5")>-1);
	this.ie6 = (this.ie && this.ver.indexOf("MSIE 6")>-1);
	this.ns4 = (this.ns && this.ver.indexOf("4.")>-1);
	this.ns6 = (this.ns && this.ver.indexOf("5.")>-1&&this.dom);
	this.ns60 = (this.ns6 && navigator.userAgent.indexOf('6.0')!=-1);
	this.ns61 = (this.ns6 && navigator.userAgent.indexOf('6.1')!=-1);
	this.compatible=((this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6) && !this.opera);
	this.width = null; //to be set later after document is loaded;
	this.height = null; //to be set later after document is loaded;
	return this;
}

function initBrowserComp() {
	if (browser.compatible) {
		if (browser.ie) {
			browser.width = document.body.clientWidth;
			browser.height = document.body.clientHeight;
			if(!browser.ie6) {
				Array.prototype.push = ArrayPush;
				Array.prototype.pop = ArrayPop;
			}
		}
		else if (browser.ns4) {
			browser.width = window.innerWidth;
			browser.height = window.innerHeight;
			initResizeBug();
		}
		else if (browser.ns6) {
			browser.width = window.innerWidth;
			browser.height = window.innerHeight;
		}
		else if(browser.opera) {
			browser.width = window.innerWidth;
			browser.height = window.innerHeight;
		}
		return (true);
	}
	else {
		return (true);
	}
}

function layerGetRef( ID ) {
	if (browser.ns6) return document.getElementById(ID);
	else if (browser.ns4) return document.layers[ID];
	else return document.all[ID];
}

function layerShow( ID ) {
	var thisID = layerGetRef(ID);
	if (browser.ns4) thisID.visibility = "show";
	else thisID.style.visibility = "visible";
}
function layerHide( ID ) {
	var thisID = layerGetRef(ID);
	if (browser.ns4) thisID.visibility = "hide";
	else thisID.style.visibility = "hidden";
}

function initResizeBug() {
	document.orPageWidth = innerWidth;
	document.orPageHeight = innerHeight;
	onresize = nsResizeBug;
}
function nsResizeBug() {
	if (innerWidth != document.orPageWidth || innerHeight != document.orPageHeight) location.reload();
}
function ArrayPush(the_element) {
	this[this.length] = the_element;
}
function ArrayPop(the_element) {
	var the_value = this[this.length-1];
	this.length--;
	return(the_value);
}
init();

function fadein(p,alpha,timer,actmenu) {
	b = alpha * 2;
	document.images[p].style.filter = "alpha(Opacity="+b+", FinishOpacity="+alpha+", Style=1, StartX=0, StartY=0, FinishX="+alpha+", FinishY="+alpha+")";
	alpha=alpha+3;
	if ((actmenu==activeMenu) && (alpha < 100)) setTimeout("fadein('" + p + "',"+alpha+",1,'"+actmenu+"');", timer);
}