
//For hovering tr productgroup
$(".tr_link:even").css("background-color", "transparant");
$(".tr_link:odd").css("background-color", "#ddd");



// $('#search_start').click(function() {
//     if($('.search_criteria_form').is(":hidden"))
//     {
// 	$(".search_criteria_form").show(300);
// 	$("#search_end").show();
// 	$("#search_start").hide();
// 	$(this).removeClass('search_criteria_text_hover');
// 	$("#arrow_image").attr("src", "{{=URL('static','images/pijl_geel.png')}}");
//     }
// });
// 
// $('#search_end').click(function() {
//     if($('.search_criteria_form').is(":visible"))
//     {
// 	$("#search_end").hide();
// 	$(".search_criteria_form").hide();
// 	$("#search_start").show();
// 	$(this).addClass('search_criteria_text_hover');
// 	$("#arrow_image").attr("src", "{{=URL('static','images/pijl_zwart.png')}}");
//     }
// });

$('.footer_product_page').each(function(index) {
	if($(this).attr("id") != "p1")
	   $(this).hide();
	    });

var _max_pages = parseInt($('.footer_product_page').length);
$('.footer_product_arrow_left').click(function() {
    if($('.footer_product_page:visible').length == 0)
    {
	    $("#p1").show();
	    $("#p1 img").each(function(index) {
		$(this).attr("src",$(this).attr("title"));
	    });
	    $('.process_article_1').text(1);
	    $('.process_article_2').text(5);
    }
  $('.footer_product_page:visible').each(function(index) {
    var _id = parseInt($(this).attr("id").replace('p',''));
    var _new_id = parseInt(_id-1);
    if(_new_id >= 1)
    {
	$("#p"+_id).hide();
	$("#p"+_new_id).show();
	$("#p1"+_new_id+" img").each(function(index) {
		$(this).attr("src",$(this).attr("title"));
	});
	var _new = parseInt((_new_id-1)*5+1);
	var _new_2 = _new+4;

	if (_new_2 > parseInt(total_found))
	    _new_2 = total_found;
    	$('.process_article_1').text(_new);
	$('.process_article_2').text(_new_2);	   
	
    }
    else
    {
	$("#p"+_id).hide();
	$("#p"+_max_pages).show();
	$("#p1"+_max_pages+" img").each(function(index) {
		$(this).attr("src",$(this).attr("title"));
	});
	$('.process_article_1').text(parseInt((_max_pages-1)*5+1));
	$('.process_article_2').text(total_found);	   
    }

});
});

$('.footer_product_arrow_right').click(function() {
    if($('.footer_product_page:visible').length == 0)
    {
	    $("#p1").show();
	    $("#p1 img").each(function(index) {
		$(this).attr("src",$(this).attr("title"));
	    });
	    $('.process_article_1').text(1);
	    $('.process_article_2').text(5);
    }

    $('.footer_product_page:visible').each(function(index) {
	var _id = parseInt($(this).attr("id").replace('p',''));
	var _new_id = parseInt(_id+1);

	if (_id < _max_pages)
	{
	    $("#p"+_id).hide();
	    $("#p"+_new_id).show();
	    $("#p"+_new_id +" img").each(function(index) {
		$(this).attr("src",$(this).attr("title"));
	    });
	    var _new = parseInt((_new_id-1)*5+1);
	    var _new_2 = _new+4;
	    if (_new_2 > parseInt(total_found))
		_new_2 = total_found;
	    $('.process_article_1').text(_new);
	    $('.process_article_2').text(_new_2);	   
	}
	else
	{
	    $("#p"+_id).hide();
	    $("#p1").show();
	    $("#p1 img").each(function(index) {
		$(this).attr("src",$(this).attr("title"));
	    });
	    $('.process_article_1').text(1);
	    $('.process_article_2').text(5);	 
	}
    });
});



$("#processfullshoppingcart").click(function() {
    $(".overlay_shopping_cart").hide(200);
    $(".overlay_process_shopping_cart").show(200);
});

function sortUnorderedList(ul) {
    var items = $('.'+ul+' li:not(:first-child)').get();
    items.sort(function(a,b){ 
	var keyA = $(a).text();
	var keyB = $(b).text();

	if (keyA < keyB) return -1;
	if (keyA > keyB) return 1;
	return 0;
    });
    
    var ul = $('.'+ul+' ul li:nth-child(1)');
    $.each(items, function(i, li)
    {
	ul.after().append(li);
    });


}


