startList = function() {

	if (document.all&&document.getElementById) {

		navRoot = document.getElementById("nav");

		for (i=0; i<navRoot.childNodes.length; i++) {

			node = navRoot.childNodes[i];

			if (node.nodeName=="LI") {

				for (j=0; j<node.childNodes.length; j++) {
					node2 = node.childNodes[j];
					for (k=0; k<node2.childNodes.length; k++) {
						node3 = node2.childNodes[k];

						if (node3.nodeName=="LI") {

							node3.onmouseover=function() {
								this.className+=" over";
					  		}

					  		node3.onmouseout=function() {
					  			this.className=this.className.replace(" over", "");
					   		}
					   	}

					}

				}

				node.onmouseover=function() {
					this.className+=" over";
		  		}

		  		node.onmouseout=function() {
		  			this.className=this.className.replace(" over", "");
		   		}
		   	}

		}
	}
}

window.onload=startList;

function ge (id) {

	return document.getElementById(id);

}


function gaNaar(i) {

	document.location.href = i.value;

}


function changePage (pag) {

	if(pag!=curPage) {

		ge('pag' + pag).className = 'block';
		ge('pag' + curPage).className = 'none';

		ge('nr' + pag).className = 'zoekpagnr zoekpagnractief';
		ge('nr' + curPage).className = 'zoekpagnr';

		ge('fnr' + pag).className = 'zoekpagnr zoekpagnractief';
		ge('fnr' + curPage).className = 'zoekpagnr';

	}

	curPage = pag;
}

function setAktie(field) {

	switch(field.value) {

		case "afmelden":

			document.forms[0].action.value="afmelden";
			break;

		default:

			break;
	}

}

/* 	function changeVestigingPag
		wisselt op een vestigingdetailpagina tussen route en contact
*/

var currentVPag = "contact";

function changeVestigingPag () {

	if (currentVPag == "contact") {

		ge('vestigingcontact').style.display = 'none';
		ge('vestigingbalkcontact').style.fontWeight = 'normal';

		ge('vestigingroute').style.display = 'block';
		ge('vestigingbalkroute').style.fontWeight = 'bold';

		currentVPag = "route";

	} else if (currentVPag == "route") {

		ge('vestigingcontact').style.display = 'block';
		ge('vestigingbalkcontact').style.fontWeight = 'bold';

		ge('vestigingroute').style.display = 'none';
		ge('vestigingbalkroute').style.fontWeight = 'normal';

		currentVPag = "contact";

	}

}

/* ajax ding */

function createRequestObject() {
	try
	{
		var ro = new XMLHttpRequest();
	}
	catch (error)
	{
		try
		{
			var ro = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (error)
		{
			return false;
		}
	}
	return ro;
}

var http = createRequestObject();

function getGarageSelectHTML (id) {
		http.open('get', '/include/ajax.inc.php?actie=garage&id='+id);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {

    if(http.readyState == 4){
        var response = http.responseText;
    		ge('garagecode').innerHTML = response;
    }

}

/* ajax modellen op halen aan de hand van het merk */
function getmodellen(i) {
	
	http.open('get', '/include/ajax.inc.php?actie=model&merk='+i.value);
http.onreadystatechange = handleResponseModel;
http.send(null);
}
	
function handleResponseModel() {

    if(http.readyState == 4){
        var response = http.responseText;
        	ge('modellen').innerHTML = response;
    }

}	
	
	
function zoekUitgebreid() {
	document.occasionzoeken.uitgebreid.value = 'ja';
	document.occasionzoeken.zoek.value = '0';
	document.occasionzoeken.submit();
	
}


/* 	function showOccasionFoto
		occasion foto's tonen en met volgende/vorige de foto's wijzigen
*/

var fotooccasion = 1;	// beginnen bij foto 1

function showOccasionFoto(aantal, foto) {
		
		if(foto=='prev') {
				if(fotooccasion>1) {
						ge('occasionfoto_'+fotooccasion).style.display = 'none';
						fotooccasion = fotooccasion-1;
						ge('occasionfoto_'+fotooccasion).style.display = 'block';
						
				}
		}
		
		if(foto=='next') {
				if(fotooccasion<aantal) {
						ge('occasionfoto_'+fotooccasion).style.display = 'none';
						fotooccasion = fotooccasion+1;
						ge('occasionfoto_'+fotooccasion).style.display = 'block';
						
				}
		}
		
		// nr aanpassen: foto i van 4
		ge('aantal_occ').innerHTML = fotooccasion;
		
		
}