function accordionsubmenu(){
	$('#submenu ul').hide();
	$('#submenu li a.active').next('ul').show();
	$('#submenu li a').click(
		function() {
			var checkElement = $(this).next();
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				$('#submenu ul:visible').slideUp('normal');
				$('#submenu li a').removeClass('active');
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#submenu ul:visible').slideUp('normal');
				$('#submenu li a').removeClass('active');
				checkElement.slideDown('normal');
				$(this).addClass('active');

				return false;
			}
		}
	);
}

var margin_default = -480;
var margin_increments = 190;
var active_highlight = 0;
var animation_duration = 1000;

function homeStartSlider(firstrun){
	if(firstrun){
		homeLoadProducts(1);
	}
	$("#front_category_hover").everyTime(5000,"slidechoice",function(i){
		if(active_highlight==4){
			active_highlight = 0;
			 $("#front_category_hover").stopTime("slidechoice");
			 $("#front_category_hover").animate({
				marginLeft:margin_default+'px'
			},animation_duration,'easeOutBack',homeStartSlider(true));
		}
		else{
			homeFadeOut();
			//$("#featured_products_element").fadeOut();
			//active_highlight = i;
			active_highlight++;
			margin = (active_highlight*margin_increments)+margin_default;
			$("#front_category_hover").animate({
				marginLeft:margin+'px'
			},animation_duration,'easeOutBack',function(){ homeLoadProducts($(".front_product_category[name='"+active_highlight+"']").attr('id').substr(5,6)); });
		}
	});
}


function homeLoadProducts(id){
	//alert(id);
	var div = "#featured_products_element";	
	var values = 'data[Category][id]='+id;
	//$(div).html("<div id=\"ajax_loading\"><img src=\""+webroot+"img/ajax-loader.gif\" /></div>");

	$.ajax({
		type: "POST",
		url: webroot+'products/home',
		//url: productpath,
		data: values,
		error: function(msg){
		   	$(div).html("Het is niet gelukt om de actie uit te voeren: "+msg);
		},
		success: function(msg){
			//$(div).hide().html(msg).fadeIn();
			$(div).html(msg);
			homeFadeIn();
		}
	});
}

function homeClickCallback(){
	homeLoadProducts($(".front_product_category[name='"+active_highlight+"']").attr('id').substr(5,6));
	homeStartSlider(false);
}

function homeFadeIn(){
	$('#home_product_0').fadeIn(600, function(){ 
		$('#home_product_1').fadeIn(600, function(){ 
			$('#home_product_2').fadeIn(600);}
		)	
	});
}

function homeFadeOut(){
	$('#home_product_0').fadeOut(500);
	$('#home_product_1').fadeOut(500);
	$('#home_product_2').fadeOut(500);
}

function filterProducts(values){
	var div = "#products_element";	
	$(div).html("<div id=\"ajax_loading\"><img src=\""+webroot+"img/ajax-loader.gif\" /></div>");

	$.ajax({
		type: "POST",
		//url: 'http://vertrigo'+webroot+'products/index/handschoenen/assemblage',
		url: productpath,
		data: values,
		error: function(msg){
		   	$(div).html("Het is niet gelukt om de actie uit te voeren: "+msg);
		},
		success: function(msg){
		    $(div).html(msg);
		}
	});
}
