


$(document).ready(function() {

	var hfooter = $('#fWrap').height();   // returns height of div#fWrap == hoogste ul
	$("#fWrap").css("height", hfooter+"px");
	$("#fWrap ul").css("height", hfooter-54+"px"); // alle ul zelfde hoogte
	$("#pWrap").css("margin-bottom", "-"+hfooter+"px");
	$("#page").css("margin-bottom", hfooter-18+"px");


	$('#page .banner:odd').css("margin-right","0");


	$('#pics img:first').css("margin-top","0");
		
	if ( $('#pics img').length == 1 ) { $('#pics').css("margin-bottom","15px"); }
	
	
	$("#content img").hover(function() {  
		$(this).stop().animate({ opacity: "0.8"}, 200);  
	},function() {  
		$(this).stop().animate({ opacity: "1.0"}, 400);  
	});  
	
	
	// LIGHTBOX - pagina afbeeldingen

	$(function() {
		$('#pics a').lightBox({
			overlayBgColor: '#000',
			imageLoading: 	'/common/media/lightbox/loading.gif',
			imageBtnClose:	'/common/media/lightbox/close.gif',
			imageBtnPrev: 	'/common/media/lightbox/prev.gif',
			imageBtnNext:	'/common/media/lightbox/next.gif'
	   	});
	});
	$(function() {
		$('#groupbericht a.clb').lightBox({
			overlayBgColor: '#000',
			imageLoading: 	'/common/media/lightbox/loading.gif',
			imageBtnClose:	'/common/media/lightbox/close.gif',
			imageBtnPrev: 	'/common/media/lightbox/prev.gif',
			imageBtnNext:	'/common/media/lightbox/next.gif'
	   	});
	});
	$(function() {
		$('#bericht a.clb').lightBox({
			overlayBgColor: '#000',
			imageLoading: 	'/common/media/lightbox/loading.gif',
			imageBtnClose:	'/common/media/lightbox/close.gif',
			imageBtnPrev: 	'/common/media/lightbox/prev.gif',
			imageBtnNext:	'/common/media/lightbox/next.gif'
	   	});
	});
	$(function() {
		$('#album .thumb a').lightBox({
			overlayBgColor: '#000',
			imageLoading: 	'/common/media/lightbox/loading.gif',
			imageBtnClose:	'/common/media/lightbox/close.gif',
			imageBtnPrev: 	'/common/media/lightbox/prev.gif',
			imageBtnNext:	'/common/media/lightbox/next.gif'
	   	});
	});
	
	
	
 	$("#album .thumb").hover(function() {  
		$(this).stop().animate({ opacity: "0.7"}, 100);  
	},function() {  
		$(this).stop().animate({ opacity: "1.0"}, 400);  
	});  
	$('#album .thumb:nth-child(6n)').css("margin-right","0");



 	$("#page .banner").hover(function() {  
		$(this).stop().animate({ borderColor: "#e7a0ac"}, 200);  
	},function() {  
		$(this).stop().animate({ borderColor: "#c7cad3" }, 400);  
	});  
	


	$("ul#mainnav ul li:has(ul)").find("a:first").append("&nbsp;&raquo;");
	
	/* CLICKABLE DIV */

	$('.clickable').css('cursor','pointer')
	$(".clickable").click( function(event) {
		event.preventDefault();
		var url = $(this).attr("url");
		
		if ( url.substr(0,5) == "http:" )
		{
			window.open( $(this).attr('target','_blank').attr("url") );
		} else {
			window.location = $(this).attr("url");
		}
	});
	
	
    $("ul#zoekresultaat li").hover(function() { $(this).stop().animate({ color: "#c41130"}, 100); },function() { $(this).stop().animate({ color: "#585a5d"}, 100); });
    $(".nwsli").hover(function() { $(this).stop().animate({ color: "#c41130"}, 100); },function() { $(this).stop().animate({ color: "#585a5d"}, 100); });


	/* CLEAR INPUT ON FOCUS */

	var clearMePrevious = "";
	
	// clear input on focus
	$('.clearMeFocus').focus(function()	{
		if($(this).val() == $(this).attr('title')) {
			clearMePrevious = $(this).val();
			$(this).val("");
		}
	});	
	
	// if field is empty afterward, add text again
	$('.clearMeFocus').blur(function() {
		if($(this).val() == "") {
			$(this).val(clearMePrevious);
		}
	});
	

	
	$(function(){$('#extranet').click(function(){
			
		var linkurl = "https://extranet.hvcgroep.nl";
		var txt = "Extranet is voor bestuurders (zoals portefeuillehouders milieu en afval, leden van het innovatieplatform) en beleidsmedewerkers (afval, milieu, duurzaamheid, financi&euml;n) van de aandeelhoudende gemeenten en waterschappen.<br />Voldoet u aan deze criteria en u heeft nog geen toegang tot het extranet? Stuur dan een mail naar <a href='mailto:extranet@hvcgroep.nl'>extranet@hvcgroep.nl</a>";
		
		$.prompt(txt,{ 
			buttons: { Verder: true, Annuleer: false },
			opacity: 0.8,
			callback: function(v,m,f){ if(v == true){ window.location = linkurl; } else { window.location = '#'; } }
		});
		return false; //automatically return false
		});
	});
	
});

function openFaq(faq, key) {
	
	// sluiten van alle geopende antwoorden
	$("div.answer").each(function(){
		$(this).slideUp(function(){
			$(this).prev().removeClass('hi');
			$(this).detach();
		});
	});
	// openen van gevraagde antwoorden
	$.ajax({
		type: "POST",
		url: "/common/ajax/openFaq.php",
		cache: false,
		data: {faq: faq, key: key},
		success: function(msg) {
			$(".faq_"+key).after(msg);
			$("div.answer").prev().addClass('hi');
			$("div.answer").slideDown();
		},
		error: function(msg) {
			alert(msg);
		}
	});

	return false;
}

