// Custom JS functions
$(document).ready(function() { 
	
	//Hide toolkit help login menu
	//$(".highlight .help").hide();
	
	//$('a.helper').click(function(){
		//$(".highlight .help").toggle();
		//return false;
	//});



	$("#gebdatum").datepicker({ dateFormat: 'dd-mm-yy', changeYear: true, yearRange: '1940:-0'});

	jQuery.validator.addMethod("postalcode", function(postalcode, element) {
		return this.optional(element) || postalcode.match(/[0-9]{4,4}\s[a-zA-Z]{2,2}/) || postalcode.match(/[0-9]{4,4}[a-zA-Z]{2,2}/);
	}, "Vul een postcode in.");	
	
	jQuery.validator.addMethod("dateNL", function(value, element, params) {
		return this.optional(element) || /^\d\d?\-\d\d?\-\d\d\d?\d?$/.test(value);
	}, "Vul alstublieft een geldige datum in. (dd-mm-jjjj)");

	//Slide navigation
	$(".slide").children().hide();
	$('#contact').show();
	
	$(".slide").hoverIntent( 
		  function() {
		  	$(this).children('ul').slideDown(200);

		  }, function() {
		  	$(this).children('ul').slideUp(200);
		  }
	);
		
	// Initiate chosen dropdown
	$(".chzn-dropdown").chosen();
	
	// Hide
	$(".vacaturesites label").hide();
	
	$('#show_trans').click(function(){
		$('.video_transcriptie').slideToggle('3000',function(){
			if($('#transcript').text() == 'sluiten'){
				$('#transcript').html('tonen');
			}else{
				$('#transcript').html('sluiten');
			}
		});
		return false;
	});

	$('#interesse_stap').validate({
		rules: {
			pc:{
				required: true,
				postalcode: true			
			}
		},
		messages: {
			pc: "Vul een postcode in (bijv. 1234AA)",
		}
	});
	
	
	// validate sollicitatieform test
	$("#open-sollicitatie").validate({
		rules: {
			voorletter: {
				required: true,
				minlength: 1
			},
			voornaam: "required",
			achternaam: "required",
			email: {
				required: true,
				email: true
			},
			adres: "required",
			huisnr: {
				required: true,
				minlength: 1
			},
			woonplaats: "required",
			postcode: { 
				postalcode: true	
			},
			gebdatum: { 
     			dateNL: true,
     			required: true
			},
			niveau: "required",
			studierichting: "required",
			diplomajaar: "required",
			functiegebied: "required",
			beschikbaarheid: "required",
			cv: { 
				required: true,
				accept: "doc|pdf|docx|txt"	
			},
			motivatie: { 
				required: true,
				accept: "doc|pdf|docx|txt"	
			}
			
		},
		messages: {
			voorletter: "Vul een voorletter in",
			voornaam: "Vul een voornaam in",
			achternaam: "Vul een achternaam in",
			email: "Vul een geldig emailadres in",
			adres: "Vul een adres in",
			huisnr: "Vul een huisnummer in",
			woonplaats: "Vul een huisnummer in",
			postcode: "Vul een postcode in (bijv. 1234AA)",
			land: "",
			gebdatum: "Vul een geboortedatum in (bijv. 01-01-1980)",
			niveau: "Vul een opleidingsniveau in",
			studierichting: "Vul een studierichting in",
			diplomajaar: "Vul een diplomajaar in",
			functiegebied: "Vul een functie-gebied in",
			beschikbaarheid: "Vul beschikbaarheid in",
			cv: "Upload je cv",
			motivatie: "Upload je motivatie/sollicitatiebrief"
		}
	});
	
	// validate contactform
	$("#contact").validate({
		rules: {
			naam: "required",
			email: {
				required: true,
				email: true
			},
			opmerking: {
				required: true,
				minlength: 5
			}
			
		},
		messages: {
			naam: "Vul een naam in",
			email: "Vul een geldig emailadres in",
			opmerking: "Vul een vraag of opmerking in"
		}
	});
	

});

function makeChoice(v, c){
	if(v == 0){
		if(c == 1){
			window.location = "/zorg/";
		}else{
			window.location = "/z/zorg/";
		}
	}else if(v == 1){
		if(c == 1){
			window.location = "/vmbo12/";
		}else if(c == 2){
			window.location = "/vmbo34/";
		}else if(c == 3){
			window.location = "/mbo/";
		}else if(c == 4){
			window.location = "/o/";
		}
	}else if(v == 2 || v == 3 || v == 4 || v == 5 || v== 9){
		if(c == 1){
			window.location = "/verpleeghuiszorg/";
		}else if(c == 2){
			window.location = "/verzorgingshuiszorg/";
		}else if(c == 3){
			window.location = "/thuiszorg/";
		}else if(c == 4){
			window.location = "/kraamzorg/";
		}
	}else if(v == 6 || v == 7 || v == 8 || v == 10){
		if(c == 1){
			window.location = "/functies-in-de-zorg/";
		}else if(c == 2){
			window.location = "/social/";
		}else if(c == 3){
			if(v==6){
				//bert
				window.open("https://www.facebook.com/pages/Ome-Bert/202484579821237"); return false;
			}else if(v==7){
				//brian
				window.open("https://www.facebook.com/pages/Kleine-Brian/174642549283885", '_blank'); return false;
			}else if(v==8){
				//lenie
				window.open("https://www.facebook.com/pages/Tante-Lenie/202717926463228", '_blank'); return false;
			}else if(v==10){
				//constance
				window.open("https://www.facebook.com/pages/Constance/123638241073402", '_blank'); return false;
			}	
		}else if(c == 4){
			if(v==6){
				//bert
				window.open("http://twitter.com/#!/ome_bert"); return false;
			}else if(v==7){
				//brian
				window.open("http://twitter.com/#!/kleine_brian", '_blank'); return false;
			}else if(v==8){
				//lenie
				window.open("http://twitter.com/#!/tante_lenie", '_blank'); return false;
			}else if(v==10){
				//constance
				window.open("http://twitter.com/#!/constanceVanA", '_blank'); return false;
			}	
		}else if(c == 5){
			if(v==6){
				//bert
				window.open("http://ome-bert.hyves.nl/"); return false;
			}else if(v==7){
				//brian
				window.open("http://kleinebrian.hyves.nl/", '_blank'); return false;
			}else if(v==8){
				//lenie
				window.open("http://tante-lenie.hyves.nl/", '_blank'); return false;
			}else if(v==10){
				//constance
				window.open("http://constancevana.hyves.nl/", '_blank'); return false;
			}	
		}
	}
}

function showMenuBlocks(){
	$.cookie('showmenu', '1', { path: '/' });
	$('#menu').fadeIn();
	$('#flashmenu').hide();
}
