/*
* Custom jQuery functions
**/

/* News */
var olderNewsItemsShown = false;

function toggleOlderNewsItems() {
	if(olderNewsItemsShown) { // Hide
		$('#olderNewsItems').hide();
		olderNewsItemsShown = false;
		$('a#linkOlderNewsItems').text('Meer nieuws >');
	}else{	// Show
		$('#olderNewsItems').show();
		olderNewsItemsShown = true;
		$('a#linkOlderNewsItems').text('Verberg nieuws >');
	}
}

$(function() {
	$(".faqItem").toggle(
		function () {
			$(this).parent().addClass("question_expanded");
	     	$(this).parent().removeClass("question_collapsed");
	  	},
	  	function () {
	  		$(this).parent().removeClass("question_expanded");
	    	$(this).parent().addClass("question_collapsed");
	  	}
	);
	
	$(".faqGroup").toggle(
		function () {
			$(this).parent().addClass("faqGroup_expanded");
	     	$(this).parent().removeClass("faqGroup_collapsed");
	  	},
	  	function () {
	  		$(this).parent().removeClass("faqGroup_expanded");
	    	$(this).parent().addClass("faqGroup_collapsed");
	  	}
	);
	
	
});	


function getCustomerButtonListFiltered() {
	var branche = '';
	var service = '';
	
	// Get values from selectlists
	branche = $('#brancheFilter').val();
	service = $('#serviceFilter').val();
	
	// Send the filter to Ajaxify the overview
	$('#werkContentProjects').html('<div class="ajaxLoading"></div>');
	$.ajax({
		type: "GET",
		url: rootPath+"pages/products.ajax.php",
		data: "action=getCustomerButtonListFiltered&branche="+branche+"&service="+service,
		success: function(msg){
			$('#werkContentProjects').html(msg);
		}
	});
}

/* Sitemap */
function toggleSitemap(id, aId) {
	if($('#'+id).css('display') == 'none') {
		$('#'+id).css('display','block');
		$('a#'+aId+' img.toggleButton').attr('src',imgPath+'sitemap/min.png');
	}else{
		$('#'+id).css('display','none');
		$('a#'+aId+' img.toggleButton').attr('src',imgPath+'sitemap/plus.png');
	}
}

// define function that opens the overlay
function openOverlay() {
	
	// get access to the overlay API
	var api = $("#overlay").overlay();

	// call it's open() method		
	api.load();			
}

// overlay
$(function() {
	$("#overlay").overlay({
		close: 'a.close' ,

		speed: 50,
		// start exposing when overlay starts to load
		onBeforeLoad: function() {
			
			// this line does the magic. it makes the background image sit on top of the mask
			this.getBackgroundImage().expose({opacity: 0.75 ,color: '#000000'});
		}, 
				
		// when overlay is closed take the expose instance and close it as well
		onClose: function() {
			$.expose.close();
		}
	});

	$("#overlay2").overlay({
		close: 'a.close' ,

		speed: 50,
		// start exposing when overlay starts to load
		onBeforeLoad: function() {
			
			// this line does the magic. it makes the background image sit on top of the mask
			this.getBackgroundImage().expose({opacity: 0.75 ,color: '#000000'});
		}, 
				
		// when overlay is closed take the expose instance and close it as well
		onClose: function() {
			$.expose.close();
		}
	});
});