/* CUFON
-------------------------*/
Cufon.replace('h1, h2, .carrouselTxt, span.titel, span.subtitel', { fontFamily: 'SignaColumn-Light' });
Cufon.replace('div#extra h3, div#sponsor h3', { fontFamily: 'SignaColumn-Black' });

// MENU
//	=========================
$(function(){
	$("nav ul li:first").addClass('first');
});

// BREADCRUMB
//	=========================
$(function(){
	$("div#breadcrumb a:last").addClass('active');
});

// BREADCRUMB
//	=========================
$(function(){
	$("div#projecttekst strong:first").addClass('first');
});

// CARROUSEL HOME
//	=========================
$(function(){
	// ID's en klassen juist zetten
	$("#carrousel_item div.itemBig").each(function(index) {
		$(this).attr("id", "bgdd_image_" + (index + 1));
	});

	$("#carrousel_items div.itemSmall").each(function(index) {
		$(this).attr("id", "bgdd_menu" + (index + 1));
		if (index == 0) {
			$(this).removeClass("bgdd_menu_small").addClass("bgdd_menu_big");
			$(this).find("div").removeClass("small").addClass("big");
		}
	});

	$("#carrousel_buttons div.itemSmall").each(function(index) {
		$(this).attr("id", "bgdd_menu" + (index + 1));
		if (index == 0) {
			$(this).removeClass("bgdd_menu_small").addClass("bgdd_menu_big");
			$(this).find("div").removeClass("small").addClass("big");
		}
	});

	var delay=300;

	$("#bgdd_menu1").find('a').addClass("active");

	$("#bgdd_menu1").mouseover(function () {showItem(1);});
	$("#bgdd_menu2").mouseover(function () {showItem(2);});
	$("#bgdd_menu3").mouseover(function () {showItem(3);});
	$("#bgdd_menu4").mouseover(function () {showItem(4);});
	$("#bgdd_menu5").mouseover(function () {showItem(5);});
	$("#bgdd_menu6").mouseover(function () {showItem(6);});
	$("#bgdd_menu7").mouseover(function () {showItem(7);});

	$("#carrousel").bind("mouseenter",function(){
			clearTimeout(rotate_timer);
		}).bind("mouseleave",function(){
		timer_no=curr_no;
		var media=$("#bgdd_menu"+curr_no).attr("media");
	});

autoRotate();
});

var curr_no=1;
var timer_no=1;
var rotate_timer="";
var timer=3000;

function showItem(no){
	if(curr_no!=no){
		resetItems();
		$("#bgdd_image_"+no).fadeIn();
		
		$('.itemSmall').find('a').removeClass('active');
		$("#bgdd_menu"+no).find('a').addClass("active");
		
		curr_no=no;
	}
}

function resetItems(){
	$("#bgdd_image_"+curr_no).fadeOut();
	
	//$("#bgdd_menu"+curr_no).children().removeClass();
	//$("#bgdd_menu"+curr_no).children("div").addClass("small");
}

function autoRotate(){
	showItem(timer_no);
	timer_no++;
	if(timer_no>7){
		timer_no=1;
	}
	rotate_timer=setTimeout("autoRotate()",timer);
}

// ALBUM
// ------------------------------
$(window).load(function() {
		$("div.scrollable").scrollable();
		if($("div.scrollable div.items img").length < 5){$("a.nextPage.browse.right").addClass("disabled");}
	});

	$(function() {
		$(".items img").click(function() {
			var url = $(this).attr("src").replace("_small", "");
			var wrap = $("#image_wrap") //.fadeTo("medium", 0.5);
			var img = new Image();
			img.onload = function() {
				wrap.fadeTo("fast", 1);
				wrap.find("img").attr("src", url);
			};
			img.src = url;
		}).filter(":first").click();
	});

$(document).ready(function() {
	if($(".mainImg .headImg").length > 1){
		$('.mainImg').cycle({
			fx: 'fade'
		});
		$(".mainImg").height(260).width(750).after("<div class=\"clear\">");
	}
});
