/*Copyright 2008 - SolidFlux Webworks*/

if (typeof jQuery != 'undefined') {
/*jQuery hovermenu*/
$(function() {
	//save the original
	var orgSelectedSub = $('ul.subnav.active');

	$('#primary-nav li a').mouseover(function(){
		//if mouseover primary nav, then show corresponding subnav ul
		var currentLI = $(this).parent().get(0);
		currentNum = $("#primary-nav li").index(currentLI);
		$('.subnav').each(function(){
			$(this).removeClass("active");
			$(this).addClass("inactive");
		});
		
		//console.log(currentNum);
		if (currentNum==4){
			currentNum=1000;
		}else{
			if (currentNum==3){
				currentNum=3;
			}
			
			if (currentNum==6){ //pers
				currentNum=3;	
			}else{
				currentNum--;
			}
		}
		
		
		$('.subnav:eq('+currentNum+')').removeClass("inactive");
		$('.subnav:eq('+currentNum+')').addClass("active");		
		return false;
	});
	
	$('#menu').bind("mouseleave",function(){
		//if mouseleave primary nav, then show original selected ul
		$('.subnav').each(function(){
			$(this).removeClass("active");
			$(this).addClass("inactive");
		});								 	
		$(orgSelectedSub).removeClass("inactive");
		$(orgSelectedSub).addClass("active");			
	});
	
	if ($("#vkbrss").get()!=""){
		$('#vkbrsslink').mouseover(function(){
			$('#vkbrss a.homeRss').css({ "background" : "url(/inc/img/rss_hover.png) no-repeat top right #ebebeb"});
		});
		
		$('#vkbrsslink').bind("mouseleave",function(){
			$('#vkbrss a.homeRss').css({ "background" : "url(/inc/img/rss_hover.png) no-repeat top left #ebebeb"});
		});
		
		$('#effrsslink').mouseover(function(){
			$('#effrss a.homeRss').css({ "background" : "url(/inc/img/rss_hover.png) no-repeat bottom right #ebebeb"});
		});
		
		$('#effrsslink').bind("mouseleave",function(){
			$('#effrss a.homeRss').css({ "background" : "url(/inc/img/rss_hover.png) no-repeat bottom left #ebebeb"});
		});
	
		$('#vkbrss').cycle({ 
			fx:    'fade', 
			timeout: 6000,
			delay: 1000,
			next:   '#vkbrsslink'    	
		});
		
		$('#effrss').cycle({ 
			fx:    'fade', 
			timeout: 6000,
			delay: 1000,
			next:   '#effrsslink'
		});	
	}
	
	/*search*/
	if ($("#resultatentabel .srow").get()!=""){
		$("#resultatentabel")
			.tablesorter( {
				sortList: [[0,0], [1,0]],
				headers: {2:{ sorter: false }}
			})
			.tablesorterPager({container: $("#pager")}); 
		
		
		$('.srow').mouseover(function(){
			$(this).addClass("hover");
		});
		
		$('.srow').bind("mouseleave",function(){
			$(this).removeClass("hover");
		});
	}
	
	/*arbeidsvoorwaardeninfo*/
	if (($("#arbeidsvoorwaarden").get()!="")||($("#frmArbeidsvoorwaarden").get()!="")){
		 JT_init();
	}
	
	/*sarbeidsvoorwaardeninfo*/
	if ($("#avht").get()!=""){
		 JT_init();
	}
	
	/*faq*/
	if ($(".FAQq").get()!=""){
		$(".plusmin").click(function () {
			$(this).next().next().slideToggle("fast");
			if ($(this).hasClass("min")){
				$(this).removeClass("min");	
			}else{
				$(this).addClass("min");					
			}
		});
		
		$(".FAQq").click(function () {
		//console.log($(this).next());
      		$(this).next().slideToggle("fast");
			if ($(this).prev().hasClass("min")){
				$(this).prev().removeClass("min");	
			}else{
				$(this).prev().addClass("min");					
			}
    	});
	}
	
	if($("#lg_hover").get()!=""){
		$("#lg_hover").mouseover(function(){
			$("#landelijk_gemiddelde").slideDown("fast");
		});
		
		$('#lg_hover').bind("mouseleave",function(){
			$("#landelijk_gemiddelde").slideUp("fast");
		});
	}
	
	/*pics*/
	if ($("#pics").get()!=""){
		//console.log($("#pics a:first").attr('title'));
		//console.log($("#pics a:first").attr('href'));
		var img = new Image();
		$(img)
			.load(function () {
				$(this).hide();
				$('#bigpicloader').hide();
				$(this).addClass('bigimg');
				$('#album_big').append(this);
				$(this).fadeIn("slow");
				pic_content = $("#pics a:first").attr('title').split('-');
				$('#pic_title').html(pic_content[0]);
				$('#pic_desc p').html(pic_content[1]);
			})
		
			.error(function () {
			  alert('Er is een fout opgetreden... Onze excuses.');
			})
		
			.attr('src', $("#pics a:first").attr('href'));
		$("#pics a:first").addClass("selectedthumb");

		$("#pics a").click(function () {
			$("#pics a.selectedthumb").removeClass("selectedthumb");
			$(this).addClass("selectedthumb");
			$('#pic_title').html('Een ogenblik geduld...');
			$('#pic_desc p').html('De foto wordt ingeladen');
			$('#album_big .bigimg').fadeOut("fast");
			$('#bigpicloader').show();
			$('#album_big .bigimg').remove();
			pic_content = $(this).attr('title').split('-');
			if (pic_content[1]==""){
				pic_content[1]="&nbsp;"
			}
			var img2 = new Image();
			$(img2).load(function () {
				$(this).hide();
				$('#bigpicloader').hide();
				$(this).addClass('bigimg');
				$('#album_big').append(this);
				$(this).fadeIn("slow");
				
				$('#pic_title').html(pic_content[0]);
				$('#pic_desc p').html(pic_content[1]);
			});
		
			$(img2).error(function () {
			  alert('Er is een fout opgetreden... Onze excuses.');
			})
			$(img2).attr('src', $(this).attr('href'));
			return false;
      	});
	}
	
});
}