jQuery(document).ready(function(){
	
	jQuery('.merken_hover').hover( 
		function () {
			brand_id = "#list_" + jQuery(this).attr("id");
			jQuery(this).find('.brand_logo').attr('src', jQuery(this).find('.brand_logo').attr('src').replace(/wit_/, 'goud_') );
			jQuery(brand_id).addClass("active");
		}, 
		function() {
			brand_id = "#list_" + jQuery(this).attr("id");
			jQuery(this).find('.brand_logo').attr('src', jQuery(this).find('.brand_logo').attr('src').replace(/goud_/, 'wit_') );
			jQuery(brand_id).removeClass("active");
		}
	);
	
	jQuery('#merken_category_div_list li a').hover( 
		function () {
			brand_id = "#" + jQuery(this).attr("id").replace(/list_/,"") + " .brand_logo";
			jQuery(brand_id).attr('src', jQuery(brand_id).attr('src').replace(/wit_/, 'goud_') );
		}, 
		function() {
			brand_id = "#" + jQuery(this).attr("id").replace(/list_/g,"") + " .brand_logo";
			jQuery(brand_id).attr('src', jQuery(brand_id).attr('src').replace(/goud_/, 'wit_') );
		}
	);
	
	
	//Categories
	
	var categorie 		= jQuery('#aanbiedingen_categorie li a');
	var categorie_title	= jQuery('#merken_title h3');
	var categorie_image	= jQuery('#content_header img');
	var brand_links 	= jQuery('#merken_category_div_list li');
	var brand_logos 	= jQuery('#merken .merkenitem');
	
	categorie.click( function(e) {
		
		if(e.preventDefault){ e.preventDefault()}
		else{e.stop()};

		e.returnValue = false;
		e.stopPropagation();
		
		jQuery('#aanbiedingen_categorie li .active').removeClass("active");
		jQuery(this).addClass("active");
		
		var active_category = jQuery(this).attr('category');
		
		categorie_image.attr('src', '/images/merken/merken_' + merken_info[active_category].image + '.png');
		categorie_title.text(merken_info[active_category].title).removeClass("sIFR-replaced");
		
		sIFR.replace(bellgothic_black, {selector: 'h3.route',css: {'.sIFR-root': { 'color': '#ffffff' }},wmode: ['transparent']});

		// FILTER BRAND LOGOS
		var filtered_logos = brand_logos.filter( function() {
			return (
				jQuery(this)[0].className.indexOf( active_category ) > -1 || 
				active_category == 'all_brands_without_horeca'
			);
		});
		
		filtered_logos.fadeIn(400);
		brand_logos.not(filtered_logos).fadeOut(400);
		
		// FILTER BRAND LINKS
		var filtered_links = brand_links.filter( function() {
			return (
				jQuery(this)[0].className.indexOf( active_category ) > -1 || 
				active_category == 'all_brands_without_horeca'
			);
		});
		
		filtered_links.fadeIn(400);
		brand_links.not(filtered_links).fadeOut(400);
	});

});