 function obj(id) {
	return document.getElementById(id);
}

/* zoeken */

function setoption (option,ovalue) {
	obj('f_start').value = 0;
	if (option != '')
		obj(option).value = ovalue;
	obj('f').submit();
	return false;
}

/* submit proefritten */

function submitProefrit() {
	// iets met maar 3 auto's
	var i, counter = 0;
	for (i = 0; i < document.getElementById('f_proefrit').length; i++) {
		if (document.getElementById('f_proefrit').elements[i].checked)
			counter++; 
	}

	if (counter > 3) 
		alert ('U kan maximaal voor 3 auto\'s een proefrit aanvragen.'); 	
	else if (counter == 0)
		alert ('U heeft nog geen auto(\'s) geselecteerd.'); 	
	else 
		document.getElementById('f_proefrit').submit();
}

function proefritDetails(id) {
	detailsWin = window.open ('/proefritten/details.html?id='+id, 'detailsWin', 'width=750,height=850,status=no,menubar=no,resizable=yes,scrollbars=no');
	detailsWin.focus();
}

/* popup */

function details(id) {
	detailsWin = window.open ('/voorraad/details.html?id='+id, 'detailsWin', 'width=500,height=600,status=no,menubar=no,resizable=yes,scrollbars=no');
	detailsWin.focus();
}

/* lease bedrag window */

function leasewindow() {
	leaseWin = window.open ('/voorraad/lease.html', 'leaseWin', 'width=400,height=250,status=no,menubar=no,resizable=no,scrollbars=yes');
	leaseWin.focus();
}

/* pakketten popup */

function pakketten() {
	pakketWin = window.open ('/voorraad/offerte/pakketten.html', 'pakketWin', 'width=900,height=650,status=no,menubar=no,resizable=no,scrollbars=yes');
	pakketWin.focus();
}

/* popup print template */

function printDetails(id, prov) {
	printWin = window.open ('/voorraad/print.html?id='+id+'&prov='+prov, 'printWin', 'width=500,height=600,status=no,menubar=no,resizable=yes,scrollbars=no');
	printWin.focus();
}

function printOfferte(id) {
	printWin = window.open ('/voorraad/offerte/print.html?id='+id, 'printWin', 'width=500,height=600,status=no,menubar=no,resizable=yes,scrollbars=no');
	printWin.focus();
}

/* popup groot plaatje */

function open_image (sid, fid) {
	imgWindow = window.open('/voorraad/image.html?sid='+sid+'&fid='+fid, 'imgWindow', 'height=550,width=660');
	imgWindow.focus();
}

/* toon en verstop inruil form */

function inruil() {
	if (document.getElementById('f_inruil').value == 'auto') {
		document.getElementById('f_auto').style.display="block";
		document.getElementById('f_motor').style.display="none";
		document.getElementById('f_boot').style.display="none";
		document.getElementById('f_caravan').style.display="none";
		document.getElementById('f_camper').style.display="none";
		//document.getElementById('f_KENTEKEN1').focus(); 
	}
	else if (document.getElementById('f_inruil').value == 'motor') {
		document.getElementById('f_auto').style.display="none";
		document.getElementById('f_motor').style.display="block";
		document.getElementById('f_boot').style.display="none";
		document.getElementById('f_caravan').style.display="none";
		document.getElementById('f_camper').style.display="none";
		//document.getElementById('f_MERK').focus(); 
	}
	else if (document.getElementById('f_inruil').value == 'boot') {
		document.getElementById('f_auto').style.display="none";
		document.getElementById('f_motor').style.display="none";
		document.getElementById('f_boot').style.display="block";
		document.getElementById('f_caravan').style.display="none";
		document.getElementById('f_camper').style.display="none";
		//document.getElementById('f_MERK').focus(); 
	}
	else if (document.getElementById('f_inruil').value == 'caravan') {
		document.getElementById('f_auto').style.display="none";
		document.getElementById('f_motor').style.display="none";
		document.getElementById('f_boot').style.display="none";
		document.getElementById('f_caravan').style.display="block";
		document.getElementById('f_camper').style.display="none";
		//document.getElementById('f_MERK').focus(); 
	}
	else if (document.getElementById('f_inruil').value == 'camper') {
		document.getElementById('f_auto').style.display="none";
		document.getElementById('f_motor').style.display="none";
		document.getElementById('f_boot').style.display="none";
		document.getElementById('f_caravan').style.display="none";
		document.getElementById('f_camper').style.display="block";
		//document.getElementById('f_MERK').focus(); 
	}
	else if (document.getElementById('f_inruil').value == 0) {
		document.getElementById('f_auto').style.display="none";
		document.getElementById('f_motor').style.display="none";		
		document.getElementById('f_boot').style.display="none";
		document.getElementById('f_caravan').style.display="none";
		document.getElementById('f_camper').style.display="none";
	}
}

/* toon en verstop lease form */

function lease() {
	document.getElementById('s_lease').style.display="block";
	document.getElementById('f_bedrag').focus(); 
}

function nolease() {
	document.getElementById('s_lease').style.display="none";
}

/* toon en verstop proefrit form */

function proefrit() {
	if (document.getElementById('f_proefrit').checked) {
		document.getElementById('f_rit').style.display="block";
		document.getElementById('f_rijbewijs').focus(); 
	}
	else
		document.getElementById('f_rit').style.display="none";
}

// function financiering(mr, md, ty, gewicht, ni, bj, ke) {
	
function financiering(rp, np, mr, md, ty, gewicht, ni, bj, ke) {
	finWin = window.open('https://www.financieringverzekering.nl/autocash3/startframe.asp?RP='+rp+'&&NP='+np+'&DN=8448&SK=ASK&TR=KDW&MR='+mr+'&MD='+md+'&TY='+ty+'&GEWICHT='+gewicht+'&NI='+ni+'&BJ='+bj+'&KE='+ke, 
		'finWin', 'width=740,height=670,status=no,menubar=no,resizable=yes,scrollbars=no'); 
	finWin.focus(); 
}

function financiering2() {
	finWin = window.open('https://www.financieringverzekering.nl/autocash3/startframe.asp?DN=8448&SK=ASK&TR=KDW', 
		'finWin', 'width=740,height=670,status=no,menubar=no,resizable=yes,scrollbars=no'); 
	finWin.focus(); 
}

/* resize to object */

function resizetoobj(object, extrawidth, extraheight) {
	if (obj(object).offsetWidth) {
		// object size + extra size + window size
		w = obj(object).offsetWidth + extrawidth +10;
		h = obj(object).offsetHeight + extraheight +29;
		//document.title = obj(object).offsetHeight;
		window.resizeTo(w,h);
	}
}

/* show hints in /inkoop */

var posx = 0;
var posy = 0;
var hintserror = 0;

function evt(e) {
	posx = e.pageX;
	posy = e.pageY;
}

function showhint(id) {
	var spax = 200;
	var spay = 70;

	if (window.event) {
		posx = window.event.clientX + document.getElementsByTagName('body')[0].scrollLeft;
		posy = window.event.clientY + document.getElementsByTagName('body')[0].scrollTop;
	} else {
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = evt;
	}
	if ((posx != 0) && (posy != 0) && hints[id]) {
		obj('hint').style.top = (posy - spay)+'px';
		obj('hint').style.left = (posx - spax)+'px';
		obj('hint').innerHTML = hints[id];
		obj('hint').style.display = 'block';
	} else if (hints[id]) {
		window.status= "error displaying tooltip";
		hintserror = 1;
	}
}

function hidehint() {
	obj('hint').style.display = 'none';
	if (hintserror == 1)
		window.status = '';
}

function favorite(url,description) {
	if (window.external)
		window.external.addFavorite (url,description);
	else
		alert ("Met de toetsencombinatie 'CTRL + D' slaat u deze pagina op in uw favorieten.");
}

/* film */

function film() {
	var film_win = window.open ('/film/', 'film_win', 'width=220,height=220');
	film_win.focus ();
}

function show_popup() {
	var popupWin = window.open ('/nieuwsbrief_popup/index.html', 'popupwindow', 'width=400,height=250,status=no,menubar=no,resizable=yes,scrollbars=yes');
	if (popupWin) popupWin.focus ();
}

