var adressen = [ 
	'', '', '', 
	'alg', 'Algemeen', 'ingrid.goor@derietpluim.nl,anita.visser@derietpluim.nl',
	'12a', 'Groep 1/2a Patrice/Ank', 'ank.rijnaard@derietpluim.nl,patrice.goossens@derietpluim.nl', 
	'12b', 'Groep 1/2b Janneke', 'janneke.brouwer@derietpluim.nl', 
	'12c', 'Groep 1/2c Celine', 'celine.kronenburg@derietpluim.nl', 
	'12d', 'Groep 1/2d Henny/Yvonne', 'henny.berg@derietpluim.nl,yvonne.erp@derietpluim.nl', 
	'12e', '', '', 
	'3a', 'Groep 3a Andrea/Sanne', 'andrea.dodebier@derietpluim.nl,sanne.teesink@derietpluim.nl', 
	'3b', 'Groep 3b Neelke', 'neelke.katwijk@derietpluim.nl', 
	'3c', 'Groep 3c Marlies/Loes', 'marlies.pijnenburg@derietpluim.nl,loes.kuijeren@derietpluim.nl', 
	'4a', 'Groep 4a Laura/Carolien', 'laura.koning@derietpluim.nl,carolien.dalsum@derietpluim.nl', 
	'4b', 'Groep 4b Jozee/Marie-Jose/Marij', 'jozee.verberne@derietpluim.nl,mariejose.veer@derietpluim.nl,laura.koning@derietpluim.nl', 
	'5a', 'Groep 5a Marije', 'marije.gilse@derietpluim.nl', 
	'5b', 'Groep 5b Bart', 'bart.voort@derietpluim.nl', 
	'5c', 'Groep 5c Anke', 'anke.swinkels@derietpluim.nl', 
	'6a', 'Groep 6a Ton/Gemma/Sanne', 'ton.overbruggen@derietpluim.nl,gemma.eerdmans@derietpluim.nl,sanne.teesink@derietpluim.nl', 
	'6b', 'Groep 6b Inge/Lenneke', 'inge.koelink@derietpluim.nl,lenneke.wiel@derietpluim.nl', 
	'6c', 'Groep 6c Irene/Sonja', 'irene.oord@derietpluim.nl,sonja.holleman@derietpluim.nl', 
	'7a', 'Groep 7a Peter', 'peter.groot@derietpluim.nl', 
	'7b', 'Groep 7b Toine/Marijke', 'toine.kerkhof@derietpluim.nl,marijke@derietpluim.nl', 
	'7c', 'Groep 7c Ralf', 'ralf.bloemers@derietpluim.nl', 
	'8a', 'Groep 8a Harold', 'harold.sweers@derietpluim.nl', 
	'8b', 'Groep 8b Marc/Carolien', 'marc.strik@derietpluim.nl,carolien.dalsum@derietpluim.nl', 
	'8c', 'Groep 8c Rogier/Marijke', 'rogier.dommelen@derietpluim.nl,marijke@derietpluim.nl', 
	'', '', ''
];
var startinput = "Klik hierboven op een locatie en vink de groep van uw kind aan.";
var noinput = "Geen groep geselecteerd. Vink hierboven de groep van uw kind aan.";
var goodinput = "Deze e-mail wordt gestuurd naar: ";
var extramails;

$(document).ready(function(){
	$("p:empty").remove();
	
	$("#container-center a").currentPage();
	$("#catdisplay").html(startinput);
	
	
	// ZiekmeldForm
	if ( $('#ZiekmeldForm').length ) {
		extramails = adressen[(jQuery.inArray('alg', adressen)+2)];
		$("#to").val(adressen[(jQuery.inArray('alg', adressen)+2)]);
		//if (window.console) console.log(extramails);
		$('.groepen').hide();
		$("a.school").toggle(function(){
			$(this).addClass("active"); 
			}, function () {
			$(this).removeClass("active");
		});
			
		$("a.school").click(function(){
			$(this).next(".groepen").slideToggle("slow,");
		});
		
		$('.groepen input').map(
			function(){
				t = $(this).parent().closest('label').find('span').text();
				u = $(this).val();
				//if (window.console) console.log(t+ " " + u);
				var pos = jQuery.inArray($(this).val(), adressen);
				$(this).parent().closest('label').find('span').text(adressen[pos+1]);
			}
		);
		
		$("#ZiekmeldForm input:checkbox").click(function(){
			var arr=$('#ZiekmeldForm input:checkbox:checked').map(function() {
				//return $(this).val();
				var pos = jQuery.inArray($(this).val(), adressen);
				return adressen[pos+2];
			}).get();
			
			//alert(arr);
			if(arr=="") {
				$("#catdisplay").html(''+noinput+'&nbsp;');
				arr=adressen[(jQuery.inArray('alg', adressen)+2)];
				$("#to").val(extramails);
			} else {
				$("#catdisplay").html('&nbsp;');
				$("#catdisplay").html(goodinput+arr.toString().replace(/,/g, ', ')+", "+extramails.toString().replace(/,/g, ', ')+'.');
				$("#to").val(arr+","+extramails);
			}
			
			//if (window.console) console.log($("#to").val());
		});
	}
	
	
	
	$("a.thumblink").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'easingIn'		:	'easeInOutExpo',
		'easingOut'		:	'easeInExpo',
		'speedIn'		:	700, 
		'speedOut'		:	600, 
		'overlayShow'	:	false,
		'hideOnContentClick':true,
		'margin'		:	20,
		'padding'		:	5
	});
	//gcalbig
	$("a#gcallink, #gcal").fancybox({
		'type'			:	'iframe',
		'width'			:	920,
		'height'		:	($(window).height()-10)
	});
	$(".diashow").fancybox({
		'type'			:	'iframe',
		'overlayColor'	:	'#000',
		'overlayOpacity':	'0.9',
		'width'			:	($(window).width()-30),
		'height'		:	($(window).height()-30),
		'onStart'		:	function() {$("#fancybox-content").css({"border-color": "#000"});},
		'onClosed'		:	function() {$("#fancybox-content").css({"border-color": "#FFF"});}
	});
	$('a[href*="player.vimeo"]').fancybox({
		'type'			:	'iframe',
		'width'			:	640,  //960
		'height'		:	360   //540
	});
	
	
	// Aparte opmaak voor paging bij zoekresultaten
	$('.paging1:eq(1)').addClass('bottonpaging');
});


function borderblack() {
	$("#fancybox-content").css({"border-color": "#000"});
}







// jQuery plugin for setting the class of a particular element to "current" based on the current page.
// Useful for navigation menus that are part of a server side include for the whole site.
//
// By Rob Watts, http://tractionsys.com
// Version 1.2, April 25, 2011
// Provided under the MIT license. Feel free to use it however you like.
//
// Example:
// $("ul.nav a").currentPage();
//
// To override defaults, pass in a defaults object:
// $("ul.nav a").currentPage({
//    attr: "href",
//    defaultClass: "selected",
//    indexPage: ""
// });

function getPage() {
  var href = window.location.href;
  var host = window.location.host;
  var pos = href.indexOf(host);
  var url = href.substring(pos + host.length);


  if ( url.charAt(0) == "/" )
    url = url.substring(0, url.length);
  return url;
}


jQuery.fn.currentPage = function(options) {
  var currentPage = "";
  var thisClass = "";
  var thisHref = "";
  var settings = jQuery.extend({
    defaultClass: "current",       // Default class to add to current link
	attr: "href",              // Default attribute to compare with current page URL (not usually used)
	appendToFirstClass: false, // Append the defaultClass to the first class on the element.
	                              // E.g. class="monkey" becomes class="monkey monkeycurrent"
	indexPage: "/",            // Default index page (to make current when page is not shown in URL)
	anyPath: false             // Ignore the path (supports pages in subfolders, and triggers on filename alone)
	}, options);
  
  currentPage = getPage();

  if ( (currentPage == "") || ( settings.anyPath && (currentPage.indexOf("/") == currentPage.length-1) ) )
    currentPage = settings.indexPage;

  this.each(function() {
      thisHref = $(this).attr(settings.attr);
      thisClass = "";

      if ( (thisHref == currentPage) || ( settings.anyPath && ( ( currentPage.indexOf(thisHref) > -1 ) && ( currentPage.indexOf(thisHref) + thisHref.length == currentPage.length ) ) ) ) {
	if (settings.appendToFirstClass) {
	  if ( $(this).attr("class") )                        // Conditional to support jQuery 1.6
	    thisClass = $(this).attr("class").split(" ")[0];  // Choose the first class (if multiple classes defined)
	  thisClass = thisClass + settings.defaultClass;      // Append the default current class to the first class class
	}
	else 
	  thisClass = settings.defaultClass;

	$(this).addClass(thisClass);
      }
    });
};

