var headline_count		= 3;
var current_headline	= 0;

function headline_rotate() {
	old_headline = current_headline % headline_count;
	new_headline = ++current_headline % headline_count;

	$("#the_carousel li:eq("+old_headline+")").removeClass("active");
	$("#the_carousel li:eq("+new_headline+")").addClass("active");

}

function rewriteId() {
	
}


$(document).ready(function(){
	//$(".print a").live("click", function() {
	//	$("#programma-items").empty();
	//	$("#programma-items").load("http://www.test-center.nl/mwf11c/wp-content/plugins/winterfair-programma/list-programma.php");
	//	return false;
	//});
	$("#programma-lijst").hide();
	$("#programma-items").load("http://www.test-center.nl/mwf11c/wp-content/plugins/winterfair-programma/list-programma.php");
	$("#mijnprogramma").click(function(){
		$("#programma-lijst").slideDown();
		//$("#programma-items").load("http://www.test-center.nl/mwf11c/wp-content/plugins/winterfair-programma/list-programma.php");
		return false;
	}).mouseleave(function(){
		$("#programma-lijst").delay(800).hide();
	});
	
	$("a.addtolist").live("click", function() {
		var thisId	= $(this).parent().parent().attr("id");
		$.post("http://www.test-center.nl/mwf11c/wp-content/plugins/winterfair-programma/list-programma.php",{addId: thisId},function(data){
			$("#programma-lijst").show().delay(1000).slideUp(200);
			$("#programma-items").load("http://www.test-center.nl/mwf11c/wp-content/plugins/winterfair-programma/list-programma.php");
			
		});
		return false;
	});
	
	$("p.programma_del").live("click",function(){
		var thisId	= $(this).parent().attr("id");
		$.post("http://www.test-center.nl/mwf11c/wp-content/plugins/winterfair-programma/list-programma.php",{removeId: thisId},function(data){
		});
		$(this).parent().slideUp();
		//$("#programma-items").load("http://www.test-center.nl/mwf11c/wp-content/plugins/winterfair-programma/list-programma.php");
		return false;
	});
	
	$("#the_carousel li:eq("+current_headline+")").addClass("active");
	$("#the_carousel li:eq("+current_headline+") img").show();
	headline_interval = setInterval(headline_rotate,5000);

	// mouse-over 
	$("#the_carousel li").bind('mouseenter', function(event){
		//old_headline = current_headline;
		new_headline = this;
		clearInterval(headline_interval);
		
		$("#the_carousel").find("li.active").removeClass("active");
		$(new_headline).addClass("active");
		
		current_headline = $(this).parent().prevAll().length;
		headline_interval = setInterval(headline_rotate,5000);

	});
	
	$("ul.headers_theme_vertical li.theme_tab_active").append('<div class="arrow" />');
	$("#the_carousel li").append('<div class="arrow" />');
	$("#specials").jCarouselLite({
		auto: 5000,
		speed: 500,
		circular: true,
		visible: 4
	});

});
