$(document).ready(function(){

//show / hide / toggle / slideUp / slideDown / slideToggle / fadeIn / fadeOut -->

	// thumb1 -->  
	$('#thumb1').hide();
	$('a.toggle1').click(function(){
	$('#thumb2').slideUp(200);
	$('#thumb3').slideUp(200);
	$('#thumb4').slideUp(200);
	setTimeout(function() {$('#thumb1').slideToggle(400);}, 50);
	});

	// thumb2 -->
	$('#thumb2').hide();
	$('a.toggle2').click(function(){
	$('#thumb1').slideUp(200);
	$('#thumb3').slideUp(200);
	$('#thumb4').slideUp(200);
	setTimeout(function() {$('#thumb2').slideToggle(400);}, 50);
	});  

	// thumb3 -->
	$('#thumb3').hide();
	$('a.toggle3').click(function(){
	$('#thumb1').slideUp(200);
	$('#thumb2').slideUp(200);
	$('#thumb4').slideUp(200);
	setTimeout(function() {$('#thumb3').slideToggle(400);}, 50);
	});

	// thumb4 -->
	$('#thumb4').hide();
	$('a.toggle4').click(function(){
	$('#thumb1').slideUp(200);
	$('#thumb2').slideUp(200);
	$('#thumb3').slideUp(200);
	setTimeout(function() {$('#thumb4').slideToggle(400);}, 50);
	});

});


//OPEN/DICHTKLAPPEN (neem contact op)
/*$(document).ready(function() {
	$('div.content> div.contact').hide();
	$('div.content> div.toggle').click(function() {

		var $nextDiv = $(this).next();
		var $visibleSiblings = $nextDiv.siblings('div.contact:visible');
		var $visible = $(this).find('.on').length == 0;

		$('div.content> div.toggle> a').removeClass('on');

		if ($visibleSiblings.length ) {
			$visibleSiblings.slideToggle('slow', function() {
				$nextDiv.slideDown('slow');
			});
		} else {
				$nextDiv.slideToggle('slow', function() {

					if ($(this).find("h3").css("visibility") == "hidden") {
						replaceH3();
					}

				});
		}

		if ($visible) {
			$(this).find('a').addClass('on');
		}
	});
});
*/


/* Afbeeldingen float left + float right

		Subtitels moeten zo worden geplaatst dat afbeeldingen met model 
		float:left en float:right gewoon geplaatst kunnen worden, en dat de titel er 
		nog in het geheel boven komt
*/

$(function() {
	$("div.img-links + h2, div.img-rechts + h2").each(function() {
		$(this).insertBefore($(this).prev());
	});
});

//TOOLTIP
this.tooltip = function(){	
		
		xOffset = 10;
		yOffset = -160;		
 		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<div id='tooltip'><span class='tooltip1'></span><span class='tooltip2'>"+ this.t +"</span><span class='tooltip3'></span></div>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

// starting the script on page load
$(document).ready(function(){
	tooltip();
});

//RESIZE
$(document).ready(function() {
	resizeContainer();
});
		
$(window).bind("resize", function() { resizeContainer(); });
		
function resizeContainer() {
	if ($("#container").height() <= $(window).height()) {
		$("#container").height($(window).height() - 30);
	}
}



function resizePopup() {
	var height = $("#sb-body").height() - 100;
	$("#sb-container .popupContent").height(height);
	$("#sb-container .popupSb_l").height(height);
	$("#sb-container .popupSb_r").height(height);
}

$(document).ready(function() {
	resizePopup();
});

$(window).bind("resize", function() { window.setTimeout(resizePopup, 75); });

//CAROUSSEL (home)
$(document).ready(function(){
	
	var delay=300;
	cCarouselExt = typeof(cCarouselExt) != "undefined" ? cCarouselExt : "png";

	$("#hdr_news1").mouseover(function () {
		showItem(1);
	});
	$("#hdr_news2").mouseover(function () {
		showItem(2);
	});
	$("#hdr_news3").mouseover(function () {
		showItem(3);
	});

	$("#carrousel").bind("mouseenter",function(){
			clearTimeout(rotate_timer);
		}).bind("mouseleave",function(){
		timer_no=curr_no;
		var media=$("#hdr_news"+curr_no).attr("media");
	});

autoRotate();
});

var curr_no=1;
var timer_no=1;
var rotate_timer="";
var timer=5000;

function showItem(no){
	if(curr_no!=no){
		resetItems();
		$("#news_image_"+no).fadeIn();
		$("#hdr_news"+no).css("height","151px");
		$("#hdr_news"+no).css("backgroundImage","url('" + jsServerpad + "custompages/jQuery/img/bg_tabbig"+no+"." + cCarouselExt + "')");
		
		$("#hdr_news"+no).children().removeClass();
		$("#hdr_news"+no).children("div").addClass("big");
		
		if (no == 3) {
			$("#hdr_news2").css("backgroundImage","url('" + jsServerpad + "custompages/jQuery/img/bg_tabsmall2_2." + cCarouselExt + "')");
			$("#hdr_news1").css("width","165px")
			$("#hdr_news1").css("padding","0 10px 0 85px");
			$("#hdr_news2").css("width","180px")
			$("#hdr_news2").css("padding","0 10px 0 70px");
			$("#hdr_news3").css("width","200px")			
			$("#hdr_news3").css("padding","0 10px 0 50px");
			$("#hdr_news3 .big a").css("line-height","24px");
			$("#hdr_news1 .small a").css("line-height","18px");
			$("#hdr_news2 .small a").css("line-height","18px");
		}

		if (no == 2) {
			$("#hdr_news1").css("width","165px")
			$("#hdr_news1").css("padding","0 10px 0 85px");
			$("#hdr_news2").css("width","180px")
			$("#hdr_news2").css("padding","0 10px 0 70px");
			$("#hdr_news3").css("width","220px")			
			$("#hdr_news3").css("padding","0 10px 0 30px");
			$("#hdr_news2 .big a").css("line-height","24px");
			$("#hdr_news1 .small a").css("line-height","18px");
			$("#hdr_news3 .small a").css("line-height","18px");
		}
		
		if (no == 1) {
			$("#hdr_news1").css("width","165px")
			$("#hdr_news1").css("padding","0 10px 0 85px");
			$("#hdr_news2").css("backgroundImage","url('" + jsServerpad + "custompages/jQuery/img/bg_tabsmall2." + cCarouselExt + "')");
			$("#hdr_news2").css("width","200px")			
			$("#hdr_news2").css("padding","0 10px 0 50px");
			$("#hdr_news3").css("width","220px")			
			$("#hdr_news3").css("padding","0 10px 0 30px");
			$("#hdr_news1 .big a").css("line-height","24px");
			$("#hdr_news2 .small a").css("line-height","18px");
			$("#hdr_news3 .small a").css("line-height","18px");
		}
				
		curr_no=no;
	}
}

function resetItems(){
	$("#news_image_"+curr_no).fadeOut();
	$("#hdr_news"+curr_no).css("height","70px");
	$("#hdr_news"+curr_no).css("backgroundImage","url('" + jsServerpad + "custompages/jQuery/img/bg_tabsmall"+curr_no+"." + cCarouselExt + "')");
	
	$("#hdr_news"+curr_no).children().removeClass();
	$("#hdr_news"+curr_no).children("div").addClass("small");
}

function autoRotate(){
	showItem(timer_no);
	timer_no++;
	if(timer_no>3){
		timer_no=1;
	}
	rotate_timer=setTimeout("autoRotate()",timer);
}

