$(function(){
	// colorfull menu
	$('#header ul.level_2 li').each(function(index){
		$(this).addClass('color_'+index);
	});
	
	// pretty checkbox
	$('#filters input[type=radio]').prettyCheckboxes({checkboxWidth: 17, checkboxHeight: 17,display: 'inline'});

	// jquery carousel
	 $("#customers_related .carousel").jCarouselLite({
        btnNext: "#customers_related .next",
        btnPrev: "#customers_related .prev",
			visible: 4,
    speed: 1000
    });

		 $(".random .carousel").jCarouselLite({
        btnNext: ".random .next",
        btnPrev: ".random .prev",
			visible: 4,
    speed: 1000
    });
		 $(".featured .carousel").jCarouselLite({
        btnNext: ".featured .next",
        btnPrev: ".featured .prev",
			visible: 1,
		speed: 1000
    });
    
    	 $("#top_sellers .carousel").jCarouselLite({
        btnNext: ".next_top_sellers",
        btnPrev: ".prev_top_sellers",
			visible: 4,
		speed: 1000
    });

//	Product Page image zoom
//	var options = {  
//            zoomType: 'standard',  
//            lens:true,  
//            preloadImages: true,  
//            alwaysOn:true,  
//            zoomWidth: 474,  
//	    zoomHeight: 474,
//	    imageOpacity: 1,
//            position:'right',
//	    title:false
//            //...MORE OPTIONS  
//    };  
//	 $('.zoom').jqzoom(options); 
	 
	 // init cart
	 init();
	 
	 
	
});

// Products Filter by New, Lowest Price, Highest Price
function filters_submit(n){
    $('#filters input.filter').val($(n).attr("value"));
    $('#filters form').submit();
}

function init()
{
	set_archive();
	set_scrollables();
	cart_status();
}

function set_scrollables()
{
	var height = 480;
	$('.scrollable .module-items').each(function(){
		var h = $(this).height();
		if(h>height)
			height = h;
		$(this).parent().parent().height(height);
	})
}

function set_archive()
{
	$('.module-archive ul').each(function(){
		$('li',this).click(function(){
			$('ul',this).slideToggle();
		})
	});
}

/* cart */

function show_response(msg)
{
	$('#response').stop(true,true).html(msg).fadeIn().delay(3000).fadeOut();
}

function cart_status()
{
	$.post(site_url+'shop/status',function(data){
		$('.cart_top').html(data);
	})
}
function clear_cart()
{
	var n = you_sure();
	if(n)
		$.post(site_url+'shop/clear',function(data){
			$('.cart_top').html(data);
		});
	return false;
}


/* you sure */

function you_sure()
{

	var check = confirm('Click OK to confirm');
	if(check)
	{
		return true;
	}
	else
	{
		return false;
	}

}
