//	TOPNAV
//	=========================
$(function(){
	$("ul.subnav").parent().append("<span></span>");

	$("ul.topnav li span").click(function(){ 

		$(this).parent().find("ul.subnav").slideDown('fast').show();
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").slideUp('slow');
		});

		}).hover(function() { 
			$(this).addClass("subhover");
		}, function(){
			$(this).removeClass("subhover");
	});
});

//	BANNER
//	=========================
$(function(){
	if ($("#slider>ul>li").length > 1) {
		$("#slider").easySlider({
			auto: true, 
			continuous: true,
			speed: 500,
			pause: 8000
		});
	}
});

$(function(){
	$('a.click').click(function(){
		$('.slidertxt').slideToggle('slow');
		$(this).toggleClass("up");
		return false
	})
});


//	NIEUWSCAROUSEL - HOME
//	=========================
$(function(){
	
	var delay=300;

	$("#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).children().removeClass();
		$("#hdr_news"+no).children("div").addClass("big");
		
		curr_no=no;
	}
}

function resetItems(){
	$("#news_image_"+curr_no).fadeOut();
	
	$("#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);
}

//	TOGGLE - CATEGORIEN
//	=========================
$(function(){
	$(".toggle_box").hide();
	
	$("span.trigger").click(function(){
		if ($(this).attr("active") == "true") {
			$(this).removeAttr("active");
			$(this).removeClass("active").next(".toggle_box").slideUp("slow");
		} else {
			$("span.trigger").removeClass("active").removeAttr("active");	
			$(this).attr("active", "true");
			$(".toggle_box").slideUp();
			$(this).addClass("active").next(".toggle_box").slideToggle("slow");
		}
	});


	var triggerCount = 0;
	$(".box a.current").parents(".toggle_box").prev(".trigger").each(function() {
		$(this).click();
		triggerCount++;
	});
	if (triggerCount == 0) {
		$("span.trigger").eq(0).click();
	}
});

