// -------------------------------- preload afbeeldingen
var locationAfterPreload = "#" 
var lengthOfPreloadBar = 300 // Length of preload bar (in pixels)
var heightOfPreloadBar = 15 // Height of preload bar (in pixels)
var yourImages = new Array("images/welkom.png","images/pistache_bg.gif","images/pistache_titel.gif","images/pistache_midden.gif","images/pistache_footer.gif")

yourImages.push("images/menu/nl/pistache_contact.gif");
yourImages.push("images/menu/nl/pistache_diversen.gif");
yourImages.push("images/menu/nl/pistache_navigatie.gif");
yourImages.push("images/menu/nl/standby/pistache_comments.gif");
yourImages.push("images/menu/nl/standby/pistache_eetkaart.gif");
yourImages.push("images/menu/nl/standby/pistache_email.gif");
yourImages.push("images/menu/nl/standby/pistache_geschiedenis.gif");
yourImages.push("images/menu/nl/standby/pistache_home.gif");
yourImages.push("images/menu/nl/standby/pistache_ijsgeschiedenis.gif");
yourImages.push("images/menu/nl/standby/pistache_ijskaart.gif");
yourImages.push("images/menu/nl/standby/pistache_interieur.gif");
yourImages.push("images/menu/nl/standby/pistache_jobs.gif");
yourImages.push("images/menu/nl/standby/pistache_ligging.gif");
yourImages.push("images/menu/nl/standby/pistache_menukaart.gif");
yourImages.push("images/menu/nl/standby/pistache_theekaart.gif");
yourImages.push("images/menu/nl/standby/pistache_verhuur.gif");
yourImages.push("images/menu/nl/standby/pistache_wijnkaart.gif");
yourImages.push("images/menu/nl/hover/pistache_h_comments.gif");
yourImages.push("images/menu/nl/hover/pistache_h_eetkaart.gif");
yourImages.push("images/menu/nl/hover/pistache_h_email.gif");
yourImages.push("images/menu/nl/hover/pistache_h_geschiedenis.gif");
yourImages.push("images/menu/nl/hover/pistache_h_home.gif");
yourImages.push("images/menu/nl/hover/pistache_h_ijsgeschiedenis.gif");
yourImages.push("images/menu/nl/hover/pistache_h_ijskaart.gif");
yourImages.push("images/menu/nl/hover/pistache_h_interieur.gif");
yourImages.push("images/menu/nl/hover/pistache_h_jobs.gif");
yourImages.push("images/menu/nl/hover/pistache_h_ligging.gif");
yourImages.push("images/menu/nl/hover/pistache_h_menukaart.gif");
yourImages.push("images/menu/nl/hover/pistache_h_theekaart.gif");
yourImages.push("images/menu/nl/hover/pistache_h_verhuur.gif");
yourImages.push("images/menu/nl/hover/pistache_h_wijnkaart.gif");

if (document.images) {
	var dots = new Array() 
	dots[0] = new Image(1,1)
	dots[0].src = "images/load_back.gif" // default preloadbar color (note: You can substitute it with your image, but it has to be 1x1 size)
	dots[1] = new Image(1,1)
	dots[1].src = "images/load_front.gif" // color of bar as preloading progresses (same note as above)
	var preImages = new Array(),coverage = Math.floor(lengthOfPreloadBar/yourImages.length),currCount = 0
	var loaded = new Array(),i,covered,timerID
	var leftOverWidth = lengthOfPreloadBar%coverage
}
function loadImages() { 
	for (i = 0; i < yourImages.length; i++) { 
		preImages[i] = new Image()
		preImages[i].src = yourImages[i]
	}
	for (i = 0; i < preImages.length; i++) { 
		loaded[i] = false
	}
	checkLoad()
}
function checkLoad() {
	if (currCount == preImages.length) { 
		location.replace(locationAfterPreload)
		return
	}
	for (i = 0; i <= preImages.length; i++) {
		if (loaded[i] == false && preImages[i].complete) {
			loaded[i] = true
			eval("document.img" + currCount + ".src=dots[1].src")
			currCount++
		}
	}
	timerID = setTimeout("checkLoad()",10) 
}

//---------------------------------
function switchen(id , lg ) {
	element =	document.getElementById(id);
	element.src = "/images/menu/"+ lg +"/hover/pistache_h_" + id + ".gif" ;
}

function backswitch(id , lg){
	element =	document.getElementById(id);
	element.src = "/images/menu/"+ lg +"/standby/pistache_" + id + ".gif" ;
	
}

function showSubmenu( id , lg) {
	element =	document.getElementById(id);
	element.innerHTML = "<a href=\""+lg+".php?page=eetkaart\"><img id=\"eetkaart\" src=\"/images/menu/"+lg+"/standby/pistache_eetkaart.gif\" onmouseover=\"switchen(this.id , "+lg+")\" onmouseout =\"backswitch(this.id , "+lg+")\" /></a><a href=\""+lg+".php?page=ijskaart\">	<img id=\"ijskaart\" src=\"/images/menu/"+lg+"/standby/pistache_ijskaart.gif\" onmouseover=\"switchen(this.id , "+lg+")\" onmouseout =\"backswitch(this.id , "+lg+")\" /></a><a href=\""+lg+".php?page=theekaart\">	<img id=\"theekaart\" src=\"/images/menu/"+lg+"/standby/pistache_theekaart.gif\" onmouseover=\"switchen(this.id , "+lg+" )\" onmouseout =\"backswitch(this.id , "+lg+" )\"/></a><a href=\""+lg+".php?page=wijnkaart\">		<img id=\"wijnkaart\" src=\"/images/menu/"+lg+"/standby/pistache_wijnkaart.gif\" onmouseover=\"switchen(this.id , "+lg+" )\" onmouseout =\"backswitch(this.id , "+lg+")\"/></a>";
}
// -------------------------------- ajax functies
var req = createXMLHttpRequest();

function createXMLHttpRequest() {
    var ua;
    if (window.XMLHttpRequest) {
        try {
            ua = new XMLHttpRequest;
        } catch (e) {
            ua = false;
        }
    } else if (window.ActiveXObject) {
        try {
            ua = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
            ua = false;
        }
    }
    return ua;
}

function handleResponse() {
    if (req.readyState == 4) {
        var response = req.responseText;
        var update = new Array;
        if (response.indexOf("||" != -1)) {
            update = response.split("||");
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
}

function getPage(id) {
	if (id != 'eetkaart' && id != 'ijskaart' && id !='theekaart' && id !='wijnkaart'){
		element =	document.getElementById('submenu_menukaart');
		element.innerHTML = "";
	}
	req.open('get', '/request.php?pagina=' + id);
	req.onreadystatechange = handleResponse;
	req.send(null); 
}
