accent_title = [];
accent_title[1] = 'Archeologie';
accent_title[2] = 'Immaterieel erfgoed';
accent_title[3] = 'Scholen';
accent_title[4] = 'Amateurkunst';
accent_title[5] = 'Publieksbereik en spreiding';
accent_title[6] = 'Culturele planologie';
accent_title[8] = 'Talentontwikkeling';
accent_title[10] = 'Cultuur en economie';
accent_title[12] = 'Cultuurhistorie & ruimte';
accent_title[13] = 'Monumenten';
accent_title[14] = 'Jeugdtheater';
accent_title[15] = 'Publieksontwikkeling';
accent_title[16] = 'Digitale mogelijkheden';
accent_title[17] = 'Bibliotheken en media';
accent_title[19] = 'Media-educatie';


$(function() // pageload
{
	  
    openScreen('ContLinks', 'right', 240);
	  
    //ajax controller
    

    $("html").click(function(){
	  ignore_hash = true;
	  setTimeout(function(){
		ignore_hash = false;
	  },500);
    });
	  	
     
    //$("*").click(function(){ $(this).css('border','1px solid blue'); alert($(this).attr("id")); });

    //openScreen('ContBanners', 'right', 1);

    current_cat = 0;
	
    if ( ($("#init_pagina").html()!='') && ($("#init_id").html()) )
    {
	  var this_pag = $("#init_pagina").html();
	  var initid = $("#init_id").html();
	  if (this_pag=='uitgelicht')
	  {
		$("#uitgelicht_popup").show();
		uitgelicht_set_content(initid);
	  }
	  if (this_pag=='locatie')
	  {
		$("#uitgelicht_op_kaart_popup").show();
		uitgelicht_op_kaart_set_content(initid);
	  }
		
    }
	
    //subsidiemogelijkheden
    $(".submo_titel").click(function()
    {
	  id = $(this).attr("id").substr(12);
				
	  if ($("#submo_content_"+id).css('display')=='block')
	  {
		$("#submo_content_"+id).slideUp("fast");
		$("#submo_titel_"+id).css("background-image","url(/images/cultuurnota_ingeklapt.gif)");
		return;
	  }
	
	  $(".submo_content").slideUp("fast");
	  $("#submo_content_"+id).slideDown("fast");
	  $(".submo_titel").css("background-image","url(/images/cultuurnota_ingeklapt.gif)");
	  $("#submo_titel_"+id).css("background-image","url(/images/cultuurnota_uitgeklapt.gif)");
		
    });
		
    //tijdlijn
    var options = {
	  zoomWidth: 600,
	  zoomHeight: 395,
	  xOffset: 10,
	  yOffset: 26,
	  title: false,
	  position: "right",
	  preloadText: 'Laden...'
    };
    $('.jqzoom').jqzoom(options);
	
    //jongerenkaart
    $("#toevoegen_poi_adres").click(function()
    {
	  title = $(this).attr("title");
	  val = $(this).attr("value");
	  if (val==title) {
		$(this).attr("value","");
	  }
    });
	
    $("#reactie_form").submit(function()
    {
	  id = openMarker;
	  reactie = $("#reactie_form_reactie").val();
	  naam = $("#reactie_form_naam").val();
	  email = $("#reactie_form_email").val();
		
	  if ((!naam) || (!reactie)) {
		alert('Vul zowel een naam als een reactie in');
		return false;
	  }
	  if ((email!='') && (!validate_email(email))) {
		alert('Het opgegeven e-mail adres is ongeldig');
		return false;
	  }

	  function post_reactie(id,reactie,naam,email)
	  {
		$.post("/ajax/jongerenkaart_reactie.php",{
		    id:id,
		    reactie:reactie,
		    naam:naam,
		    email:email
		},function(data)

		{
			  $("#reactie_content").load("/ajax/jongerenkaart_reacties.php?id="+openMarker);
			  $("#jong_aantal_reacties").load("/ajax/jongerenkaart_reacties.php?type=count&id="+openMarker);
			  document.getElementById('reactie_form').reset();
			  $("#reageerPoi").hide();
			  alert('Je reactie is opgeslagen');
		    });
	  }
	  post_reactie(id,reactie,naam,email);
		
	  return false;
    });
	
    $("#contactformulier_form").submit(function()
    {
	  naam = $("#contactformulier_form input[name=naam]").val();
	  adres = $("#contactformulier_form input[name=adres]").val();
	  postcode = $("#contactformulier_form input[name=postcode]").val();
	  plaats = $("#contactformulier_form input[name=plaats]").val();
	  telefoonnummer = $("#contactformulier_form input[name=telefoonnummer]").val();
	  email = $("#contactformulier_form input[name=email]").val();
	  reactie = $("#contactformulier_form textarea[name=reactie]").val();
		
	  if ((!naam) || (!reactie)) {
		alert('Vul zowel een naam als een reactie in');
		return false;
	  }
	  if ((email=='') || (!validate_email(email))) {
		alert('Vul een geldig e-mail adres in');
		return false;
	  }

	  $("#contactformulier_laden").show();
	  $("#contactformulier_submit").hide();
			
	  $.post("/ajax/contactformulier_submit.php",{
		reactie:reactie,
		naam:naam,
		plaats:plaats,
		email:email,
		adres:adres,
		postcode:postcode,
		telefoonnummer:telefoonnummer
	  },function(data)

	  {
		    $("#contactformulier_laden").hide();
		    $("#contactformulier_submit").show();
		    document.getElementById('contactformulier_form').reset();
		    alert('De reactie is verzonden.');
		});
		
	  return false;
    });
	
		
    nieuws_selectie = false;
    $("#nieuws_link").click(function()
    {
	  $(".popOver").hide();
	  $("#nieuws_popup").show();
	  if (!nieuws_selectie) {
		ajax_set_url('nieuws');
		set_nieuws('3mnd');
	  }
    });
	
    $("#nieuws_index a").click(function()
    {
	  selectie = $(this).attr("id").substr(13);
	  set_nieuws(selectie);
    });

    $("#zoeken_submit").click(function() {
	  $("#zoeken_form").submit();
    });

    $("#zoeken_form").submit(function()
    {
	  input = $("#zoeken_input").val();
	  $("#zoeken_in_cultuurnota_zoeken").val(input);
	  if (!input) {
		alert('Vul eerst een zoektekst in.');
		return false;
	  }
	  $(".popOver").hide();
	  $("#cultuurnota_zoeken_popup").show();
	  cultuurnota_zoeken(input);
	  return false;
    });
	
    $("#cultuurnota_zoeken_form").submit(function()
    {
	  input = $("#zoeken_in_cultuurnota_zoeken").val();
	  $("#zoeken_input").val(input);
	  if (!input) {
		alert('Vul eerst een zoektekst in.');
		return false;
	  }
	  cultuurnota_zoeken(input);
	  return false;
    });

    zoekstring = '';
    function cultuurnota_zoeken(str)
    {
	  zoekstring = str;
	  var res='';
	  $.ajax(
	  {
		url:'/ajax/cultuurnota_zoeken.php',
		data:{
		    zoekwoord:str
		},
		success:function(data)
		{
		    $("#cultuurnota_zoeken_zoekresultaten").html(data);
		    $('#cultuurnota_zoeken_zoekresultaten,#cultuurnota_index,#cultuurnota_tekst').each(function() {
			  $.highlight(this, str.toUpperCase());
		    });
		}
	  });
    }

	
    $("#thema_1_link").click(function(){
	  $(".popOver").hide();
	  $("#thema_popup_1").show();
	 setPageTitle('Thema: mooi Noord-Holland');
    });
    $("#thema_2_link").click(function(){
	  $(".popOver").hide();
	  $("#thema_popup_2").show();
	  setPageTitle('Thema: genieten en meedoen');
    });
    $("#thema_3_link").click(function(){
	  $(".popOver").hide();
	  $("#thema_popup_3").show();
	   setPageTitle('Thema: levend verleden');
	  
    });
    $(".home_link").click(function()
    {
	  if (jongerenkaart) {
		$("#loader_wrapper").show();
		switch_jongerenkaart();
		return;
	  }
	  if (marker_list_active)
	  {
		defaultLocation();
		map.setMapType(G_PHYSICAL_MAP);
		map.clearOverlays();
		marker_visible=[];
		for (i=0;i<marker_list_active.length;i++) {
		    id = marker_list_active[i];
		    addMarker(id);
		}
		$(".legenda_check").each(function() {
		    $(this).attr("checked","");
		});
		$("#zoeken_op_kaart_zoekresultaat").html('Vul eerst een zoekopdracht in.');
		$("#zoeken_op_kaart_gemeente").val('');
		$("#zoeken_op_kaart_naam").val('');
		if (openMarker) {
		    poiClose(openMarker);
		}
		poi_return=false;
		statistische_kaart_return = false;
		legenda('open');
		zoeken_op_kaart('sluit');
	  }
		
	  gotohome();
    });
    $("#jongerenkaart_link,#cultuur_link").click(function(){
	  switch_jongerenkaart();
    });
    $("#jongerenkaart_link,#cultuur_link").click(function(){
	  $('#loader_wrapper').show();
    });
    $("#tijdlijn_link").click(function(){
	  $(".popOver").hide();
	  $("#tijdlijn_popup").show().css('visibility','visible');
	  $("#tijdlijn_popup2").show();
    });
    if(window.location.pathname.toLowerCase().indexOf('tijdlijn')!=-1)
    {
	  $(".popOver").hide();
	  $("#tijdlijn_popup").show().css('visibility','visible');
	  $("#tijdlijn_popup2").show();
    };

    $("#overcultuurnota_link").click(function(){
	  start_introductie();
    });
    $("#contact_link").click(function(){
	  $(".popOver").hide();
	  $("#contact_popup").show();
    });
    //cultuurnota links
    $("#cultuurnota_print").click(function(){
	  print_div('cultuurnota_tekst');
    });
	
    $(".wistudat_nogeen").click(function()
    {
	  wistudat_set_content();
		
    });
	
    $(".statistische_kaart_toon_op_kaart").click(function()
    {
	  if (jongerenkaart) {
		switch_jongerenkaart();
	  }
	  target_id = statistische_kaart_id[current_cat];
	  if (!target_id) {
		alert('Er kan geen kaart worden gevonden');
		return;
	  }
	  openScreen(n2o[current_cat]);
	  add_overlay(target_id);
    });
	
    $(".statistische_kaart_bekijk").click(function()
    {
	  id = statistische_kaart_id[current_cat];
	  ajax_set_url('statistische-kaart/'+id);
	  statistische_kaart_bekijk(id);
    });
	
	
    $("#statistische_kaart_popup .imageswitcher_vorige, .statistische_kaart_wrapper .imageswitcher_vorige").click(function()
    {
	  huidige_locatie = $("#statistische_kaart_wrapper_"+current_cat+" .huidignr").html();
	  totaalnr = $("#statistische_kaart_wrapper_"+current_cat+" .totaalnr").html();
	  if (huidige_locatie==1) {
		huidige_locatie = totaalnr;
	  } else {
		huidige_locatie = huidige_locatie - 1;
	  }
	  $("#statistische_kaart_wrapper_"+current_cat+" .huidignr,#statistische_kaart_popup .huidignr").html(huidige_locatie);
	  statistische_kaart_set_content(statistische_kaart_ids[current_cat][huidige_locatie-1]);
    });

    $("#statistische_kaart_popup .imageswitcher_volgende, .statistische_kaart_wrapper .imageswitcher_volgende").click(function()
    {
	  huidige_locatie = $("#statistische_kaart_wrapper_"+current_cat+" .huidignr").html();
	  totaalnr = $("#statistische_kaart_wrapper_"+current_cat+" .totaalnr").html();
	  if (huidige_locatie==totaalnr) {
		huidige_locatie = 1;
	  } else {
		huidige_locatie++;
	  }
	  $("#statistische_kaart_wrapper_"+current_cat+" .huidignr,#statistische_kaart_popup .huidignr").html(huidige_locatie);
	  statistische_kaart_set_content(statistische_kaart_ids[current_cat][huidige_locatie-1]);
    });
	
    $(".uitgelicht_op_kaart_toon").click(function()
    {
	  target_id = uitgelicht_op_kaart_id[current_cat];
	  poi_return = current_cat;
	  toon_op_kaart(target_id);
    });
	
    $(".uitgelicht_op_kaart_leesverder").click(function()
    {
	  target_id = uitgelicht_op_kaart_id[current_cat];
	  $("#uitgelicht_op_kaart_popup .totaalnr").html($("#uitgelicht_op_kaart_wrapper_"+current_cat+" .totaalnr").html());
	  $("#uitgelicht_op_kaart_popup .huidignr").html($("#uitgelicht_op_kaart_wrapper_"+current_cat+" .huidignr").html());
		
	  uitgelicht_op_kaart_leesverder(target_id);
    });

    $("#uitgelicht_op_kaart_popup .imageswitcher_vorige, .uitgelicht_op_kaart_wrapper .imageswitcher_vorige").click(function()
    {
	  huidige_locatie = $("#uitgelicht_op_kaart_wrapper_"+current_cat+" .huidignr").html();
	  totaalnr = $("#uitgelicht_op_kaart_wrapper_"+current_cat+" .totaalnr").html();
	  if (huidige_locatie==1) {
		huidige_locatie = totaalnr;
	  } else {
		huidige_locatie = huidige_locatie - 1;
	  }
	  $("#uitgelicht_op_kaart_wrapper_"+current_cat+" .huidignr,#uitgelicht_op_kaart_popup .huidignr").html(huidige_locatie);
	  uitgelicht_op_kaart_set_content(uitgelicht_op_kaart_ids[current_cat][huidige_locatie-1]);
		
    });

    $("#uitgelicht_op_kaart_popup .imageswitcher_volgende, .uitgelicht_op_kaart_wrapper .imageswitcher_volgende").click(function()
    {
					
	  huidige_locatie = $("#uitgelicht_op_kaart_wrapper_"+current_cat+" .huidignr").html();
	  totaalnr = $("#uitgelicht_op_kaart_wrapper_"+current_cat+" .totaalnr").html();
	  if (huidige_locatie==totaalnr) {
		huidige_locatie = 1;
	  } else {
		huidige_locatie++;
	  }
	  $("#uitgelicht_op_kaart_wrapper_"+current_cat+" .huidignr,#uitgelicht_op_kaart_popup .huidignr").html(huidige_locatie);
	  uitgelicht_op_kaart_set_content(uitgelicht_op_kaart_ids[current_cat][huidige_locatie-1]);
    });

    $("#uitgelicht_op_kaart_groot_vorige_afb").click(function()
    {
	  lijst = uitgelicht_op_kaart_img_lijst[current_cat];
	  cur_img = uitgelicht_op_kaart_img[current_cat];
	  target_id = uitgelicht_op_kaart_id[current_cat];
	  cur_pos = lijst.indexOf(cur_img);
	  if (cur_pos<0) {
		cur_pos = 0;
	  }
	  if (lijst[cur_pos-1]) {
		cur_img = lijst[cur_pos-1];
	  } else {
		cur_img = lijst[lijst.length-1];
	  }
	  uitgelicht_op_kaart_img[current_cat] = cur_img;
	  alert(cur_img);
	  if (cur_img.substr(0,4)=="[yt=")
	  {
		yt_code = cur_img.substr(4);
		yt_code = yt_code.split("]")[0];
		html = youtube_html(yt_code);
		$("#uitgelicht_op_kaart_image_groot").css("background-image","none").html(html);

	  }
	  else
	  {
			
		$("#uitgelicht_op_kaart_image_groot").html('').css("background-image","url(/files/uitgelicht_kaart/"+target_id+"/"+cur_img+"/290.jpg)");
	  }
    });
	

    $("#uitgelicht_op_kaart_groot_volgende_afb").click(function()
    {
	  lijst = uitgelicht_op_kaart_img_lijst[current_cat];
	  cur_img = uitgelicht_op_kaart_img[current_cat];
	  target_id = uitgelicht_op_kaart_id[current_cat];
	  cur_pos = lijst.indexOf(cur_img);
	  if (!cur_pos) {
		cur_pos = 0;
	  }
	  if (lijst[cur_pos+1]) {
		cur_img = lijst[cur_pos+1];
	  } else {
		cur_img = lijst[0];
	  }
	  uitgelicht_op_kaart_img[current_cat] = cur_img;
		
	  if (cur_img.substr(0,4)=="[yt=")
	  {
		yt_code = cur_img.substr(4);
		yt_code = yt_code.split("]")[0];
		html = youtube_html(yt_code);
		$("#uitgelicht_op_kaart_image_groot").css("background-image","none").html(html);

	  }
	  else
	  {
		$("#uitgelicht_op_kaart_image_groot").html('').css("background-image","url(/files/uitgelicht_kaart/"+target_id+"/"+cur_img+"/290.jpg)");
	  }
    });
	
    $("#poi_op_kaart_groot_volgende_afb").click(function()
    {
	  poi_volgende_afb(poi_op_kaart_id);
    });
    $("#poi_op_kaart_groot_vorige_afb").click(function()
    {
	  poi_vorige_afb(poi_op_kaart_id);
    });
	
    $(".uitgelicht_leesverder").click(function()
    {
	  target_id = uitgelicht_id[current_cat];
	  uitgelicht_leesverder(target_id);
		
    });
	  
	 

    $("#uitgelicht_popup .imageswitcher_vorige, .uitgelicht_wrapper .imageswitcher_vorige").click(function()
    {
	  huidige_locatie = $("#uitgelicht_wrapper_"+current_cat+" .huidignr").html();
	  totaalnr = $("#uitgelicht_wrapper_"+current_cat+" .totaalnr").html();
	  if (huidige_locatie==1) {
		huidige_locatie = totaalnr;
	  } else {
		huidige_locatie = huidige_locatie - 1;
	  }
	  $("#uitgelicht_wrapper_"+current_cat+" .huidignr,#uitgelicht_popup .huidignr").html(huidige_locatie);
	  uitgelicht_set_content(uitgelicht_ids[current_cat][huidige_locatie-1]);
    });

    $("#uitgelicht_popup .imageswitcher_volgende, .uitgelicht_wrapper .imageswitcher_volgende").click(function()
    {
	  huidige_locatie = $("#uitgelicht_wrapper_"+current_cat+" .huidignr").html();
	  totaalnr = $("#uitgelicht_wrapper_"+current_cat+" .totaalnr").html();
	  if (huidige_locatie==totaalnr) {
		huidige_locatie = 1;
	  } else {
		huidige_locatie++;
	  }
	  $("#uitgelicht_wrapper_"+current_cat+" .huidignr,#uitgelicht_popup .huidignr").html(huidige_locatie);
	  uitgelicht_set_content(uitgelicht_ids[current_cat][huidige_locatie-1]);
    });

    $("#uitgelicht_groot_vorige_afb").click(function()
    {
	  lijst = uitgelicht_img_lijst[current_cat];
	  cur_img = uitgelicht_img[current_cat];
	  target_id = uitgelicht_id[current_cat];
	  cur_pos = lijst.indexOf(cur_img);
	  if (cur_pos<0) {
		cur_pos = 0;
	  }
	  if (lijst[cur_pos-1]) {
		cur_img = lijst[cur_pos-1];
	  } else {
		cur_img = lijst[lijst.length-1];
	  }
	  uitgelicht_img[current_cat] = cur_img;
	  $("#uitgelicht_image_groot").css("background-image","url(/files/uitgelicht/"+target_id+"/"+cur_img+"/290.jpg)");
    });
	
    $("#uitgelicht_groot_volgende_afb").click(function()
    {
	  lijst = uitgelicht_img_lijst[current_cat];
	  cur_img = uitgelicht_img[current_cat];
	  target_id = uitgelicht_id[current_cat];
	  cur_pos = lijst.indexOf(cur_img);
	  if (cur_pos<0) {
		cur_pos = 0;
	  }
	  if (lijst[cur_pos+1]>0) {
		cur_img = lijst[cur_pos+1];
	  } else {
		cur_img = lijst[0];
	  }
	  uitgelicht_img[current_cat] = cur_img;
	  $("#uitgelicht_image_groot").css("background-image","url(/files/uitgelicht/"+target_id+"/"+cur_img+"/290.jpg)");
    });
	
    $(".statistiek_overige_bekijk").click(function()
    {
	  id = statistiek_overige_id[current_cat];
	  ajax_set_url('statistiek/'+id);
	  statistiek_overige_bekijk(id)
    });
	
	
    $("#statistiek_overige_popup .imageswitcher_vorige, .statistiek_overige_wrapper .imageswitcher_vorige").click(function()
    {
	  huidige_locatie = $("#statistiek_overige_wrapper_"+current_cat+" .huidignr").html();
	  totaalnr = $("#statistiek_overige_wrapper_"+current_cat+" .totaalnr").html();
	  if (totaalnr<2) {
		return;
	  }
	  if (huidige_locatie==1) {
		huidige_locatie = totaalnr;
	  } else {
		huidige_locatie = huidige_locatie - 1;
	  }
	  $("#statistiek_overige_wrapper_"+current_cat+" .huidignr,#statistiek_overige_popup .huidignr").html(huidige_locatie);
	  statistiek_overige_set_content(statistiek_overige_ids[current_cat][huidige_locatie-1]);
    });

    $("#statistiek_overige_popup .imageswitcher_volgende, .statistiek_overige_wrapper .imageswitcher_volgende").click(function()
    {
	  huidige_locatie = $("#statistiek_overige_wrapper_"+current_cat+" .huidignr").html();
	  totaalnr = $("#statistiek_overige_wrapper_"+current_cat+" .totaalnr").html();
	  if (totaalnr<2) {
		return;
	  }
	  if (huidige_locatie==totaalnr) {
		huidige_locatie = 1;
	  } else {
		huidige_locatie++;
	  }
	  $("#statistiek_overige_wrapper_"+current_cat+" .huidignr,#statistiek_overige_popup .huidignr").html(huidige_locatie);
	  statistiek_overige_set_content(statistiek_overige_ids[current_cat][huidige_locatie-1]);
    });

    $(".accentlink").click(function()
    {
	  target_id = $(this).attr("id").substr(11);
	  accent_bekijk(target_id);
	  return false;
    });
	  

	
    $("#accent_popup_imageswitcher .imageswitcher_vorige").click(function()
    {
	  id = accenten_id[current_cat];
	  huidige_locatie = 1;
	  for (i=0;i<4;i++) {
		if (accenten_ids[current_cat][i]==id) {
		    huidige_locatie = i;
		    break;
		}
	  }

	  totaalnr = accenten_ids[current_cat];
	  totaalnr = totaalnr.length;
	  if (huidige_locatie==0) {
		huidige_locatie = totaalnr-1;
	  } else {
		huidige_locatie = huidige_locatie - 1;
	  }
	  accenten_set_content(accenten_ids[current_cat][huidige_locatie]);
    });
    $("#accent_popup_imageswitcher .imageswitcher_volgende").click(function()
    {
	  id = accenten_id[current_cat];
	  huidige_locatie = 1;
	  for (i=0;i<4;i++) {
		if (accenten_ids[current_cat][i]==id) {
		    huidige_locatie = i;
		    break;
		}
	  }

	  totaalnr = accenten_ids[current_cat];
	  totaalnr = totaalnr.length;
	  if (huidige_locatie+1==totaalnr) {
		huidige_locatie = 0;
	  } else {
		huidige_locatie = huidige_locatie + 1;
	  }
	  accenten_set_content(accenten_ids[current_cat][huidige_locatie]);
    });

    $("#plaats_ervaring").click(function()
    {
	  titel = $('#poi_label').val();
	  beschrijving = $('#toevoegen_poi_beschrijving').val();
	  naam = $('#toevoegen_poi_naam').val();
	  email = $('#toevoegen_poi_email').val();
	  lat = $('#toevoegen_poi_lat').val();
	  lng = $('#toevoegen_poi_lng').val();
	  locatie = $('#toevoegen_poi_locatie').val();
		
	  if (!titel) {
		alert('Vul een titel in');
		return false;
	  }
	  if (!beschrijving) {
		alert('Vul een beschrijving in');
		return false;
	  }
	  if (!naam) {
		alert('Vul je naam in');
		return false;
	  }
	  if (!locatie) {
		alert('Selecteer een locatie');
		return false;
	  }
		
	  $("#plaats_ervaring").attr("disabled","disabled");
		
	  $.post("/ajax/jongerenkaart_cultuurervaring.php",{
		titel:titel,
		beschrijving:beschrijving,
		naam:naam,
		email:email,
		lat:lat,
		lng:lng,
		locatie:locatie
	  },function(data)

	  {
		    if (!data)
		    {
			  alert('Er is een fout opgetreden bij het versturen, probeer het later opnieuw');
		    }
		    else
		    {
			  $("#plaats_ervaring").removeAttr("disabled");
			  $("#param_values").val(data); //id toewijzen in hidden field voor ajaxupload
			  if ($("#toevoegen_poi_foto").val()!='') //eerst foto uploaden
			  {
				ajaxFileUpload();
			  }
			  else
			  {
				$("#disableMap").show();
				alert('Je inzending is opgeslagen, deze zal na goedkeuring worden gepubliceerd');
				document.getElementById('cultuurervaring_form').reset();
				$("#cultuurervaring").hide();
			  }
		    }
		});
    });

    //jongerenkaart
    $("#toevoegen_poi_adres").click(function()
    {
	  title = $(this).attr("title");
	  val = $(this).attr("value");
	  if (val==title) {
		$(this).attr("value","");
	  }
    });
	
    $(window).bind("resize",function(){
	  set_dimensions();
	  checkDrag();
    });
	
});

poi_imgs = [];
poi_imgs_cur_id = 0;

uitgelicht_kaart_return=false;
function nieuws_lees_verder_uitgelicht_kaart(id)
{
    uitgelicht_kaart_return='nieuws';
    $(".popOver").hide();
    $("#poi_op_kaart_popup").show();
    ajax_set_url('uitgelichte-locatie/'+id);
    poi_op_kaart_set_content(id);
}

uitgelicht_return=false;
function nieuws_lees_verder_uitgelicht(id)
{
    uitgelicht_return='nieuws';
    $(".popOver").hide();
    $("#uitgelicht_popup").show();
    uitgelicht_set_content(id);
    ajax_set_url('uitgelicht/'+id+'/leesverder');
    $("#uitgelicht_groot_imageswitcher").hide();
}
	
function uitgelicht_op_kaart_leesverder(id)
{
    $("#uitgelicht_op_kaart_image_groot").css("background-image","none");
    
    $(".popOver").hide();
												 
    //if (!target_id) { alert('Er kan geen kaart worden gevonden'); return; }
	

    $("#uitgelicht_op_kaart_popup").show();
    uitgelicht_op_kaart_set_content(id);
}
	
	
function start_introductie()
{
    //	$(".posContainer").css('visibility','hidden');
    $("#introductie_wrapper").show();
    //swfobject.embedSWF("/intro/main.swf", "introductie_swf", "996", "615", "9.0.0", false, {}, 
    //	{bgcolor: "#FFFFFF", allowScriptAccess: "always", allownetworking: "all", allowFullScreen: "true", wmode: "transparent"}, {id: "main"});
    
    var main = new SWFObject("/intro/main.swf", "d", "996", "615", "8");
    main.addParam("wmode", "transparent"); 
    main.write("introductie_swf");
}

function introductie_sluiten()
{
    $("#introductie_wrapper").hide();
    //$("#introductie_swf").html('');
    //SWFAddress.setValue('/');
    $(".posContainer").css('visibility','visible');
}

function set_nieuws(selectie)
{
    nieuws_selectie = selectie;
    var nieuws='';
    $.ajax(
    {
	  url:'/ajax/nieuws_content.php',
	  data:{
		selectie:selectie
	  },
	  success:function(data)
	  { 
		$("#nieuws_content").html(data);		
				
	  }
    }); 		
}

statische_kaart_return = 0;
poi_return = 0;

function jongerenkaart_leesverder(id)
{
    $("#jongerenkaart_ervaring_leesmeer_popup").show();
	
    $.ajax(
    {
	  url:'/ajax/jongerenkaart_ervaring_content.php',
	  data:{
		id:id
	  },
	  dataType:"json",
	  success:function(data)
	  { 
		data = data.ervaring;
		$("#jongerenkaart_ervaring_leesmeer_titel").html(data.titel);
		$("#jongerenkaart_ervaring_leesmeer_beschrijving").html(data.beschrijving);
		
	  },
	  error:function(xhr,err,e){  }
    }); 
	
}

function goto_cultuurnota(id,parent)
{
    $(".popOver").hide();
    if (current_cat!=7) {
	  openScreen('ContCultuurNota');
    }
    cultuurnota_set_content(id);
    if (parent>0) {
	  $(".cultuurnota_paragraaf").slideUp("fast");
	  $("#cultuurnota_paragraaf_"+parent).slideDown("fast");
    }
}
	
function returnfrompoi()
{
    if (!poi_return) {
	  return;
    }
    if (poi_return=='nieuws') {
	  $(".popOver").hide();
	  $("#nieuws_popup").show();
	  if (!nieuws_selectie) {
		set_nieuws('3mnd');
	  }
	  poi_return=false;
	  return;
    } 
    if (poi_return>0) {
	  openScreen(n2o[poi_return]);
	  poi_return=false;
    }
	
}
function returnfromstatistische_kaart()
{
    if (!statische_kaart_return) {
	  return;
    }
    if (statische_kaart_return>0) {
	  openScreen(n2o[statische_kaart_return]);
	  statische_kaart_return=false;
    }
    return;	
}

function returntonieuws()
{
    if (uitgelicht_return) {
	  $("#nieuws_popup").show();
	  uitgelicht_return=false;
	  uitgelicht_kaart_return=false;
    }
    if (uitgelicht_kaart_return) {
	  $("#nieuws_popup").show();
	  uitgelicht_return=false;
	  uitgelicht_kaart_return=false;
    }	
    return;
}



function toon_op_kaart(target_id) 
{	
    $(".popOver").hide();
    gotohome();
    remove_overlay();
	
    if (!target_id) {
	  return;
    }
    if (!gmarkers[target_id].getPoint()) {
	  return;
    }
	
    poi_location = map.fromLatLngToContainerPixel(gmarkers[target_id].getPoint());
    offset=0;
    if (poi_location.y>450) {
	  offset = -0.05;
    }
    if (poi_location.y<40) {
	  offset = +0.25;
    }
    map.setCenter(new GLatLng(parseFloat(defaultLat+offset), parseFloat(defaultLon)), 9);
    addMarker(target_id);
    poiClick(target_id);
}

function statistische_kaart_set_content(id)
{
    statistische_kaart_id[current_cat] = id;
	
    s = $("#statistische_kaart_wrapper_"+current_cat+" .statistische_kaart_afbeelding_klein");
    if ($.browser.msie) 
    { 
	  s.css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='files/statistische_kaart/"+id+"/kaart_thumb1.png', enabled=true, sizingMethod=scale);");	
    }
    else
    {
	  s.css("background-image","url(/files/statistische_kaart/"+id+"/kaart_thumb1.png)");
    }
    $("#statistische_kaart_wrapper_"+current_cat+" .statistische_kaart_titel").html(statistische_kaart_titel[id]);

    if ($("#statistische_kaart_popup").css('display')!='none')
    {
	  $(".statistische_kaart_image_groot").hide();
	  $("#statistische_kaart_popup .huidignr").html($("#statistische_kaart_wrapper_"+current_cat+" .huidignr").html());
	  $("#statistische_kaart_popup .totaalnr").html($("#statistische_kaart_wrapper_"+current_cat+" .totaalnr").html());
	  $("#statistische_kaart_groot_titel").html(statistische_kaart_titel[id]);
	  $(".statistische_kaart_image_groot").show();
	  $("#statistische_kaart_image_groot").css("background-image","url(/files/statistische_kaart/"+id+"/kaart_klein.jpg)");
		
	  setPageTitle(statistische_kaart_titel[id]);
	
	  $.ajax(
	  {
		url:'/ajax/statistische_kaart_content.php',
		data:{
		    id:id
		},
		beforeSend :function() {
		    $("#statistische_kaart_groot_content").html('Laden...');
		}, 
		success:function(data)
		{ 				 
		    $("#statistische_kaart_groot_content").html(data);	 			
		},
		error:function(xhr,err,e){  }
	  }); 	
    }
}

poi_op_kaart_id = 0;
function poi_lees_verder(target_id)
{
    $("#poi_op_kaart_image_groot").css("background-image","none");
    poi_op_kaart_id = target_id; 
    $(".popOver").hide();
    $("#poi_op_kaart_popup").show();
    poi_op_kaart_set_content(target_id);
}

/// 

function poi_op_kaart_set_content(id)
{	
    $("#poi_op_kaart_groot_beschrijving").html('Laden...');
    $("#poi_op_kaart_image_groot").css("background-image","url(/images/load_big.gif)");

    $.ajax(
    {
	  url:'/ajax/uitgelicht_kaart_content.php',
	  data:{
		id:id
	  },
	  //		dataType:"json",
	  success:function(data)
	  { 
		data = data.split('\n');
		naam = data[0];
		beschrijving = data[2];
		beschrijving_kort = data[3];
		locatie = data[1];
		aantal_reacties = data[4];
		aantal_reacties_tekst = data[5];	
		imgs = data[6];
		imgs = imgs.split(",");
		poi_imgs[id]=imgs;
	
		$("#poi_op_kaart_popup_bg .opties").hide();
		$("#poi_op_kaart_groot_beschrijving").show();
		$("#poi_op_kaart_wrapper_"+current_cat+" .poi_op_kaart_beschrijving").html(beschrijving_kort);
		$("#poi_op_kaart_wrapper_"+current_cat+" .poi_op_kaart_foto").html('').css("background-image","url(/files/uitgeligcht_kaart/"+id+"/"+imgs[0]+"/250.jpg)");		
			
		cur_img = imgs[0];
			
		if (imgs.length>1)
		{
		// $("#poi_op_kaart_groot_vorige_afb").css("background-image","url(/images/buttons/182_l.gif)").css('cursor','pointer');
		//$("#poi_op_kaart_groot_volgende_afb").css("background-image","url(/images/buttons/182_r.gif)").css('cursor','pointer');					
		}
		else
		{
		//$("#poi_op_kaart_groot_vorige_afb").css("background-image","url(/images/buttons/182_l_disabled.gif)").css('cursor','default');
		//$("#poi_op_kaart_groot_volgende_afb").css("background-image","url(/images/buttons/182_r_disabled.gif)").css('cursor','default');
		}
			
		if (cur_img.substr(0,4)=="[yt=")
		{		
		    yt_code = cur_img.substr(4);
		    yt_code = yt_code.split("]")[0];
		    html = youtube_html(yt_code);
		    $("#poi_op_kaart_image_groot").css("background-image","none").html(html);
		}
		else
		{
		    $("#poi_op_kaart_image_groot").html('').css("background-image","url(/files/uitgelicht_kaart/"+id+"/"+cur_img+"/290.jpg)");
		}		

		$("#poi_op_kaart_groot_beschrijving").html(beschrijving);
		$("#poi_op_kaart_groot_naam").html(naam);
		$("#poi_op_kaart_popup_bg .aantalreacties").html(aantal_reacties_tekst);
		if (aantal_reacties<1) {
		    $("#poi_op_kaart_groot_reactielink .bekijk_reacties_link").hide();
		} 
		else {
		    $("#poi_op_kaart_groot_reactielink .bekijk_reacties_link").show();
		}
		setPageTitle(naam);
			
	  },
	  error:function(xhr,err,e){  }
    }); 
}

function poi_op_kaart_bekijkreacties()
{
    $("#poi_op_kaart_popup_bg .opties").hide();
    $("#poi_op_kaart_groot_reacties").show().load('/ajax/bekijkreacties.php?pagina=poi_op_kaart&type=l&id='+poi_op_kaart_id);
}

function poi_op_kaart_terugnaarartikel()
{
    $("#poi_op_kaart_popup_bg .opties").hide();
    $("#poi_op_kaart_groot_beschrijving").show();
}	

function poi_op_kaart_plaatsreactie()
{
    $("#poi_op_kaart_popup_bg .opties").hide();
    $("#poi_op_kaart_groot_plaatsreactie").show().load('/ajax/plaatsreactie.php?pagina=poi_op_kaart&type=l&id='+poi_op_kaart_id);
}

function poi_op_kaart_sendtoafriend()
{
    $("#poi_op_kaart_popup_bg .opties").hide();
    $("#poi_op_kaart_groot_sendtoafriend").show().load('/ajax/sendtoafriend.php?pagina=poi_op_kaart&type=l&id='+poi_op_kaart_id);
}

function uitgelicht_op_kaart_bekijkreacties()
{
    $("#uitgelicht_op_kaart_popup_bg .opties").hide();
    $("#uitgelicht_op_kaart_groot_reacties").show().load('/ajax/bekijkreacties.php?pagina=uitgelicht_op_kaart&type=l&id='+uitgelicht_op_kaart_id[current_cat]);
}

function uitgelicht_op_kaart_terugnaarartikel()
{
    $("#uitgelicht_op_kaart_popup_bg .opties").hide();
    $("#uitgelicht_op_kaart_groot_beschrijving").show();
}	

function uitgelicht_op_kaart_plaatsreactie()
{
    $("#uitgelicht_op_kaart_popup_bg .opties").hide();
    $("#uitgelicht_op_kaart_groot_plaatsreactie").show().load('/ajax/plaatsreactie.php?pagina=uitgelicht_op_kaart&type=l&id='+uitgelicht_op_kaart_id[current_cat]);
}

function uitgelicht_op_kaart_sendtoafriend()
{
    $("#uitgelicht_op_kaart_popup_bg .opties").hide();
    $("#uitgelicht_op_kaart_groot_sendtoafriend").show().load('/ajax/sendtoafriend.php?pagina=uitgelicht_op_kaart&type=l&id='+uitgelicht_op_kaart_id[current_cat]);
}


uitgelicht_op_kaart_id = 0;
uitgelicht_op_kaart_img_lijst = [];
uitgelicht_op_kaart_img = [];
uitgelicht_op_kaart_current_img = 0;

function uitgelicht_op_kaart_set_content(id)
{
    uitgelicht_op_kaart_id[current_cat] = id;
    $("#uitgelicht_op_kaart_groot_imageswitcher").show();

    ajax_set_url('uitgelicht-op-de-kaart/'+id+'/leesverder');
	
    $.ajax(
    {
	  url:'/ajax/uitgelicht_kaart_content.php',
	  data:{
		id:id
	  },
	  beforeSend :function() {
		$("#uitgelicht_op_kaart_groot_beschrijving").html('Laden...'); 
		$("#uitgelicht_op_kaart_image_groot").css("background-image","url(/images/load_big.gif)");
		$("#uitgelicht_op_kaart_popup_bg .opties").hide();
		$("#uitgelicht_op_kaart_groot_beschrijving").show();
	  }, 
	  success:function(data)
	  { 			
		data = data.split('\n');
		naam = data[0];
		beschrijving = data[2];
		beschrijving_kort = data[3];
		locatie = data[1];
		aantal_reacties = data[4];
		aantal_reacties_tekst = data[5];	
		imgs = data[6];
		imgs = imgs.split(",");
		cur_img=imgs[0];			

		setPageTitle(naam);
		//preload
		t='';
		for (i=0;i<imgs.length;i++) 

		{
			  t += '<img src="/files/uitgelicht_kaart/'+id+'/'+imgs[i]+'/250.jpg"><img src="/files/uitgelicht_kaart/'+id+'/'+imgs[i]+'/290.jpg">';
		    }
		//$("#preload").html(t);
		//eind preload
		if (cur_img.substr(0,4)=="[yt=")
		{		
		    yt_code = cur_img.substr(4);
		    yt_code = yt_code.split("]")[0]; 
		    $("#uitgelicht_op_kaart_wrapper_"+current_cat+" .uitgelicht_op_kaart_foto").css("background-image","url(http://i1.ytimg.com/vi/"+yt_code+"/0.jpg)").css("background-color","#000").html('<img src="/gfx/youtube.gif" class="cursorpointer" onclick="uitgelicht_op_kaart_leesverder()" alt="Klik om deze video af te spelen"/>');

		}
		else
		{
		    $("#uitgelicht_op_kaart_wrapper_"+current_cat+" .uitgelicht_op_kaart_foto").html('').css("background-image","url(/files/uitgelicht_kaart/"+id+"/"+imgs[0]+"/250.jpg)");
		}

		$("#uitgelicht_op_kaart_wrapper_"+current_cat+" .uitgelicht_op_kaart_locatie").html(naam);
		$("#uitgelicht_op_kaart_wrapper_"+current_cat+" .uitgelicht_op_kaart_beschrijving").html(beschrijving_kort);

		
		if ($("#uitgelicht_op_kaart_popup").css('display')=='block')
		{

				
		    if (cur_img.substr(0,4)=="[yt=")
		    {	
			  yt_code = cur_img.substr(4);
			  yt_code = yt_code.split("]")[0]; 
			  html = youtube_html(yt_code);
			  $("#uitgelicht_op_kaart_image_groot").css("background-image","none").html(html);
		    }
		    else
		    {
			  $("#uitgelicht_op_kaart_image_groot").html('').css("background-image","url(/files/uitgelicht_kaart/"+id+"/"+cur_img+"/290.jpg)");
		    }
				
		    $("#uitgelicht_op_kaart_groot_vorige_afb,#uitgelicht_op_kaart_groot_volgende_afb").show();
				
		    $("#uitgelicht_op_kaart_groot_naam").html(naam);
		    $("#uitgelicht_op_kaart_popup_bg .aantalreacties").html(aantal_reacties_tekst);
		    if (aantal_reacties<1) {
			  $("#uitgelicht_op_kaart_popup_bg .bekijk_reacties_link").hide();
		    } 
		    else {
			  $("#uitgelicht_op_kaart_popup_bg .bekijk_reacties_link").show();
		    }
				
		    uitgelicht_op_kaart_img_lijst[current_cat] = imgs; 
		    uitgelicht_op_kaart_img[current_cat] = imgs[0];
				
		    if (uitgelicht_op_kaart_img_lijst[current_cat].length>1)
		    {
			  $("#uitgelicht_op_kaart_groot_vorige_afb").css("background-image","url(/images/buttons/182_l.gif)").css('cursor','pointer');
			  $("#uitgelicht_op_kaart_groot_volgende_afb").css("background-image","url(/images/buttons/182_r.gif)").css('cursor','pointer');					
		    }
		    else
		    {
			  $("#uitgelicht_op_kaart_groot_vorige_afb").css("background-image","url(/images/buttons/182_l_disabled.gif)").css('cursor','default');
			  $("#uitgelicht_op_kaart_groot_volgende_afb").css("background-image","url(/images/buttons/182_r_disabled.gif)").css('cursor','default');
		    }
		    $("#uitgelicht_op_kaart_groot_beschrijving").html(beschrijving);
				
		    if(current_cat>0) {
			  $("#uitgelicht_op_kaart_groot_imageswitcher").show();
		    } else {
			  $("#uitgelicht_op_kaart_groot_imageswitcher").hide();
		    }
		}
			
	  },
	  error:function(xhr,err,e){  }
    }); 
		
}

function set_dimensions()
{
    body_width = $(window).width();
    body_height = $(window).height();	
    a = $(".mainContainer").offset();
    offset_left = a.left;
    if (offset_left<1) {
	  offset_left=0;
    }
    offset_top = a.top;
    if (offset_top<1) {
	  offset_top=0;
    }
	
    $("#googleMap").css('width',body_width+'px').css('height',body_height+'px').css('margin-left','-'+offset_left+'px').css('margin-top','-'+offset_top+'px');

    popup_offset_left = a.left+426;
    popup_offset_top = a.top+532;
//	$(".mainContainer").css('margin-left',popup_offset_left+'px').css('margin-top',popup_offset_top+'px')
	
	
//	left = 226
// top = 132
}

var infowindow_x = 0;
var infowindow_y = 0;

function resize_infowindow()
{
    /*	a = $("#legenda").offset();
	offset_left = a.left;
	offset_top = a.top;	
	body_width = $("body").width();
	body_height = $("body").height();
	
	if (body_width<1036) { body_width = 1036; }
	if (body_height<655) { body_height = 655; }	
*/
    //	popup_offset_left = Math.round(body_width/2)-464;
    //	popup_offset_top = Math.round(body_height/2)-201;


    this_location = map.fromLatLngToContainerPixel(map.getCenter());
    var difference_x,difference_y,pixelLocation,pixelLocation_x,pixelLocation_y;
	
    pixelLocation = map.fromLatLngToContainerPixel(gmarkers[openMarker].getPoint());
    pixelLocation_x = pixelLocation.x - 268;
    pixelLocation_y = pixelLocation.y - 316;
	
    gmap_height = $("#googleMap").height();
    gmap_half = Math.round(gmap_height/2);	
	
    difference_x = this_location.x - pixelLocation.x+120;
    difference_y = this_location.y - pixelLocation.y-gmap_half+500;

	
    //	if (jQuery.browser.msie) {  difference_y -= 100; }
	
    if (map) {
	  map.panBy(new GSize(difference_x,difference_y));
    }
	
	
    //infowindow_x = popup_offset_left;
    //infowindow_y = popup_offset_top + 240;	
	
    //$("#testdiv").css("left",location_x+"px").css("top",location_y+"px");
			
    $(".mapPop,.mapPopJong,.mapPopPijl").css('left',pixelLocation_x+'px').css('top',pixelLocation_y+'px');

}

function youtube_html(code,width,height)
{
    width=289;
    height=182;
    color1='0xCCE3F5';
    color2='0xa5d0ef'; 
    return '<object width="'+width+'" height="'+height+'"><param name="movie" value="http://www.youtube-nocookie.com/v/'+code+'&hl=nl&fs=1&rel=0&hl=nl&fs=1&color1='+color1+'&color2='+color2+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/'+code+'&hl=nl&fs=1&rel=0&hl=nl&fs=1&color1='+color1+'&color2='+color2+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+width+'" height="'+height+'"></embed></object>';
}


function poi_volgende_afb(target_id)
{
    lijst = poi_imgs[target_id];
    if (!lijst) {
	  return;
    }
    cur_img = poi_imgs_cur_id;
	
    cur_pos = lijst.indexOf(cur_img);
    if (cur_pos<0) {
	  cur_pos = 0;
    }
	
    if (lijst[cur_pos+1]) {
	  cur_img = lijst[cur_pos+1];
    } else {
	  cur_img = lijst[0];
    }
    poi_imgs_cur_id = cur_img;

    if (cur_img.substr(0,4)=="[yt=")
    {		
	  yt_code = cur_img.substr(4);
	  yt_code = yt_code.split("]")[0]; 
	  html = youtube_html(yt_code);
	  $("#poi_foto").css("background-image","url(http://i1.ytimg.com/vi/"+yt_code+"/0.jpg)").css("background-color","#000").html('<img src="/gfx/youtube.gif" class="cursorpointer" onclick="poi_lees_verder('+target_id+')" alt="Klik om deze video af te spelen"/>');
	  if ($("#poi_op_kaart_popup").css("display")=="block") {
		$("#poi_op_kaart_image_groot").css("background-image","none").html(html);
	  }

    }
    else
    {			
	  $("#poi_op_kaart_image_groot").css("background-color","#F4F4F4").css("background-image","url(/files/uitgelicht_kaart/"+target_id+"/"+cur_img+"/290.jpg)").html('');
	  $("#poi_foto").css("background-image","url(/files/uitgelicht_kaart/"+target_id+"/"+cur_img+"/250.jpg)").html('');
    }

}

function poi_vorige_afb(target_id)
{
    lijst = poi_imgs[target_id];
    if (!lijst) {
	  return;
    }
    cur_img = poi_imgs_cur_id;
    cur_pos = lijst.indexOf(cur_img);
    if (cur_pos<0) {
	  cur_pos = 0;
    }
    if (lijst[cur_pos-1]) {
	  cur_img = lijst[cur_pos-1];
    } else {
	  cur_img = lijst[lijst.length-1];
    }
    poi_imgs_cur_id = cur_img;

    if (cur_img.substr(0,4)=="[yt=")
    {		
	  yt_code = cur_img.substr(4);
	  yt_code = yt_code.split("]")[0]; 
	  html = youtube_html(yt_code);
	  $("#poi_foto").css("background-image","url(http://i1.ytimg.com/vi/"+yt_code+"/0.jpg)").css("background-color","#000").html('<img src="/gfx/youtube.gif" class="cursorpointer" onclick="poi_lees_verder('+target_id+')" alt="Klik om deze video af te spelen"/>');
	  if ($("#poi_op_kaart_popup").css("display")=="block") {
		$("#poi_op_kaart_image_groot").css("background-image","none").html(html);
	  }
	  $("#poi_op_kaart_image_groot").css("background-image","url(/files/uitgelicht_kaart/"+target_id+"/"+cur_img+"/290.jpg)");
    }
    else
    {			
	  $("#poi_op_kaart_image_groot").css("background-image","url(/files/uitgelicht_kaart/"+target_id+"/"+cur_img+"/290.jpg)").html('');
	  $("#poi_foto").css("background-color","#F4F4F4").css("background-image","url(/files/uitgelicht_kaart/"+target_id+"/"+cur_img+"/250.jpg)").html('');
    }
}


function set_img_list(imglist)
{
    if (imglist.length>1)
    {
	  $(".poi_vorige_afb").show();
	  $(".poi_volgende_afb").show();		
	  $(".poi_vorige_afb_disabled").hide();	
	  $(".poi_volgende_afb_disabled").hide();		
	  $("#poi_op_kaart_groot_vorige_afb").css("background-image","url(/images/buttons/182_l.gif)").css('cursor','pointer');
	  $("#poi_op_kaart_groot_volgende_afb").css("background-image","url(/images/buttons/182_r.gif)").css('cursor','pointer');			
    }
    else
    {
	  $(".poi_vorige_afb").hide();
	  $(".poi_volgende_afb").hide();
	  $(".poi_vorige_afb_disabled").show();	
	  $(".poi_volgende_afb_disabled").show();
	  $("#poi_op_kaart_groot_vorige_afb").css("background-image","url(/images/buttons/182_l_disabled.gif)").css('cursor','default');
	  $("#poi_op_kaart_groot_volgende_afb").css("background-image","url(/images/buttons/182_r_disabled.gif)").css('cursor','default');	
    }
	
    poi_imgs_cur_id = imglist[0];
}


function poi_get_imgs(id)
{
    if (poi_imgs[id]) {
	  set_img_list(poi_imgs[id]);
	  return;
    }
    $.ajax(
    {
	  url:'/ajax/uitgelicht_kaart_imgs.php',
	  data:{
		id:id
	  },
	  success:function(data) 
	  { 
		poi_imgs[id] = data.split(",");	
		if (poi_imgs[id]) {
		    set_img_list(poi_imgs[id]);
		}
	  },
	  error:function(xhr,err,e){  }
    });
}


uitgelicht_id = 0;
uitgelicht_img_lijst = [];
uitgelicht_img = [];
uitgelicht_current_img = 0;

function uitgelicht_set_content(id)
{
    uitgelicht_id[current_cat] = id;
    $("#uitgelicht_popup .totaalnr").html($("#uitgelicht_wrapper_"+current_cat+" .totaalnr").html());
    $("#uitgelicht_popup .huidignr").html($("#uitgelicht_wrapper_"+current_cat+" .huidignr").html()); 
    
    ajax_set_url("uitgelicht/"+id+'/leesverder');

    $("#uitgelicht_groot_imageswitcher").show();		
    $.ajax(
    {
	  url:'/ajax/uitgelicht_content.php',
	  data:{
		id:id
	  },
	  beforeSend :function() {
		$("#uitgelicht_groot_beschrijving").html('Laden...'); 
		$("#uitgelicht_image_groot").css("background-image","url(/images/load_big.gif)");
		$("#uitgelicht_popup_bg .opties").hide();
		$("#uitgelicht_groot_beschrijving").show();
	  }, 
	  success:function(data)
	  { 			
		data = data.split('\n');
		naam = data[0];
		beschrijving = data[1];
		beschrijving_kort = data[2];
		aantal_reacties = data[3];
		aantal_reacties_tekst = data[4];			
		imgs = data[5];
		imgs = imgs.split(",");
		//preload
		t='';
		for (i=0;i<imgs.length;i++) 
		{
		    t += '<img src="/files/uitgelicht/'+id+'/'+imgs[i]+'/250.jpg"><img src="/files/uitgelicht/'+id+'/'+imgs[i]+'/290.jpg">';
		}

		setPageTitle(naam);
		$("#uitgelicht_wrapper_"+current_cat+" .uitgelicht_naam").html(naam);
		$("#uitgelicht_wrapper_"+current_cat+" .uitgelicht_beschrijving").html(beschrijving_kort);
		$("#uitgelicht_wrapper_"+current_cat+" .uitgelicht_foto").css("background-image","url(/files/uitgelicht/"+id+"/"+imgs[0]+"/216.jpg)");
			
			
		if ($("#uitgelicht_popup").css('display')=='block')
		{
		    uitgelicht_terugnaarartikel();
		    $("#uitgelicht_groot_beschrijving").show();
		    $("#uitgelicht_image_groot").css("background-image","url(/files/uitgelicht/"+id+"/"+imgs[0]+"/290.jpg)");
		    $("#uitgelicht_groot_vorige_afb,#uitgelicht_groot_volgende_afb,#uitgelicht_groot_reactielink").show();
				
		    $("#uitgelicht_groot_beschrijving").html(beschrijving);
		    $("#uitgelicht_groot_naam").html(naam);
		    $("#uitgelicht_popup_bg .aantalreacties").html(aantal_reacties_tekst);
		    if (aantal_reacties<1) {
			  $("#uitgelicht_popup_bg .bekijk_reacties_link").hide();
		    } 
		    else {
			  $("#uitgelicht_popup_bg .bekijk_reacties_link").show();
		    }
				
				
		    uitgelicht_img_lijst[current_cat] = imgs; 
		    uitgelicht_current_img[current_cat] = imgs[0];

		    if (uitgelicht_img_lijst[current_cat].length>1)
		    {
			  $("#uitgelicht_groot_vorige_afb").css("background-image","url(/images/buttons/182_l.gif)").css('cursor','pointer');
			  $("#uitgelicht_groot_volgende_afb").css("background-image","url(/images/buttons/182_r.gif)").css('cursor','pointer');					
		    }
		    else
		    {
			  $("#uitgelicht_groot_vorige_afb").css("background-image","url(/images/buttons/182_l_disabled.gif)").css('cursor','default');
			  $("#uitgelicht_groot_volgende_afb").css("background-image","url(/images/buttons/182_r_disabled.gif)").css('cursor','default');
		    }
				
		    if(current_cat>0) {
			  $("#uitgelicht_groot_imageswitcher").show();
		    } else {
			  $("#uitgelicht_groot_imageswitcher").hide();
		    }
		}
			
	  },
	  error:function(xhr,err,e){  }
    }); 
}

function plaats_reactie()
{
    naam = $("#plaats_reactie_form input[name=naam]").val();
    if (!naam) {
	  alert('Vul uw naam in');
	  return false;
    }
    bericht = $("#plaats_reactie_form textarea[name=bericht]").val();
    if (!bericht) {
	  alert('Vul een bericht in');
	  return false;
    }
	
    this_id = $("#plaats_reactie_form input[name=id]").val();
    this_type = $("#plaats_reactie_form input[name=type]").val();	
    this_pagina = $("#plaats_reactie_form input[name=pagina]").val();
	
    $("#reactiesubmit_laden").show();
    $("#reactiesubmit_opslaan").hide();
	
    $.post("/ajax/reactie_submit.php",{
	  id:this_id,
	  type:this_type,
	  bericht:bericht,
	  naam:naam
    },function(data) 

    {	
		$("#plaats_reactie_form input[name=naam]").val('');
		$("#plaats_reactie_form textarea[name=bericht]").val('');
		if (this_pagina=='uitgelicht') {
		    uitgelicht_bekijkreacties();
		}
		if (this_pagina=='poi_op_kaart') {
		    poi_op_kaart_bekijkreacties();
		}
		if (this_pagina=='uitgelicht_op_kaart') {
		    uitgelicht_op_kaart_bekijkreacties();
		}
		alert('Het bericht is opgeslagen');
		$("#reactiesubmit_laden").hide();
		$("#reactiesubmit_opslaan").show();
	  });
}

function verstuur_sendtoafriend()
{
    naam = $("#sendtoafriend_form input[name=naam]").val();
    if (!naam) {
	  alert('Vul uw naam in');
	  return false;
    }
    afzender = $("#sendtoafriend_form input[name=afzender]").val();
    if (!afzender) {
	  alert('Vul uw e-mail adres in');
	  return false;
    }
    if (!validate_email(afzender)) {
	  alert('Vul een geldig e-mail adres bij afzender in');
	  return false;
    }
    geadresseerde = $("#sendtoafriend_form input[name=geadresseerde]").val();
    if (!geadresseerde) {
	  alert('Vul een geadresseerde in');
	  return false;
    }
    if (!validate_email(geadresseerde)) {
	  alert('Vul een geldig e-mail adres bij geadresseerde in');
	  return false;
    }
    bericht = $("#sendtoafriend_form textarea[name=bericht]").val();
    if (!bericht) {
	  alert('Vul een bericht in');
	  return false;
    }
	
    this_id = $("#sendtoafriend_form input[name=id]").val();
    this_type = $("#sendtoafriend_form input[name=type]").val();	
    this_pagina = $("#sendtoafriend_form input[name=pagina]").val();
	
    $("#sendtoafriend_load").show();
	
    $.post("/ajax/sendtoafriend_submit.php",{
	  id:this_id,
	  type:this_type,
	  bericht:bericht,
	  naam:naam,
	  afzender:afzender,
	  geadresseerde:geadresseerde
    },function(data) 

    {	
		$("#sendtoafriend_form input[name=naam]").val('');
		$("#sendtoafriend_form textarea[name=afzender]").val('');
		$("#sendtoafriend_form textarea[name=geadresseerde]").val('');
		$("#sendtoafriend_form textarea[name=bericht]").val('');
		if (this_pagina=='uitgelicht') {
		    uitgelicht_terugnaarartikel();
		}
		if (this_pagina=='poi_op_kaart') {
		    poi_op_kaart_terugnaarartikel();
		}
		if (this_pagina=='uitgelicht_op_kaart') {
		    uitgelicht_op_kaart_terugnaarartikel();
		}
		$("#sendtoafriend_load").hide();
		alert('Het bericht is verzonden.');
	  });
}



function uitgelicht_bekijkreacties()
{
    $("#uitgelicht_popup_bg .opties").hide();
    $("#uitgelicht_groot_reacties").show().load('/ajax/bekijkreacties.php?pagina=uitgelicht&type=u&id='+uitgelicht_id[current_cat]);
}

function uitgelicht_terugnaarartikel()
{
    $("#uitgelicht_popup_bg .opties").hide();
    $("#uitgelicht_groot_beschrijving").show();
}	

function uitgelicht_plaatsreactie()
{
    $("#uitgelicht_popup_bg .opties").hide();
    $("#uitgelicht_groot_plaatsreactie").show().load('/ajax/plaatsreactie.php?pagina=uitgelicht&type=u&id='+uitgelicht_id[current_cat]);
}

function uitgelicht_sendtoafriend()
{
    $("#uitgelicht_popup_bg .opties").hide();
    $("#uitgelicht_groot_sendtoafriend").show().load('/ajax/sendtoafriend.php?pagina=uitgelicht&type=u&id='+uitgelicht_id[current_cat]);
}



//jongerenkaart
function toggle_reacties()
{
    if ($(".closedReactie").css('display')!='none')
    {
	  $(".closedReactie").hide();
	  $(".openReactie").show();
	  $("#reactie_content").load("/ajax/jongerenkaart_reacties.php?id="+openMarker);	
    }
    else
    {
	  $(".closedReactie").show();
	  $(".openReactie").hide();		
    }
}


function statistiek_overige_set_content(id)
{
    statistiek_overige_id[current_cat] = id;
	
    s = $("#statistiek_overige_wrapper_"+current_cat+" .statistiek_overige_afbeelding_klein");
    if ($.browser.msie) 
    { 
	  s.css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='files/statistiek_overige/"+id+"/kaart_thumb1.png', enabled=true, sizingMethod=scale);");	
    }
    else
    {
	  s.css("background-image","url(/files/statistiek_overige/"+id+"/kaart_thumb1.png)");
    }
    $("#statistiek_overige_wrapper_"+current_cat+" .statistiek_overige_titel").html(statistiek_overige_titel[id]);
    setPageTitle(statistiek_overige_titel[id]);

    if ($("#statistiek_overige_popup").css('display')!='none')
    {
	  $(".statistiek_overige_image_groot").hide();
	  $("#statistiek_overige_popup .huidignr").html($("#statistiek_overige_wrapper_"+current_cat+" .huidignr").html());
	  $("#statistiek_overige_popup .totaalnr").html($("#statistiek_overige_wrapper_"+current_cat+" .totaalnr").html());
	  $("#statistiek_overige_groot_titel").html(statistiek_overige_titel[id]);
	  $("#statistiek_overige_image_groot_muisover").hide();
		
		
	  $.ajax(
	  {
		url:'/ajax/statistiek_overige_content.php',
		data:{
		    id:id
		},
		beforeSend :function() {
		    $("#statistiek_overige_groot_content").html('Laden...');
		}, 
		success:function(data)
		{ 
		    $(".statistiek_overige_image_groot").show();
		    $("#statistiek_overige_image_groot").css("background-image","url(/files/statistiek_overige/"+id+"/kaart_klein.jpg)");
		    $("#statistiek_overige_image_groot_muisover").css("background-image","url(/files/statistiek_overige/"+id+"/kaart_klein.jpg)");						

		    $("#statistiek_overige_groot_content").html(data);				
		},
		error:function(xhr,err,e){  }
	  }); 	
    }
}


function wistudat_set_content(id)
{
    $.ajax(
    {
	  url:'/ajax/wistudat_content.php',
	  dataType:"json",
	  success:function(data)
	  { 
		data = data.wistudat;
		$("#wistudat_wrapper_"+current_cat+" .wistudat_weetje").html(data.weetje);
		$("#wistudat_wrapper_"+current_cat+" .wistudat_link").attr("href",data.url);
	  },
	  error:function(xhr,err,e){  }
    }); 
	
}

cultuurnota_id = false;
function cultuurnota_set_content(id,expand)
{	
    if (expand)
    {

	  if ($("#cultuurnota_hoofdstuk_"+id).hasClass('haschild'))
	  {
		$(".cultuurnota_paragraaf").slideUp("fast");
		$(".haschild").css('background-image','url(/images/cultuurnota_ingeklapt.gif)');
			
		if ($("#cultuurnota_paragraaf_"+id).css("display")=='none')
		{

		    $("#cultuurnota_paragraaf_"+id).slideDown("fast");
		    $("#cultuurnota_hoofdstuk_"+id).css('background-image','url(/images/cultuurnota_uitgeklapt.gif)');
		}
	  }
    }

    if (id==cultuurnota_id) {
	  return;
    }
    cultuurnota_id = id;
	
    $.ajax(
    {
	  url:'/ajax/cultuurnota_content.php',
	  data:{
		id:id
	  },
	  success:function(data)
	  { 
		setPageTitle('Cultuurnota achtergrond');
		$("#cultuurnota_tekst,#print").html(data);
		if (zoekstring!='') { 
		    $('#cultuurnota_tekst').each(function() {
			  $.highlight(this, zoekstring.toUpperCase());
		    });
		}
	  },
	  error:function(xhr,err,e){  }
    }); 
}

accenten_ids = [];
accenten_id = [];
accenten_ids[1]=[13,1];
accenten_ids[2]=[2,15,16];
accenten_ids[3]=[3,14,19];
accenten_ids[4]=[4,8];
accenten_ids[5]=[5,10,17];
accenten_ids[6]=[6,12];
for (i=1;i<7;i++) {
    accenten_id[i]=accenten_ids[i];
}

function accenten_set_content(id)
{
    cur_pos = 0;
    aantal_accenten =1 ;
    if (current_cat>0) {
    
	  accenten_id[current_cat] = id;
    
	  lijst = accenten_ids[current_cat];
	  aantal_accenten = lijst.length;
   
	  for (i=1;i<4;i++) {
		if (accenten_ids[current_cat][i]==id) {
		    cur_pos = i;
		    break;
		}
	  }
    }
    ajax_set_url("accent/"+id);
    $("#accent_popup_imageswitcher .huidignr").html(cur_pos+1);
    $("#accent_popup_imageswitcher .totaalnr").html(aantal_accenten);
   
    $("#accent_popup_image_groot").css("background-image","url(/files/accenten/"+id+".jpg)");
    $("#accent_popup_titelimg").css("background-image","url(/images/cat_titels/popup_titel_"+id+".gif)");
	
    $.ajax(
    {
	  url:'/ajax/accenten_content.php',
	  data:{
		id:id
	  },
	  beforeSend :function() {
		$("#accent_popup_beschrijving").html('Laden...');
	  }, 
	  success:function(data)
	  { 
		$('body').css('cursor', 'default');
		$("#accent_popup_beschrijving").html(data);
		setPageTitle('Accent: '+accent_title[id]);
	  },
	  error:function(xhr,err,e){  }
    }); 
		
}

function print_div(target)
{
    $("#print").html($("#"+target).html());
    window.print();	
}

function cultuurervaring_close()
{
    $("#disableMap").show();
    $("#cultuurervaring").hide();
}

function cultuurervaring_popup()
{
    $("#cultuurervaring").show();
    if (GBrowserIsCompatible()) 
    {
	  poi_map = new GMap2(document.getElementById("addPoiMap"));
	  poi_map.setMapType(G_PHYSICAL_MAP);
	  poi_geocoder = new GClientGeocoder();
	  poi_map.setCenter(new GLatLng(52.380629,4.762573), 7);
				
	  // Tijdelijk de standaard controls
	  poi_map.addControl(new GSmallMapControl());
		
	  // Add scroll voor mouse wheel
	  poi_map.enableScrollWheelZoom();
    }
}

function addPoiGetLocation()
{
    if ($('#toevoegen_poi_adres').val().length>0)
    {
	  showAddress($('#toevoegen_poi_adres').val());
    }
}
	
	
function ajaxFileUpload()
{
    $("#cultuurervaring_opslaan").show();
    $.ajaxFileUpload
    (
    {
	  url:'/ajax/jongerenkaart_foto_uploaden.php',
	  secureuri:false,
	  fileElementId:'toevoegen_poi_foto',
	  dataType: 'json',
	  success: function (data, status)
	  {
		//$("#file_upload_loading").hide();
				
		if(typeof(data.error) != 'undefined')
		{
		    if(data.error != '')
		    {
			  alert(data.error);
		    }
		    else
		    {
			  $("#disableMap").show();
			  document.getElementById('cultuurervaring_form').reset()
			  $("#cultuurervaring_opslaan").hide();
			  $("#cultuurervaring").hide();
			  $("#toevoegen_poi_foto").val('');
			  alert('Je inzending is opgeslagen, deze zal na goedkeuring worden gepubliceerd');
		    }
		}
				
	  },
	  error: function (data, status, e)
	  {
		//$("#file_upload_loading").hide();		
		alert('Er is een fout opgetreden, mogelijk is het bestand te groot of wordt het bestandsformaat niet ondersteund');
	  }
    }
    )
	
    return false;
}								


function uitgelicht_leesverder(id)
{
    $("#uitgelicht_image_groot").css("background-image","none");
		
    $(".popOver").hide();
    $("#uitgelicht_popup").show();
    
    uitgelicht_set_content(id);
}
	  
function statistiek_overige_bekijk(id)  { 
    if (!id) {
	  alert('Er kan geen kaart worden gevonden');
	  return;
    }
    $(".popOver").hide();
    $("#statistiek_overige_popup").show();
    statistiek_overige_set_content(id);
}
    
function statistische_kaart_bekijk(id)
{
    if (!id) {
	  alert('Er kan geen kaart worden gevonden');
	  return;
    }
    $(".popOver").hide();
    $("#statistische_kaart_popup").show(); 
    statistische_kaart_set_content(id);
		    
}    

function accent_bekijk(id)
{
    $(".popOver").hide();
    $("#accent_popup").show();
    accenten_set_content(id);
}

function pageview()
{
   setTimeout(function(){
	 url = document.location;
	 var hash = new String(document.location).split("#")[1];
	 var url = '/#'+hash;
	  pageTracker._trackPageview(url);
    },1000);
}


