
<!--

// Init
// =========================================================================



// Browser info
// =========================================================================
var bType = "other";					 // Standaard
var bVer = parseInt(navigator.appVersion);
if (navigator.appName == "Netscape") bType = "ns";
if (navigator.appName == "Microsoft Internet Explorer") bType = "ie";


// Datum ophalen
// =========================================================================
var today = new Date();
var sdag = today.getDate();
var smaand = today.getMonth() + 1;
var sjaar = today.getYear();
if ( sjaar <= 100 ) { sjaar += 1900; }                   	// Y2K problem!!!!

  //gegevens arrays

	
  // array voor categorie x (kilometer + zomertijd)
  // categorie = veteraan(wa casco) oldtimer(wa beperktcasco casco) youngtimer(idem) hobbytimer(idem) sporttimer(idem)
  // kilometer = 3000 5000 7500
  // zomerdekking jaardekking

  arrPremie = new Array(15)
  arrPremie[0] = new Array(29,39,42,56,55,74);
  arrPremie[1] = new Array(0,0,0,0,0,0);
  arrPremie[2] = new Array(0.008,0.011,0.011,0.015,0.015,0.02);
  arrPremie[3] = new Array(35,47,51,68,67,89);
  arrPremie[4] = new Array(0.006,0.009,0.008,0.01,0.009,0.012);
  arrPremie[5] = new Array(0.01,0.013,0.014,0.019,0.018,0.024);
  arrPremie[6] = new Array(41,55,60,80,79,105);
  arrPremie[7] = new Array(0.008,0.01,0.009,0.012,0.011,0.014);
  arrPremie[8] = new Array(0.011,0.015,0.017,0.022,0.021,0.028);
  arrPremie[9] = new Array(72,96,105,140,138,184);
  arrPremie[10] = new Array(0.011,0.014,0.013,0.017,0.015,0.02);
  arrPremie[11] = new Array(0.016,0.021,0.023,0.031,0.029,0.039);
  arrPremie[12] = new Array(103,138,150,200,197,263);
  arrPremie[13] = new Array(0.014,0.02,0.017,0.024,0.02,0.028);
  arrPremie[14] = new Array(0.021,0.03,0.025,0.035,0.031,0.045);

  //array kortingen bij eigenrisico als casco
  //ER kan zijn: 0 | 500 | 750 | 1.000 | 1.500 | 2.000 

  arrEigenrisico = new Array();
  arrEigenrisico[0] = new Array(0,0.2,0.25,0.3,0.35,0.4);    // 7.000 tm 50.000
  arrEigenrisico[1] = new Array(0,0.15,0.2,0.25,0.3,0.35);   // 50 tm 75
  arrEigenrisico[2] = new Array(0,0.05,0.1,0.15,0.2,0.25);   // 75 tm 150

  //array motorvermogen * (leeftijd(toeslag + extra ER))
  //voor hobby en sporttimers
  //leeftijd tm 29 (geen acceptatie boven 250 pk)
  // motorvermogen = [0] tm 150 pk | [1] 250 | [2] 300 | [3] >300 
  arrMotor = new Array();
  arrMotor[0] = new Array(0   ,370 ,0   ,170);
  arrMotor[1] = new Array(0.5 ,620 ,0   ,370);
  arrMotor[2] = new Array(0   ,0   ,0.5 ,620);
  arrMotor[3] = new Array(0   ,0   ,1   ,870);

  arrOngevallen = new Array();
  arrOngevallen[0] = new Array(7500 ,15000,2.25);
  arrOngevallen[1] = new Array(10000,20000,3.00);
  arrOngevallen[2] = new Array(12500,25000,3.75);
  arrOngevallen[3] = new Array(15000,30000,4.50);
  arrOngevallen[4] = new Array(17500,35000,5.25);
  arrOngevallen[5] = new Array(20000,40000,6.00);
  


function calcOngevallen(){ // 1, 2 of 3
	int_inzit = 0;
	if(document.premie.inzit.checked){
		with (document.premie){
			if(parseInt(inzittenden.value)){
				for(x=0 ; x<6 ; x++){
					if(inz[x].checked){
						int_inzit = arrOngevallen[x][2] * parseInt(inzittenden.value);
						return int_inzit;
					}
				}		
			}	
		}
	}
	else {
		return int_inzit;
	}
}

function RijArrPremie(){ // get array row number
	with (document.premie){
		for(x=0 ; x<5 ; x++){
			if(bj[x].checked){
				var rijnr = bj[x].value;
				return parseInt(rijnr);
			}
		}
	}
}

function ColArrPremie(){ // get array coll number
	with (document.premie){
		var iszomer = zomer[0].checked?1:0;
		for(y=0 ; y<3 ; y++){
			if(kmjaar[y].checked) {
				var indexKilometer = y*2;
				var colnr = indexKilometer + iszomer;
				return parseInt(colnr);
			}
		}
	}
}


function calcWA(){
	var rij = RijArrPremie();
	var col = ColArrPremie();
  	var WApremie = arrPremie[rij][col];
	WApremie = WApremie + WApremie * getMotorArray("wa");
	return WApremie;
}

function getMotorArray(caller){
	var rij = RijArrPremie();
	var retval = 0;
	with (document.premie){	
	if(rij > 8){
		isdertig = age[2].checked?2:0; //2 >=30 
		for(z=0 ; z<4 ; z++){
			if(pk[z].checked) {
				indexPK = z;
				break;
			}
		}
		if(isdertig != 2 && indexPK > 1){
			alert("Directe acceptatie is niet mogelijk.\nVraag uw verzekeringsadviseur voor advies.");
			pk[1].checked = true;
			indexPK = 1;
		}
		if (caller == "wa") {coll = 0}
		if (caller == "casco") {coll = 1}
		retval = arrMotor[indexPK][coll + isdertig];
	}
	return retval;
	}
}

function calcER(iscasco){ //basis ER voor casco en Bcasco;
	with (document.premie){
		if(casco.checked && age[0].checked){
			 return 200;
		}
		else {
			return 130;
		}
	}
}

function calcXtraER3(casco){ //
	with (document.premie){
		for(x=0 ; x<6 ; x++){
			if(er[x].checked){
				xtraER = er[x].value;
				return xtraER;
				break;
			}
		}
	}
}

function calcBCasco(){
	var rij = RijArrPremie()+ 1;
	var coll = ColArrPremie();
	with (document.premie){
		if (beperkt.checked){
			if(rij != 1){ // beperkt casco niet mogelijk voor veteraan
				if(taxwaarde.value !=""){
					BcascoPremie = parseInt(taxwaarde.value) * arrPremie[rij][coll];
					return BcascoPremie;
				}
				else{
					alert("Vul a.u.b. de taxatiewaarde van uw klassiek in.");
					taxwaarde.focus();
					return 0;
				}
			}
			else{
				alert("Voor een veteraan is het niet mogelijk een beperkt casco verzekering af te sluiten.");
				beperkt.checked = false;
				casco.focus();
				return 0;	
			}	
		}
		else {
			return 0;
		}
	}
}

function calcCasco(){
	var rij = RijArrPremie() + 2;
	var coll = ColArrPremie();
	var indexERtaxwaarde = 0;
	var correctieperc = 0; 
	with (document.premie){
		if (casco.checked){
			if(taxwaarde.value !=""){
				//if(calcXtraER("casco") == false){	
					if(parseInt(taxwaarde.value) < 50001){
						indexERtaxwaarde = 0;
					}
					else{
						if(parseInt(taxwaarde.value) < 75001){
							indexERtaxwaarde = 1;
						}
						else {
							if(parseInt(taxwaarde.value) > 150000){
								alert("Neem contact op met uw verzekeringsadviseur.")
							}
							else {
								indexERtaxwaarde = 2;
							}
						}
					}
					for(x=0 ; x<6 ; x++){
						if(er[x].checked){
							var indexER = x;
							break;
						}
					}
					correctieperc = arrEigenrisico[indexERtaxwaarde][indexER];
				//}
				//else {
					//if(er[1].checked || er[2].checked || er[3].checked || er[4].checked || er[5].checked){
						//alert("Extra vrijwillig eigen risico is niet mogelijk.");
						//er[0].checked = true;
						//er[0].focus();
					//}
				//}
			} 	
			else{
				alert("Vul a.u.b. de taxatiewaarde van uw klassiek in.");
				taxwaarde.focus();
				return 0;
			}

// berekening cascoPremie
	
			cascoPremie = arrPremie[rij][coll] * taxwaarde.value;
			correctie = cascoPremie * correctieperc;
			cascoPremie = cascoPremie - correctie;
			return cascoPremie;
		}
		else {
			return 0;
		}
	}
}

// uitschrijven gegevens naar polistext



var int_wa = 0;
var int_bcasco = 0;
var int_casco =0;
var int_er = 0;
var int_xtraer = 0;
var int_hulpnl = 0;
var int_hulpeuro = 0;
var int_verhaal = 0;
var int_rechtsb = 0;
var int_dekking1 = 0;
var int_dekking2 = 0;

function comDispatch(){
	//calls call functions and gets all values;
	fehacKorting = document.premie.fehac[0].checked?.8:1;
	int_wa = calcWA();
	int_bcasco = calcBCasco();
	int_casco = calcCasco();
	int_er = parseInt(calcER());
	int_xtraer = parseInt(calcXtraER3());
	int_xtraer2 = parseInt(getMotorArray('casco'));
	int_hulpeuro = document.premie.hulp[1].checked?15 : 0;
	int_verhaal = document.premie.verhaal.checked?15 : 0;
	int_rechtsb = document.premie.rbijstand.checked?20 : 0;
	int_svi = document.premie.svi.checked?42 : 0;
	int_inzittenden = calcOngevallen("1");
	//int_dekking1 = calcOngevallen("2");
	//int_dekking2 = calcOngevallen("3");
	int_tot1 = int_wa + int_bcasco + int_casco; // totaal netto premie
	int_tot2 = int_er + int_xtraer + int_xtraer2; // totaal eigen risico
	int_tot3 = int_tot1 + int_hulpeuro + int_verhaal + int_rechtsb + int_svi; // totaal met extra's excl inzittenden
	int_fehac = (1 - fehacKorting) * (int_tot3 + int_inzittenden);
	int_tot4 = int_tot3 * fehacKorting; // totaal met extra's excl inzittenden
	int_tax = int_tot4 * 0.075; //assurantiebelasting
	int_tot5 = int_tot4 + int_tax + (int_inzittenden * fehacKorting); //TOTAAAAAAL !
	writeDown();
	
}



function writeDown(){
	with (document.premie){
	arrOutput = new Array(21);
	arrOutput[0] = "Onderstaand treft u de uitkomst van de premieberekening aan.\n";
	arrOutput[1] = "U heeft gekozen voor een ";
	if(casco.checked){
		arrOutput[2] = "casco";
		arrOutput[11] = "Casco\t\t\t\t\t\t\t€" +  numToString(pad( formatcurrency(int_casco), 8)) +"\n";

	}
	if(beperkt.checked){
		arrOutput[2] = "beperkt casco";
		arrOutput[11] = "Beperkt casco\t\t\t\t\t\t€" +  numToString(pad( formatcurrency(int_bcasco), 8)) +"\n";
	}
	if(casco.checked == false && beperkt.checked == false){
		arrOutput[2] ="wa-";
	}
	arrOutput[3] = "verzekering. "
	if(casco.checked || beperkt.checked){
		arrOutput[4] = "Bij deze verzekering heeft u een eigen risico van €" + numToString(formatcurrency(int_tot2));
		if(casco.checked){	
			if (int_xtraer2 != 0){
				arrOutput[5] = " (Eigen risico € " + numToString(formatcurrency(int_er));
				arrOutput[6] = " + verplicht extra eigen risico van €" + numToString(formatcurrency(int_xtraer2));
				if (er[0].checked == false){
					arrOutput[7] = " + vrijwillig extra eigen risico van €" + numToString(formatcurrency(int_xtraer));
				}
				arrOutput[8] = ").";
			}
		}		
	}

	arrOutput[9] = "\n\nGekozen dekking\t\t\tverzekerd bedrag\tPremie\n";
	arrOutput[10] = "W.A. Premie\t\t\t€ 2.500.000,-\t\t€"+ numToString(pad( formatcurrency(int_wa), 8)) +"\n";


	if(hulp[0].checked){
		arrOutput[12] = "Hulpverlening Nederland\t\t\t\t\t€"+ numToString(pad( formatcurrency(int_hulpnl), 8)) +" \n";
	}
	else{
		arrOutput[12] = "Hulpverlening Europa\t\t\t\t\t€"+  numToString(pad( formatcurrency(int_hulpeuro), 8)) +" \n";
	}
	if(verhaal.checked){
		arrOutput[13] = "Verhaalservice-extra\t\t\t\t\t€"+  numToString(pad( formatcurrency(int_verhaal), 8)) +" \n";
	}
	if(rbijstand.checked){
		arrOutput[13] = "Rechtsbijstand\t\t\t\t\t\t€"+  numToString(pad( formatcurrency(int_rechtsb), 8)) +" \n";
	}
	if(svi.checked){
		arrOutput[13] = "Schadeverzekering inzittenden\t\t\t\t€"+  numToString(pad( formatcurrency(int_svi), 8)) +" \n";
	}
	
	arrOutput[14] = "-----------------------------------------------------------------\n";
	arrOutput[15] = "Totaal netto premie\t\t\t\t\t€" + numToString(pad( formatcurrency(int_tot3), 8)) + "\n";
	if(int_fehac > 0){
		arrOutput[16] = "Fehac korting\t\t\t\t\t\t€" + numToString(pad( formatcurrency(int_fehac), 8)) + "-\n";
	}
	arrOutput[17] = "Assurantie belasting\t\t\t\t\t€" + numToString(pad( formatcurrency(int_tax), 8)) + "\n";
	if(inzit.checked){
		arrOutput[18] = "Ongevallen inzittenden\t\t\t\t\t€" + numToString(pad( formatcurrency(int_inzittenden), 8)) + "\n";
	}
	arrOutput[19] = "-----------------------------------------------------------------\n";
	arrOutput[20] = "Te betalen per jaar\t\t\t\t\t€" + numToString(pad( formatcurrency(int_tot5), 8)) + "\n";
	arrOutput[21] = "\nHet eerste jaar bedragen de poliskosten € 8,50 exclusief 7,5% assurantiebelasting.";
		var isoutput = "";
	for(x=0 ; x < arrOutput.length ; x++){
		if(arrOutput[x]){
			isoutput = isoutput + arrOutput[x];
			document.premie.polistext.value = isoutput;
			document.premie.vSum.value = formatcurrency(int_tot4);
		}
	}
}
}

//number format
function numToString(value) {
	
	var fCurrency = formatcurrency(value);
	if(value < 10)
		var fCurrencyStr = "    "+String(fCurrency);
	else if(value < 100)
		var fCurrencyStr = "   "+String(fCurrency);
	else if(value < 1000)
		var fCurrencyStr = "  "+String(fCurrency);
	else if(value < 10000)
		var fCurrencyStr = " "+String(fCurrency);
	else
		var fCurrencyStr = String(fCurrency);
	returnVal = fCurrencyStr.replace(/\./, ",");
	return returnVal;
}

function change(){
	//general change
	comDispatch()
}

function changeTax(){
	//general change
	if(parseInt(document.premie.taxwaarde.value) >= 50000){
		alert("Voor klassiekers met een waarde boven de € 50.000,- gelden afwijkende premies.\nNeem hiervoor contact op met onze afdeling ATP-Premie, tel:\n020-6515555");
		document.premie.taxwaarde.value = "49999";
	}
	else{
		comDispatch()
	}
}

function changeOther(chgfield){
	if(eval('document.premie.' +chgfield+ '.checked') == true){
		eval('document.premie.' +chgfield+ '.checked = false')
	}
}

function valInzittenden(){
	if(parseInt(document.premie.inzittenden.value) > 0){
		document.premie.inzit.checked = true;
	}
}


// Diversen ===========================================================================


function help( pVeld) {
  // Generic help funtie

  helpwindow = window.open( pVeld + ".htm", "winhelp", "width=350,height=300,status,scrollbars");
	//helpwindow.document.dform.ok.focus();
  return;
}