// JavaScript Document
function Merk(){
	DWREngine._execute("/inc_ajax_functions.cfm", null, 'fGetCategory', document.motoren.MotorMerk.value, getMerkNumber);
	DWREngine._execute("/inc_ajax_functions.cfm", null, 'fGetType', document.motoren.MotorMerk.value, getMerkType);
}

function getMerkNumber(CategorieLijst){
	document.motoren.MotorCategorie.options.length = 0;
	insertOption(0,'Geen voorkeur')
	if(CategorieLijst==''){
		alert('Er is geen categorie gevonden op het door jouw gekozen merk.');
	}else{
		var CategorieArray = CategorieLijst.split(',');
		for(idx=0; idx<CategorieArray.length; idx++){
			CategorieRecord = CategorieArray[idx].split(';',2);
			insertOption(CategorieRecord[0],CategorieRecord[1]);
		}
	}
}

function getMerkType(TypeLijst){
	sbMotorType = document.motoren.MotorType;
	sbMotorType.options.length = 0;
	idx = 0;
	sbMotorType.options[idx] = new Option("Geen voorkeur", "");
	if (TypeLijst != ''){
		arrTypes = TypeLijst.split(',');
		selectedType = arrTypes[0];
		for(loopidx = 1; loopidx < arrTypes.length; loopidx++){
			idx++;
			sbMotorType.options[idx] = new Option(arrTypes[loopidx]);
			if (selectedType == arrTypes[loopidx]) {
				sbMotorType.options[idx].selected = true;
			}
		}
	}
}

function insertOption(UNIEKNR,NAAM){
	var y=document.createElement('option');
	y.text=NAAM;
	y.value=UNIEKNR;
	try{
		document.motoren.MotorCategorie.add(y,null); // standards compliant
	}
	catch(ex){
		document.motoren.MotorCategorie.add(y); // IE only
	}
}