function CheckDate(oSrc, args){

	if (Form1.MonthList.selectedIndex == 0 || Form1.YearList.selectedIndex == 0 )
		args.IsValid = false;
	else
		args.IsValid = true;
}

function CheckMerk(oSrc, args){

	if (Form1.MerkList.selectedIndex == 0 )
		args.IsValid = false;
	else
		args.IsValid = true;
}

// Auto default page functions

function CheckModel(oSrc, args){

	if (Form1.ModelList.selectedIndex == 0 )
		args.IsValid = false;
	else
		args.IsValid = true;
}

function OnYearMonthMerkChange(){
	f = document.Form1;
	
	if (f.MerkList.selectedIndex > 0){
		if (f.OldMerkID.value != ""){
			if (f.OldMerkID.value != f.MerkList.options[f.MerkList.selectedIndex].value){
				var merkUrl = f.MerkList.options[f.MerkList.selectedIndex].text;
				merkUrl = merkUrl.replace(" ", "-") + "-autoverzekering";
				merkUrl = merkUrl.toLowerCase();
				window.top.location= "http://safa/fx/autoverzekering/" + merkUrl;
			}
		}
	}

	if (f.MonthList.selectedIndex > 0 && f.YearList.selectedIndex > 0){
		if (f.MerkList.selectedIndex > 0){
			f.txtKenteken1.value = "";
			f.txtKenteken2.value = "";
			f.txtKenteken3.value = "";
			f.IsModel.value = true;
			f.submit();
		}
		else{
			//RemoveAllModelsAndSubmit();
			f.ModelList.disabled = false;
			
		}
	}
	else{
		f.ModelList.disabled = true;
		f.IsModel.value = false;
	}
}

function OnKentekenChange(){

	f = document.Form1;
	f1 = f.txtKenteken1.value;
	f2 = f.txtKenteken2.value;
	f3 = f.txtKenteken3.value;
	if (f1 !=""  && f1.length == 2 &&  f2 !=""  && f2.length == 2 && f3 !=""  && f3.length == 2){
		var qryStr = "";
		if (f.p1.value != "")
			qryStr = "&P="+f.p1.value
			
		if (f.isFrm1.value != "")
			qryStr += "&isFrm="+f.isFrm1.value
			
		if (f.PartnerID1.value != "")
			qryStr += "&PartnerID="+f.PartnerID1.value
			
		if (f.IsP1.value != "")
			qryStr += "&IsP="+f.IsP1.value	
		
		var nUrl = f.nUrl1.value;	

		if (nUrl != ""){
			nUrl = nUrl + "autotool.asp";
			if (f.nTarget.value == "0")
				window.top.location = nUrl + '?Kenteken='+f1+"-"+f2+"-"+f3+ qryStr;
			else
				window.open(nUrl + '?Kenteken='+f1+"-"+f2+"-"+f3+ qryStr);
		}
		else
			window.location = 'AutoTypesDetailByKenteken.aspx?Kenteken='+f1+"-"+f2+"-"+f3+ qryStr;
		//f.submit();
	}
}


function RemoveAllModelsAndSubmit(){

	f = document.Form1.ModelList;
	for(x = 0; x < f.length; x++){
		f.options[x] = null;
	}
	document.Form1.submit();
	
}
