/*
    scripts.js

    v1.0 - 22/dec/2003 - Bob Kersten - Initial version

    (C) Copyright 2003 Medusa, Media Usage Advice B.V.
    All rights reserved.
*/


cindex = -1;
naam_old = -1;

// browsercontrole
app = navigator.appName;
ver = navigator.appVersion;
mac = ver.indexOf("Macintosh") > 0;
win = ver.indexOf("Win") > 0;
vnum = parseFloat(ver);
magOok = (((app == "Netscape") && (vnum >= 3 )) ||
    ((mac) && (app == "Microsoft Internet Explorer") && (vnum >= 3.01 )) ||
    ((win) && (app == "Microsoft Internet Explorer") && (vnum >= 4 ))) ;

// als de browser rollovers kan laten zien dan de array met plaatjes aanmaken
if (magOok) {
    // vul het aantal roll-over plaatjes-1 in (hier dus aantal -1 = 7)
    off = new MakeImageArray(6);
    over = new MakeImageArray(16);
    down = new MakeImageArray(6);

    // vul hier de off-toestand van de plaatjes in
    off[0].src = "images/b1.gif";
    off[1].src = "images/b2.gif";
    off[2].src = "images/b3.gif";
    off[3].src = "images/b4.gif";
    off[4].src = "images/b5.gif";
    off[5].src = "images/b6.gif";
    off[6].src = "images/b7.gif";

    // vul hier de over-toestand in
    over[0].src = "images/b1a.gif";
    over[1].src = "images/b2a.gif";
    over[2].src = "images/b3a.gif";
    over[3].src = "images/b4a.gif";
    over[4].src = "images/b5a.gif";
    over[5].src = "images/b6a.gif";
    over[6].src = "images/b7a.gif";
    over[7].src = "images/m0.gif";
    over[8].src = "images/m1.gif";
    over[9].src = "images/m1b.gif";
    over[10].src = "images/m2.gif";
    over[11].src = "images/m3.gif";
    over[12].src = "images/m4.gif";
    over[13].src = "images/m5.gif";
    over[14].src = "images/m6.gif";
    over[15].src = "images/m7.gif";
    over[16].src = "images/m8.gif";

    // en ook de down-toestand
    down[0].src = "images/b1a.gif";
    down[1].src = "images/b2a.gif";
    down[2].src = "images/b3a.gif";
    down[3].src = "images/b4a.gif";
    down[4].src = "images/b5a.gif";
    down[5].src = "images/b6a.gif";
    down[6].src = "images/b7a.gif";
}

// de browser wordt verteld dattie de plaatjes moet pre-loaden     
function MakeImageArray(n) {
    this.length = n;
    for (var i = 0; i<=n; i++) {
        this[i] = new Image();
    }
    return this;
}

// de roll-over functie
function mOver(num,pos) {
    if (document.images) {
        if ((over[num].src != "") && (num != cindex)) {
            document.images[pos].src = over[num].src;
        }
    }
}

// de opruim functie
function mOut(num,pos) {
    if (document.images) {
        if ((off[num].src != "") && (num != cindex)) {
            document.images[pos].src = off[num].src;
        }
    }                   
}

// en de klik-functie
function mClick(num,pos) {
    if (document.images) {
        if ((down[num].src != "")) {
            if (cindex != -1) {
                document.images[naam_old].src = off[cindex].src;
            }
            document.images[pos].src = down[num].src;
            cindex = num;
            naam_old = pos;
        }
    }
}

// menu


function showSubmenu(x) {
	for(i=0;i<8;i++) {
		var productElement = document.getElementById("submenu" + i);
		if (productElement != null){
			if (i == x){
				document.getElementById("submenu" + i).style.display = "block";
				if (document.getElementById("menu" + i) != null){
					document.getElementById("menu" + i).className="active";
				}
			} else{
				document.getElementById("submenu" + i).style.display = "none";
				if (document.getElementById("menu" + i) != null){
					document.getElementById("menu" + i).className="nonactive";
				}
			}
		}
	}
 } 
 function menuOver(which) {
 	//alert(which + "knop");
	var productElement = document.getElementById(which + "knop");
	if (productElement != null){
		if(document.getElementById(which + "knop").className != "selected"){
			document.getElementById(which + "knop").className="menuOver";
		}
	}
	for(i=1;i<7;i++) {
		var productElement = document.getElementById("menu" + i + "submenu");
		if (productElement != null){
			if (("menu" + i + "submenu") == (which + "submenu")){
				document.getElementById(which + "submenu").style.display = "block";
			}else{
				document.getElementById(which + "submenu").style.display = "none";
			}
		}
	}
 }
 
 function menuOut(which) {
	var productElement = document.getElementById(which + "knop");
	if (productElement != null){
		if(document.getElementById(which + "knop").className != "selected"){
			document.getElementById(which + "knop").className="menuOut";
		}
	}
 }
 
function mainmenu(){
	$$("#nav li").each(function(item) {
		item.observe('mouseenter', function() {
			if (typeof(item.getElementsBySelector('ul')[0]) != 'undefined') {
				item.getElementsBySelector('ul')[0].setStyle({visibility: "visible",display: "block",zIndex: 50});
			}
		});
	});
	$$("#nav li").each(function(item) {
		item.observe('mouseleave', function() {
			if (typeof(item.getElementsBySelector('ul')[0]) != 'undefined') {
				item.getElementsBySelector('ul')[0].setStyle({visibility: "visible",display: "none"});
			}
		});
	});
}

