	
	function fillyear(list)
	{
		var today = new Date();
		var yearSelect = document.getElementById(list);
		if(yearSelect)
		{
			var thisYear = today.getFullYear();
			
			for(var i = thisYear; i <= thisYear + 4; i++)
			{
			    yearSelect.options[yearSelect.options.length] =  new Option(i, i);
			}
		}
	}
	

	function fillbirthyear(list, years)
	{
		var today = new Date();
		var yearSelect = document.getElementById(list);

		if(yearSelect)
		{

			var thisYear = today.getFullYear();
			
			for(var i = thisYear; i >= thisYear - years; i--)
			{
			    yearSelect.options[yearSelect.options.length] =  new Option(i, i);
			}
		}
	}


	function validform()
	{
	 var oCurrentForm = document.getElementById('komiabedrijven');
	 oForm.scrobble(oCurrentForm);
	    
	   oForm.validate(oCurrentForm, false);
	    alert('gevalideerd');
	}
	
	function nextstep(formID)
	{
	    var oCurrentForm = document.getElementById(formID);
	    
		if( typeof oForm == "undefined" )
		{
			oForm = new FormScrobbler();
			oForm.initialize();
		}
	    oForm.scrobble(oCurrentForm);
	    
	    oForm.validate(oCurrentForm, false)
	    
	    if (document.getElementById('error').style.display == "block")
	    {
	    //alert(document.getElementById('error').innerHTML);
	    //alert(document.getElementById('error').style.display);
	        return;
	    }
	   
	    
	
	var step1_2 = document.getElementById("aanmelden1_2");
	var step2_2 = document.getElementById("aanmelden2_2");
	
	if (step1_2.style.display != "none")
	{
	step2_2.style.display = "inline";
	step2_2.focus();
	step1_2.style.display = "none";
	
	}
	else
	{
		step1_2.style.display = "inline";
	step2_2.style.display = "none";

	}
	}


	function back(formID)
	{
	    var oCurrentForm = document.getElementById(formID);
	    
	    oForm.scrobble(oCurrentForm);
	    
	    oForm.validate(oCurrentForm, false)
	    
	    if (document.getElementById('error').style.display == "block")
	    {
	    //alert(document.getElementById('error').innerHTML);
	    //alert(document.getElementById('error').style.display);
	    //    return;
	    }
	   
	    
	
	var step1_2 = document.getElementById("aanmelden1_2");
	var step2_2 = document.getElementById("aanmelden2_2");
	
	if (step1_2.style.display != "none")
	{
		history.go(-1)	
	}
	else
	{

				step1_2.style.display = "inline";
	step2_2.style.display = "none";

	}
	}


	
	function showblock(chkbox, group) 
	{
    var visSetting = (chkbox.checked) ? "inline" : "none";
    var oElement = document.getElementById(group);

    //als bloch zichtbaar wordt de bijbehorende verplichte velden als
	//verplicht maken: class=required
	//als niet 'anders' is geselecteerd evt. verplichte velden opheffen: class=orequired
	
	var oAreas = new Array(3);
	oAreas[0] = "TEXTAREA";
	oAreas[1] = "INPUT";
	oAreas[2] = "SELECT";
	
	for (var a = 0; a < oAreas.length; a++)
	{
	var oTextarea = oElement.getElementsByTagName(oAreas[a]);
	for(var i = 0; i < oTextarea.length; i++)
	{
	 if ( chkbox.checked)
	 {
	//alert('area' + oTextarea[i].className);
        if (oTextarea[i].className.match( /dependentrequired/i ))
        {
	            oTextarea[i].className = 'required';
	    }
	 }
	 else
	 {
	    if (oTextarea[i].className.match( /\brequired/i ))
	    {
	    	    oTextarea[i].className = 'dependentrequired';
	    }
	 }
	 
	 //waarden verwijderen
	 if (a <2)
	 {
	    oTextarea[i].value = '';
	 }

	}
	}
	

		oElement.style.display = visSetting ;
		
   	}
	
	function specifyselection(cbbox, group)
	{
	var visSetting = (cbbox.value == "anders") ? "inline": "none";
	var oElement = document.getElementById(group);
	oElement.style.display = visSetting ;
		
    //als 'anders' is geselecteerd de bijbehorende verplichte velden als
	//verplicht maken: class=required
	//als niet 'anders' is geselecteerd evt. verplichte velden opheffen: class=orequired
	
	var oAreas = new Array(3);
	oAreas[0] = "TEXTAREA";
	oAreas[1] = "INPUT";
	oAreas[2] = "SELECT";
	
	if (oElement)
	{
	
	for (var a = 0; a < oAreas.length; a++)
	{
	var oTextarea = oElement.getElementsByTagName(oAreas[a]);
	for(var i = 0; i < oTextarea.length; i++)
	{
	 if ( cbbox.value == "anders")
     {
	    if (oTextarea[i].className.match( /orequire/i ))
	        {
		    oTextarea[i].className = 'required';
		    }
		}
		else
		{
		 if (oTextarea[i].className.match( /\brequired/i ))
	        {
		    oTextarea[i].className = 'orequire';
		    }
		}

		 	 	 //waarden verwijderen
	 if (a <2)
	 {
	    oTextarea[i].value = '';
	 }

	 }
	
	}
	
	}
	
	}
	
	function textshowblock(input, group)
	{
	    var visSetting = (!input.value == "") ? "inline": "none";
	    var oElement = document.getElementById(group);
	  
	var oAreas = new Array(3);
	oAreas[0] = "TEXTAREA";
	oAreas[1] = "INPUT";
	oAreas[2] = "SELECT";
	
	for (var a = 0; a < oAreas.length; a++)
	{
	var oTextarea = oElement.getElementsByTagName(oAreas[a]);
	for(var i = 0; i < oTextarea.length; i++)
	{
	 if (!input.value == "")
	 {
	//alert('area' + oTextarea[i].className);
        if (oTextarea[i].className.match( /dependentrequired/i ))
        {
	            oTextarea[i].className = 'required';
	    }
	 }
	 else
	 {
	    if (oTextarea[i].className.match( /\brequired/i ))
	    {
	    	    oTextarea[i].className = 'dependentrequired';
	    }
	 }
	 
	 //waarden verwijderen
	 if (a <2)
	 {
	    oTextarea[i].value = '';
	 }
	 
	}
	}
	

		oElement.style.display = visSetting ;
	}


	function fillcountries(elementID)
	{
		
		var countrySelect = document.getElementById(elementID);
		if(countrySelect)
		{
		
        countrySelect.options[0] =  new Option('Afghanistan','AF');
        countrySelect.options[1] =  new Option('Albanië','AL');
        countrySelect.options[2] =  new Option('Algerije','DZ');
        countrySelect.options[3] =  new Option('Andorra','AD');
        countrySelect.options[4] =  new Option('Angola','AO');
        countrySelect.options[5] =  new Option('Antigua en Barbuda','AG');
        countrySelect.options[6] =  new Option('Argentinië','AR');
        countrySelect.options[7] =  new Option('Armenië','AM');
        countrySelect.options[8] =  new Option('Australië','AU');
        countrySelect.options[9] =  new Option('Azerbeidzjan','AZ');
        countrySelect.options[10] =  new Option('Bahamas','BS');
        countrySelect.options[11] =  new Option('Bahrein','BH');
        countrySelect.options[12] =  new Option('Bangladesh','BD');
        countrySelect.options[13] =  new Option('Barbados','BB');
        countrySelect.options[14] =  new Option('België','BE');
        countrySelect.options[15] =  new Option('Belize','BZ');
        countrySelect.options[16] =  new Option('Benin','BJ');
        countrySelect.options[17] =  new Option('Bermuda','BM');
        countrySelect.options[18] =  new Option('Bhutan','BT');
        countrySelect.options[19] =  new Option('Bolivia','BO');
        countrySelect.options[20] =  new Option('Bosnië-Herzegovina','BA');
        countrySelect.options[21] =  new Option('Botswana','BW');
        countrySelect.options[22] =  new Option('Brazilië','BR');
        countrySelect.options[23] =  new Option('Britse Maagdeneilanden','VG');
        countrySelect.options[24] =  new Option('Brunei','BN');
        countrySelect.options[25] =  new Option('Bulgarije','BG');
        countrySelect.options[26] =  new Option('Burkina Faso','BF');
        countrySelect.options[27] =  new Option('Burundi','BI');
        countrySelect.options[28] =  new Option('Cambodja','KH');
        countrySelect.options[29] =  new Option('Canada','CA');
        countrySelect.options[30] =  new Option('Centraal-Afrikaanse Republiek','CF');
        countrySelect.options[31] =  new Option('Chili','CL');
        countrySelect.options[32] =  new Option('China','CN');
        countrySelect.options[33] =  new Option('Christmas Island','CX');
        countrySelect.options[34] =  new Option('Colombia','CO');
        countrySelect.options[35] =  new Option('Comoren','KM');
        countrySelect.options[36] =  new Option('Costa Rica','CR');
        countrySelect.options[37] =  new Option('Cuba','CU');
        countrySelect.options[38] =  new Option('Cyprus','CY');
        countrySelect.options[39] =  new Option('Democratische Republiek Congo','ZR');
        countrySelect.options[40] =  new Option('Denemarken','DK');
        countrySelect.options[41] =  new Option('Djibouti','DJ');
        countrySelect.options[42] =  new Option('Dominica','DM');
        countrySelect.options[43] =  new Option('Dominicaanse Republiek','DO');
        countrySelect.options[44] =  new Option('Duitsland','DE');
        countrySelect.options[45] =  new Option('Ecuador','EC');
        countrySelect.options[46] =  new Option('Egypte','EG');
        countrySelect.options[47] =  new Option('El Salvador','SV');
        countrySelect.options[48] =  new Option('Eritrea','ER');
        countrySelect.options[49] =  new Option('Estland','EE');
        countrySelect.options[50] =  new Option('Ethiopië','ET');
        countrySelect.options[51] =  new Option('Falkland Eilanden','FK');
        countrySelect.options[52] =  new Option('Faroer Eilanden','FO');
        countrySelect.options[53] =  new Option('Fiji','FJ');
        countrySelect.options[54] =  new Option('Filipijnen','PH');
        countrySelect.options[55] =  new Option('Finland','FI');
        countrySelect.options[56] =  new Option('Frankrijk','FR');
        countrySelect.options[57] =  new Option('Frans Polynesië','PF');
        countrySelect.options[58] =  new Option('Franse Zuidelijke en Antarctische gebieden','TF');
        countrySelect.options[59] =  new Option('Frans-Guyana','GF');
        countrySelect.options[60] =  new Option('Gabon','GA');
        countrySelect.options[61] =  new Option('Gambia','GM');
        countrySelect.options[62] =  new Option('Georgië','GE');
        countrySelect.options[63] =  new Option('Ghana','GH');
        countrySelect.options[64] =  new Option('Gibraltar','GI');
        countrySelect.options[65] =  new Option('Grenada','GD');
        countrySelect.options[66] =  new Option('Griekenland','GR');
        countrySelect.options[67] =  new Option('Groenland','GL');
        countrySelect.options[68] =  new Option('Guadeloupe','GP');
        countrySelect.options[69] =  new Option('Guatemala','GT');
        countrySelect.options[70] =  new Option('Guinee','GN');
        countrySelect.options[71] =  new Option('Guinee-Bissau','GW');
        countrySelect.options[72] =  new Option('Guyana','GY');
        countrySelect.options[73] =  new Option('Haiti','HT');
        countrySelect.options[74] =  new Option('Honduras','HN');
        countrySelect.options[75] =  new Option('Hongarije','HU');
        countrySelect.options[76] =  new Option('Ierland','IE');
        countrySelect.options[77] =  new Option('IJsland','IS');
        countrySelect.options[78] =  new Option('India','IN');
        countrySelect.options[79] =  new Option('Indonesië','ID');
        countrySelect.options[80] =  new Option('Irak','IQ');
        countrySelect.options[81] =  new Option('Iran','IR');
        countrySelect.options[82] =  new Option('Israël','IL');
        countrySelect.options[83] =  new Option('Italië','IT');
        countrySelect.options[84] =  new Option('Ivoorkust','CI');
        countrySelect.options[85] =  new Option('Jamaica','JM');
        countrySelect.options[86] =  new Option('Japan','JP');
        countrySelect.options[87] =  new Option('Jemen','YE');
        countrySelect.options[88] =  new Option('Jordanië','JO');
        countrySelect.options[89] =  new Option('Kaaiman eilanden','KY');
        countrySelect.options[90] =  new Option('Kaap Verdische eilanden','CV');
        countrySelect.options[91] =  new Option('Kameroen','CM');
        countrySelect.options[92] =  new Option('Kazachstan','KZ');
        countrySelect.options[93] =  new Option('Kenia','KE');
        countrySelect.options[94] =  new Option('Kirgizië','KG');
        countrySelect.options[95] =  new Option('Kiribati','KI');
        countrySelect.options[96] =  new Option('Koeweit','KW');
        countrySelect.options[97] =  new Option('Kroatië','HR');
        countrySelect.options[98] =  new Option('Laos','LA');
        countrySelect.options[99] =  new Option('Letland','LV');
        countrySelect.options[100] =  new Option('Libanon','LB');
        countrySelect.options[101] =  new Option('Liberia','LR');
        countrySelect.options[102] =  new Option('Libië','LY');
        countrySelect.options[103] =  new Option('Liechtenstein','LI');
        countrySelect.options[104] =  new Option('Litouwen','LT');
        countrySelect.options[105] =  new Option('Luxemburg','LU');
        countrySelect.options[106] =  new Option('Madagaskar','MG');
        countrySelect.options[107] =  new Option('Malawi','MW');
        countrySelect.options[108] =  new Option('Maldiven','MV');
        countrySelect.options[109] =  new Option('Maleisië','MY');
        countrySelect.options[110] =  new Option('Mali','ML');
        countrySelect.options[111] =  new Option('Malta','MT');
        countrySelect.options[112] =  new Option('Marokko','MN');
        countrySelect.options[113] =  new Option('Marshall Eilanden','MH');
        countrySelect.options[114] =  new Option('Martinique','MQ');
        countrySelect.options[115] =  new Option('Mauritius','MU');
        countrySelect.options[116] =  new Option('Mexico','MX');
        countrySelect.options[117] =  new Option('Micronesië','FM');
        countrySelect.options[118] =  new Option('Moldavië','MD');
        countrySelect.options[119] =  new Option('Monaco','MC');
        countrySelect.options[120] =  new Option('Myanmar','MM');
        countrySelect.options[121] =  new Option('Namibië','NA');
        countrySelect.options[122] =  new Option('Nauru','NR');
        countrySelect.options[123] =  new Option('Nederland','NL');
        countrySelect.options[124] =  new Option('Nederlandse Antillen','AN');
        countrySelect.options[125] =  new Option('Nepal','NP');
        countrySelect.options[126] =  new Option('Nicaragua','NI');
        countrySelect.options[127] =  new Option('Nieuw-Zeeland','NZ');
        countrySelect.options[128] =  new Option('Nigeria','NE');
        countrySelect.options[129] =  new Option('Noord-Korea','KP');
        countrySelect.options[130] =  new Option('Noorwegen','NO');
        countrySelect.options[131] =  new Option('Oeganda','UG');
        countrySelect.options[132] =  new Option('Oekraïne','UA');
        countrySelect.options[133] =  new Option('Oezbekistan','UZ');
        countrySelect.options[134] =  new Option('Oman','OM');
        countrySelect.options[135] =  new Option('Oostenrijk','AT');
        countrySelect.options[136] =  new Option('Pakistan','PK');
        countrySelect.options[137] =  new Option('Panama','PA');
        countrySelect.options[138] =  new Option('Papoea Nieuw Guinea','PG');
        countrySelect.options[139] =  new Option('Paraguay','PY');
        countrySelect.options[140] =  new Option('Peru','PE');
        countrySelect.options[141] =  new Option('Polen','PL');
        countrySelect.options[142] =  new Option('Portugal','PT');
        countrySelect.options[143] =  new Option('Qatar','QA');
        countrySelect.options[144] =  new Option('Republiek Congo','CG');
        countrySelect.options[145] =  new Option('Reunion','RE');
        countrySelect.options[146] =  new Option('Russische Federatie','RU');
        countrySelect.options[147] =  new Option('Rwanda','RW');
        countrySelect.options[148] =  new Option('Saint Lucia','LC');
        countrySelect.options[149] =  new Option('Saint Vincent en de Grenadines','VC');
        countrySelect.options[150] =  new Option('Samoa','WS');
        countrySelect.options[151] =  new Option('San Marino','SM');
        countrySelect.options[152] =  new Option('Saoedi-Arabië','SA');
        countrySelect.options[153] =  new Option('Senegal','SN');
        countrySelect.options[154] =  new Option('Servië en Montenegro','YU');
        countrySelect.options[155] =  new Option('Seychellen','SC');
        countrySelect.options[156] =  new Option('Sierra Leone','SL');
        countrySelect.options[157] =  new Option('Singapore','SG');
        countrySelect.options[158] =  new Option('Slowakije','SK');
        countrySelect.options[159] =  new Option('Soedan','SD');
        countrySelect.options[160] =  new Option('Solomon Eilanden','SB');
        countrySelect.options[161] =  new Option('Spanje','ES');
        countrySelect.options[162] =  new Option('Sri Lanka','LK');
        countrySelect.options[163] =  new Option('Suriname','SR');
        countrySelect.options[164] =  new Option('Swaziland','SZ');
        countrySelect.options[165] =  new Option('Syrië','SY');
        countrySelect.options[166] =  new Option('Tadzjikistan','TJ');
        countrySelect.options[167] =  new Option('Tanzania','TZ');
        countrySelect.options[168] =  new Option('Thailand','TH');
        countrySelect.options[169] =  new Option('Togo','TG');
        countrySelect.options[170] =  new Option('Tonga','TO');
        countrySelect.options[171] =  new Option('Trinidad en Tobago','TT');
        countrySelect.options[172] =  new Option('Tsjaad','TD');
        countrySelect.options[173] =  new Option('Tsjechië','CZ');
        countrySelect.options[174] =  new Option('Tunesië','TN');
        countrySelect.options[175] =  new Option('Turkije','TR');
        countrySelect.options[176] =  new Option('Turkmenistan','TM');
        countrySelect.options[177] =  new Option('Tuvalu','TV');
        countrySelect.options[178] =  new Option('United States Minor Outlying Eilanden','UM');
        countrySelect.options[179] =  new Option('Uruguay','UY');
        countrySelect.options[180] =  new Option('Vaticaanstad','VA');
        countrySelect.options[181] =  new Option('Venezuela','VE');
        countrySelect.options[182] =  new Option('Verenigd Koninkrijk','GB');
        countrySelect.options[183] =  new Option('Verenigde Arabische Emiraten','AE');
        countrySelect.options[184] =  new Option('Verenigde Staten','US');
        countrySelect.options[185] =  new Option('Vietnam','VN');
        countrySelect.options[186] =  new Option('Wit-Rusland','BY');
        countrySelect.options[187] =  new Option('Zambia','ZM');
        countrySelect.options[188] =  new Option('Zimbabwe','ZW');
        countrySelect.options[189] =  new Option('Zuid-Afrika','ZA');
        countrySelect.options[190] =  new Option('Zuid-Korea','KR');
        countrySelect.options[191] =  new Option('Zweden','SE');
        countrySelect.options[192] =  new Option('Zwitserland','CH');
		countrySelect.options[123].selected = true
		}
              
			
	}


	function fillcountriesshort(elementID) {

	    var countrySelect = document.getElementById(elementID);
	    if (countrySelect) {


	        countrySelect.options[0] = new Option('België', 'BE');
	        countrySelect.options[1] = new Option('Duitsland', 'DE');
	        countrySelect.options[2] = new Option('Nederland', 'NL');

	        countrySelect.options[2].selected = true
	    }


	}

	
	function ShowHideBlocks(object)
	{
		switch(object.value)
		{
			case "adreswijziging":
				ShowHideBlock("wijzigadres,persoonlijkegegevens,submitformbutton;overig,wijzigrekeningnr,stopzettendonatie,wijzigbedrag");
				break;
			case "wijziging rekeningnummer":
				ShowHideBlock("wijzigrekeningnr,persoonlijkegegevens,submitformbutton;wijzigadres,overig,stopzettendonatie,wijzigbedrag");
				break;
			case "wijziging bedrag":
				ShowHideBlock("wijzigbedrag,persoonlijkegegevens,submitformbutton;wijzigadres,overig,wijzigrekeningnr,stopzettendonatie");
				break;
			case "stopzetting donatie":
				ShowHideBlock("stopzettendonatie,persoonlijkegegevens,submitformbutton;wijzigadres,overig,wijzigrekeningnr,wijzigbedrag");
				break;
			case "algemene vraag":
				ShowHideBlock("overig,submitformbutton;wijzigadres,persoonlijkegegevens,wijzigrekeningnr,stopzettendonatie,wijzigbedrag");
				break;
			default:
				ShowHideBlock(";wijzigadres,persoonlijkegegevens,overig,wijzigrekeningnr,stopzettendonatie,wijzigbedrag,submitformbutton");
				break;
		}
	}
	
	/*contact formulier*/
	
		function ShowHideBlock(task)
	{

 	var oAreas = new Array("TEXTAREA","INPUT","SELECT");

    var blocks = task.split(";");
    var showBlocks = blocks[0];
    var hideBlocks = blocks[1];

//alert(showBlocks)
//alert(hideBlocks)
if (showBlocks.length >0)
{
	var showBlocksResult = showBlocks.split(",");
        for(i = 0; i < showBlocksResult.length; i++)
        {
        //alert('show: ' + showBlocksResult[i]);
	    //document.getElementById(showBlocksResult[i]).style.display = "block" ;
	    
	   	    //start
	    	var oElement = document.getElementById(showBlocksResult[i]);

 	//var oAreas = new Array("TEXTAREA","INPUT","SELECT")
	
	if (oElement)
	{
	
	 for (var a = 0; a < oAreas.length; a++)
	 {
	  var oTextarea = oElement.getElementsByTagName(oAreas[a]);
	  for(var z = 0; z < oTextarea.length; z++)
	  {
	  
	    	if (oTextarea[z].className.match( /\bdependentrequired/i ))
	    	{
	        oTextarea[z].className = 'required';
		    }
	  
	  //waarden verwijderen
	  //oTextarea.value = '';
	  }
	
	 }
	
	oElement.style.display = "block";
	}
	}
	    //end
	    
	    
        
}	

if (hideBlocks.length >0)
{
	var hideBlocksResult = hideBlocks.split(",");
        for(i = 0; i < hideBlocksResult.length; i++)
        {
        //alert('hide: ' + hideBlocksResult[i]);
	    //document.getElementById(hideBlocksResult[i]).style.display = "none" ;
	    //start
	    	var oElement = document.getElementById(hideBlocksResult[i]);

	if (oElement)
	{
	
		
	 for (var a = 0; a < oAreas.length; a++)
	 {
	  var oTextarea = oElement.getElementsByTagName(oAreas[a]);
	  if (oTextarea)
	  {
	  //alert(oTextarea.length);
	  
	  for(var z = 0; z < oTextarea.length; z++)
	  {
	  
	    	if (oTextarea[z].className.match( /\brequired/i ))
	    	{
	        oTextarea[z].className = 'dependentrequired';
		    }
	  
	  //waarden verwijderen
	  oTextarea[z].value = '';
	  }
	  
	  }
	
	 }
	 
	oElement.style.display = "none";
	}
	
	
	
	}
	    
}
        
    /*end function*/
	}
	
	function submitForm(sParamsName1, sParamsName2)
{ 
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
  
    xhr.open("post", "/invitationcheck.ashx", false);
    var sParams = document.getElementById(sParamsName1).name + "=" + document.getElementById(sParamsName1).value ;
    sParams += '&' + document.getElementById(sParamsName2).name + "=" + document.getElementById(sParamsName2).value;
    sParams += '&id=' + gup("id");
    //prompt('',sParams);
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xhr.send(sParams);
    
    if(xhr.status  == 200) 
    {
        //alert("Status is " + xhr.status + " (" + xhr.statusText + ")");
        //alert("Response text is: " + xhr.responseText);
        checkuitnodiging(xhr.responseText);
    }
    else
    {
        //alert("Error code " + xhr.status);
    }
      
} 

	
	function checkuitnodiging(result)
	{
	    if (result == "[OK]")
	    {
  	    document.getElementById("errorcode").style.display = "none";
	    document.getElementById("evenementenuitnodiging").style.display = "none";
	    document.getElementById("evenementen").style.display = "block";
	    document.getElementById("invitationcode").value = document.getElementById("inschrijfcode").value;
	    }
	    else if (result == "[Error]" | result == "[Null]")
	    {
	    document.getElementById("evenementenuitnodiging").style.display = "inline";
	    document.getElementById("evenementen").style.display = "none";
	    document.getElementById("errorcode").style.display = "block";
	    document.getElementById("errorcode").className = "error";
		document.getElementById("errorcode").innerHTML = "De code is niet bekend. Probeer het nogmaals of neem <a href='/page/home/over_ons/contact'>contact</a> op met CliniClowns" ;
	    }
	    else
	    {
	    document.getElementById("errorcode").style.display = "none";
	    document.getElementById("evenementenuitnodiging").style.display = "none";
	    document.getElementById("evenementen").style.display = "block";
	    document.getElementById("fromto").innerHTML = result;
	    }
    }


function eventsFromTo(event)
{
document.getElementById("EvenementStart").value = gup("from");
document.getElementById("EvenementEind").value = gup("to");
var datum = gup("from");
datum = datum.split(" ")[0];
var tijd = gup("from");
tijd = tijd.split(" ")[1];
tijd = tijd.split(":")[0] + ":" + tijd.split(":")[1];
document.getElementById("eventdatum").value = datum;
document.getElementById("eventtijd").value = tijd;

//alert(datum);
//alert(tijd);

if (datum == '2-6-2010' && tijd == '13:30')
{
document.getElementById("fromto").innerHTML = "<strong>Regio Amsterdam, woensdag 2 juni om 13.30 uur.</strong>";
}
else if (datum == '2-6-2010' && tijd == '16:00') {
    document.getElementById("fromto").innerHTML = "<strong>Regio Amsterdam, woensdag 2 juni om 16.00 uur.</strong>";
}
else if (datum == '16-6-2010' && tijd == '13:30') {
    document.getElementById("fromto").innerHTML = "<strong>Regio Rotterdam, woensdag 16 juni om 13.30 uur.</strong>";
}
else if (datum == '16-6-2010' && tijd == '16:00') {
    document.getElementById("fromto").innerHTML = "<strong>Regio Rotterdam, woensdag 16 juni om 16.00 uur.</strong>";
}
else if (datum == '7-7-2010' && tijd == '13:30') {
    document.getElementById("fromto").innerHTML = "<strong>Regio Weert, woensdag 7 juli om 13.30 uur.</strong>";
}
else if (datum == '7-7-2010' && tijd == '16:00') {
    document.getElementById("fromto").innerHTML = "<strong>Regio Weert, woensdag 7 juli om 16.00 uur.</strong>";
}
else if (datum == '25-8-2010' && tijd == '13:30') {
    document.getElementById("fromto").innerHTML = "<strong>Regio Utrecht, woensdag 25 augustus om 13.30 uur.</strong>";
}
else if (datum == '25-8-2010' && tijd == '16:00') {
    document.getElementById("fromto").innerHTML = "<strong>Regio Utrecht, woensdag 25 augustus om 16.00 uur.</strong>";
}
else if (datum == '15-9-2010' && tijd == '13:30') {
    document.getElementById("fromto").innerHTML = "<strong>Regio Deventer, woensdag 15 september om 13.30 uur.</strong>";
}
else if (datum == '15-9-2010' && tijd == '16:00') {
    document.getElementById("fromto").innerHTML = "<strong>Regio Deventer, woensdag 15 september om 16.00 uur.</strong>";
}
else if (datum == '29-9-2010' && tijd == '13:30') {
    document.getElementById("fromto").innerHTML = "<strong>Regio Drachten, woensdag 29 september om 13.30 uur.</strong>";
}
else if (datum == '29-9-2010' && tijd == '16:00') {
    document.getElementById("fromto").innerHTML = "<strong>Regio Drachten, woensdag 29 september om 16.00 uur.</strong>";
}
else
{
document.getElementById("fromto").innerHTML = "<strong>" + datum + " om " + tijd + " uur</strong>";
}
}

function backblocks(currentblock, previousblock)
{
    document.getElementById(currentblock).style.display = "none";
    document.getElementById(previousblock).style.display = "block";
}

function backblocksclear(currentblock, previousblock) {

    var oElement = document.getElementById(currentblock);

    var oAreas = new Array(3);
    oAreas[0] = "TEXTAREA";
    oAreas[1] = "INPUT";
    oAreas[2] = "SELECT";
    oAreas[3] = "DIV";

    for (var a = 0; a < oAreas.length; a++) {
        var oTextarea = oElement.getElementsByTagName(oAreas[a]);
        for (var i = 0; i < oTextarea.length; i++) {
            //alert(oTextarea.name);
            if (oTextarea[i].className.match(/\brequired/i)) {
                oTextarea[i].className = 'dependentrequired';
            }

//            if (oTextarea[i].className.match(/\bhideblock/i)) {
//                oTextarea[i].style.display = "none";
//            }

            //waarden verwijderen
            if (a < 3) {
                if (oTextarea[i].type != 'button')
                    //oTextarea[i].value = '';
                if (oTextarea[i].type == 'checkbox') {
                   // oTextarea[i].checked = false;
                }
            }

        }
    }

    document.getElementById(currentblock).style.display = "none";
    document.getElementById(previousblock).style.display = "block";

}

function copyblocks(cbbox, target, diff)
{

    var blocknumbers = cbbox.value;

    var targetElement  = document.getElementById(target)

    //remove "whitespace-childnodes"
	for (j=0; j < targetElement.childNodes.length; j++)
        {
          
            if (targetElement.childNodes[j].nodeType != 1)
                targetElement.removeChild(targetElement.childNodes[j]);
            else
                break;
             
        }


    while (targetElement.firstChild.id != targetElement.lastChild.id)
    {
        var childnode=targetElement.lastChild;
        targetElement.removeChild(childnode)
    }


    for (var i = 1 - diff; i <= blocknumbers; i++) 
    {
        var oldblock =document.getElementById(target).firstChild
        var newblock = oldblock.cloneNode(true);
        var blockid = newblock.id.replace(new RegExp("_i","g"), " " + i);

    newblock.id = blockid;
    newblock.className = "";

    newblock.innerHTML = newblock.innerHTML.replace(new RegExp("_i","g"), "-" + i);
    newblock.innerHTML = newblock.innerHTML.replace(new RegExp("dependentrequired","g"), "required");

    var mytarget = document.getElementById(target);

    mytarget.insertBefore(newblock, document.getElementById(target).lastChild.nextSibling);
    
    }
}


function maxtext(x,y){
tempstr = x.value
  if(tempstr.length>y){
    x.value = tempstr.substring(0,y);
  }
}

function gup( name )
{
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

	var regexS = "[\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );

	if( results == null )
	{
//alert("niets: " + regexS);
	    return "";
	}
	else
	{
var str= results[1].replace( /%20/g," ");
str = str.replace( /:[0-9][0-9]$/g, "" );

	    return str;
	}
}



function Postcode(land,target)
{
    var pc = document.getElementById(target);
    if (land.value == "NL") 
    {
    pc.attributes.validation.value = "NLzip"
    }
    else
    {
    pc.attributes.validation.value = ""
    }
}

function Bankproef(land,target)
{
    var pc = document.getElementById(target);
    if (land.value == "NL") 
    {
    pc.attributes.validation.value = "dutchbankaccount"
    }
    else
    {
    pc.attributes.validation.value = "posint"
    }
}

function fillfield(fieldname, parameter)
{
    if (document.getElementById(fieldname))
        document.getElementById(fieldname).value = gup(parameter);
}

function clickButton(mybutton)
{
    if (event.keyCode == 13) 
    {
    document.getElementById(mybutton).click();
    return false;
    }
}

function selectradiobutton(text, list, item)
{
    var theObj = document.getElementById(list);
    if (text.value != "")
    {
        theObj.checked = true;
    }
    else
    {
        theObj.checked = false;
    }
}

function setdefaultdate(element , datepart)
{
var d = new Date();
var newvalue;

if (datepart == 'day')
    newvalue = d.getDate();
else if (datepart == 'month')
    newvalue = d.getMonth() + 1;
else if (datepart == 'year')
    newvalue= d.getFullYear();
else
    return;
    
    document.getElementById(element).value = newvalue;
}




function TTdata() {
    document.getElementById("ttdate").innerHTML = gup("t");
    document.getElementById("region").innerHTML = gup("r");

    if (gup("i").split(";")[0] == "MG")
    document.getElementById("typevoorstelling").innerHTML = "meervoudige handicap.";
    else
    document.getElementById("typevoorstelling").innerHTML = "(licht) verstandelijke handicap.";

document.getElementById("TheatertourID").value = gup("i").split(";")[2]
document.getElementById("beschikbareplaatsen").value = gup("i").split(";")[1]

document.getElementById("regio").value = gup("r");
document.getElementById("voorstelling").value = gup("t");
    
    //document.getElementById("EvenementStart").value = gup("from");
    //document.getElementById("EvenementEind").value = gup("to");
    //var datum = gup("from");
    //datum = datum.split(" ")[0];
    //var tijd = gup("from");
    //tijd = tijd.split(" ")[1];
    //tijd = tijd.split(":")[0] + ":" + tijd.split(":")[1];
    //document.getElementById("eventdatum").value = datum;
    //document.getElementById("eventtijd").value = tijd;

    //alert(datum);
    //alert(tijd);

    //document.getElementById("fromto").innerHTML = "<strong>" + datum + " om " + tijd + " uur</strong>";

}


function copyblocksTT(cbbox, target, diff) {
    
    var blocknumbers = cbbox.value;

    var targetElement = document.getElementById(target)

    //remove "whitespace-childnodes"
    for (j = 0; j < targetElement.childNodes.length; j++) {

        if (targetElement.childNodes[j].nodeType != 1)
            targetElement.removeChild(targetElement.childNodes[j]);
        else
            break;

    }


    while (targetElement.firstChild.id != targetElement.lastChild.id) {
        var childnode = targetElement.lastChild;
        targetElement.removeChild(childnode)
    }


    for (var i = 1 - diff; i <= blocknumbers; i++) {
        var oldblock = document.getElementById(target).firstChild
        var newblock = oldblock.cloneNode(true);
        var blockid = newblock.id.replace(new RegExp("_i", "g"), " " + i);
        
        newblock.id = blockid;
        newblock.className = "";

        newblock.innerHTML = newblock.innerHTML.replace(new RegExp("_i", "g"), "-" + i);
        //newblock.innerHTML = newblock.innerHTML.replace(new RegExp("dependentrequired", "g"), "required");

        var mytarget = document.getElementById(target);

        mytarget.insertBefore(newblock, document.getElementById(target).lastChild.nextSibling);

    }
}

function hideblock(chkbox, group) {
    var visSetting = (chkbox.checked) ? "none" : "inline";
    var oElement = document.getElementById(group);

    //als bloch zichtbaar wordt de bijbehorende verplichte velden als
    //verplicht maken: class=required
    //als niet 'anders' is geselecteerd evt. verplichte velden opheffen: class=orequired

    var oAreas = new Array(3);
    oAreas[0] = "TEXTAREA";
    oAreas[1] = "INPUT";
    oAreas[2] = "SELECT";

    for (var a = 0; a < oAreas.length; a++) {
        var oTextarea = oElement.getElementsByTagName(oAreas[a]);
        for (var i = 0; i < oTextarea.length; i++) {
            if (!chkbox.checked) {
                //alert('area' + oTextarea[i].className);
                if (oTextarea[i].className.match(/dependentrequired/i)) {
                    oTextarea[i].className = 'required';
                }
            }
            else {
                if (oTextarea[i].className.match(/\brequired/i)) {
                    oTextarea[i].className = 'dependentrequired';
                }
            }

            //waarden verwijderen
            if (a <2) {
                
                if (oTextarea[i].type != 'radio') {
                       oTextarea[i].value = '';
                }
            }

        }
    }


    oElement.style.display = visSetting;

}

function visitors(target) {

    var t = document.getElementById('aantalkinderen');
    t.length = 1;

    if (target == "instelling") {

        for (i = 1; i <= gup("i").split(";")[1]; i++) {
            //alert(gup("i").split(";")[1]);
            if (i > gup("i").split(";")[1]) break;
            //alert(gup("i").split(";")[1] + " i= " + i);
            t.options[i] = new Option(i, i);

        }
        t.options[0].selected = true;
    
    }
    else {   

        for (i = 1; i <= 3; i++) {
            //alert(gup("i").split(";")[1]);
            if (i > gup("i").split(";")[1]) break;
            //alert(gup("i").split(";")[1] + " i= " + i);
            t.options[i] = new Option(i, i);

        }
        t.options[0].selected = true;
    }


    //zetten kinderen zonder handicap
//    t = document.getElementById("aantalzkinderen");
    //    t.options[0].selected = true;
    var t = document.getElementById('aantalzkinderen');
    t.length = 1;

    if (target == "instelling") {

        for (i = 1; i <= (parseInt(gup("i").split(";")[1]+3)); i++) {
            //alert(gup("i").split(";")[1]);
            if (i > (parseInt(gup("i").split(";")[1])+3)) break;
            //alert(gup("i").split(";")[1] + " i= " + i);
            t.options[i] = new Option(i-1, i-1);

        }
        t.options[0].selected = true;

    }
    else {

        for (i = 1; i <= 4; i++) {
            
//            if (i > gup("i").split(";")[1]) break;
            
            t.options[i] = new Option(i -1, i-1);

        }
        t.options[0].selected = true;
    }


    //zetten aantal volwassenen;
    t = document.getElementById("aantalvolwassenen");
    t.length = 1;
    if (target == "instelling") {

        for (i = 1; i <= (parseInt(gup("i").split(";")[1]) + 3); i++) {
            
            if (i > (parseInt(gup("i").split(";")[1]) + 3)) break;
            
            t.options[i] = new Option(i, i);

        }
        t.options[0].selected = true;

    }
    else {

        for (i = 1; i <= 3; i++) {

            //if (i > gup("i").split(";")[1]) break;
            
            t.options[i] = new Option(i, i);

        }
        t.options[0].selected = true;
    }
    
}

function CalculateFamily() {
    var hkinderen = parseInt(document.getElementById("aantalkinderen").value) || 0;
    var volwassen = parseInt(document.getElementById("aantalvolwassenen").value) || 0;
    document.getElementById("aantalpersonen").value = hkinderen  + volwassen;
}


function CalculateTotal()
{
    var hkinderen = parseInt(document.getElementById("aantalkinderen").value) || 0;
    var zkinderen =  parseInt(document.getElementById("aantalzkinderen").value) || 0;
    var volwassen =  parseInt(document.getElementById("aantalvolwassenen").value) || 0;
    document.getElementById("aantalpersonen").value = hkinderen + zkinderen + volwassen;

    
    
}
 /*
function removeOptions(source, target) {
    var vw = document.getElementById(target);
    var nr = (source.value / 3 * 2);

    alert(nr);

    for (i = nr; i <= 0; i--) {

        while (parseInt(vw.options[1].value) > nr)
            vw.options[1] = parseInt(vw.options[1]) - 1;
    
    if (parseInt(vw.options[nr].value) < nr )
        vw.options[i] = null;
    }
};
*/


function CheckFamily(source) {


    if (parseInt(document.getElementById("aantalpersonen").value) > 4) {
        alert("Er mogen niet meer dan 4 personen worden opgegeven.")
        //        document.getElementById("error").style.display = "block";
        //        document.getElementById("error").className = "error";
        //        document.getElementById("error").innerHTML = "Een gezin mag niet groter zijn dan 4 personen. Pas de gegevens aan of neem contact op met CliniClowns.";
        //alert(source.value);
        //source.value = "";
        document.getElementById("aantalkinderen").value = "";
        document.getElementById("aantalvolwassenen").value = "";
        if (source)
                source.focus();
        return false;
    }
    else {
        return true;
    }


}

function CheckPerson(source) {

    var val = "";

    for (i = 0; i < document.theatertour.gezinInstelling.length; i++) {
        if (document.theatertour.gezinInstelling[i].checked == true) {
            val = document.theatertour.gezinInstelling[i].value;
            break;
        }
    }


    //alert(val);
    if (val == "gezin") {

        if (parseInt(document.getElementById("aantalpersonen").value) > 4) {
            alert("Een gezin mag niet groter zijn dan 4 personen.")
            //        document.getElementById("error").style.display = "block";
            //        document.getElementById("error").className = "error";
            //        document.getElementById("error").innerHTML = "Een gezin mag niet groter zijn dan 4 personen. Pas de gegevens aan of neem contact op met CliniClowns.";
            document.getElementById("aantalkinderen").value = "";
            document.getElementById("aantalvolwassenen").value = "";
            if (source)
                        source.focus();
            return false;
        }
        else {
            return true;
        }
    }

}

function CheckPersons(source) {

    var val = "";

    for (i = 0; i < document.theatertour.gezinInstelling.length; i++) {
        if (document.theatertour.gezinInstelling[i].checked == true) {
            val = document.theatertour.gezinInstelling[i].value;
            break;
        }
    }


    //alert(val);
if (val == "gezin") {

    if (parseInt(document.getElementById("aantalpersonen").value) > 4) {
        alert("Een gezin mag niet groter zijn dan 4 personen.")
        //        document.getElementById("error").style.display = "block";
        //        document.getElementById("error").className = "error";
        //        document.getElementById("error").innerHTML = "Een gezin mag niet groter zijn dan 4 personen. Pas de gegevens aan of neem contact op met CliniClowns.";
        document.getElementById("aantalkinderen").value = "";
        document.getElementById("aantalvolwassenen").value = "";
        if (source)
                source.focus();
        return false;
    }
    else {
        return true;
    }
    }
    else{
    var nrkids = parseInt(document.getElementById("aantalkinderen").value);
    var nradults = parseInt(document.getElementById("aantalvolwassenen").value);

    var oadults = document.getElementById("aantalvolwassenen");

    if (nradults >= nrkids / 10 * 6 && gup("i").split(";")[0] == "VG") {
        oadults.className = oadults.className.replace(new RegExp("error\\b"), "");

        return true;

    }
    else if (nradults >= nrkids && gup("i").split(";")[0] == "MG") {
    oadults.className = oadults.className.replace(new RegExp("error\\b"), "");

    return true;
    }
    else {
        if (oadults.className.indexOf("error") < 0)
            oadults.className += " error";

        alert("Er is onvoldoende begeleiding opgegeven.")
        //        document.getElementById("error").style.display = "block";
        //        document.getElementById("error").className = "error";
        //        document.getElementById("error").innerHTML = "Er is onvoldoende begeleiding opgegeven.";
        if (source)
                source.focus();
        return false;
    }
    }
   
}


function ValidationOn(formID, group) {

    var oCurrentForm = document.getElementById(formID);

    oForm.scrobble(oCurrentForm);

    oForm.validate(oCurrentForm, false)

    if (document.getElementById('error').style.display == "block") {
        //alert(document.getElementById('error').innerHTML);
        //alert(document.getElementById('error').style.display);
        return;
    }



    var step1_2 = document.getElementById("aanmelden1_2");
    var step2_2 = document.getElementById("aanmelden2_2");

    if (step1_2.style.display != "none") {
        step2_2.style.display = "inline";
        step2_2.focus();
        step1_2.style.display = "none";

    }
    else {
        step1_2.style.display = "inline";
        step2_2.style.display = "none";

    }

    //alert("test");
    var visSetting = "inline";
    var oElement = document.getElementById(group);

    //als bloch zichtbaar wordt de bijbehorende verplichte velden als
    //verplicht maken: class=required
    //als niet 'anders' is geselecteerd evt. verplichte velden opheffen: class=orequired

    var oAreas = new Array(3);
    oAreas[0] = "TEXTAREA";
    oAreas[1] = "INPUT";
    oAreas[2] = "SELECT";

    for (var a = 0; a < oAreas.length; a++) {
        var oTextarea = oElement.getElementsByTagName(oAreas[a]);
        for (var i = 0; i < oTextarea.length; i++) {
            
                //alert('area' + oTextarea[i].className);
            if (oTextarea[i].className.match(/dependentrequired/i) && !oTextarea[i].name.match(/_i$/i)) {
                //alert(oTextarea[i].name);
                    oTextarea[i].className = 'required';
                }

        }
    }


    oElement.style.display = visSetting;

}

function CheckReferrer() {
    if (gup("i") == "")
        document.location = '/page/home/wat_we_doen/theatertour/aanmelden';
}

function Terms(checkboxid) {

    var chb = document.getElementById(checkboxid);

    if (!chb.checked) {
        alert("U moet akkoord gaan met de voorwaarden.");
        return false;
    }


    return true;
}
