$(document).ready(function(){

	$(function() {
        $(".anyClass").jCarouselLite({                      
            btnNext:	".next",
            btnPrev:	".prev",            
            auto:		3000,           
            pause:		"#CarouselPlayPause",
            speed:		1000,
            start:		0,
            visible:	1
        });
    });

	$("#CarouselPlayPause").click(function()
	{
	    if ($("#CarouselPlayPause").hasClass("paused"))
	    {
	        $(this).html("<a href='#' onclick='return false'>START</a>");
	    }
	    else
	    {
	        $(this).html("<a href='#' onclick='return false'>STOP</a>");
	    }
	});


    $('#mycarousel').jcarousel({
        // Configuration goes here
    });

   	$("div#show-rate").html('<div class="loader"><img src="templates/img/loading.gif" alt="Loading..." /></div>');
    var productIdVal = $("div.rate").attr("id").split("-");
    productIdVal = productIdVal[1];
   	$.ajax({
   		type: "POST",
        url:  "plugins/rate.php",
        data: { request: 'rating', productId: productIdVal },
        success: function(msg) {
        	$("div#show-rate").html('<strong>Średnia ocena: ' + msg + '</strong>');
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
        	$("div#show-rate").html('Wystąpił błąd!');
        }
    });

    $("div.rate span").each(function(){
    	// klik na wybranym span reszty nie uwzglednia
        $(this).click(function(){
        	$("div#show-rate").hide();
        	$("div.rate").html('<div class="loader"><img src="templates/img/loading.gif" alt="Loading..." /></div>');
        	var productIdVal = $("div.rate").attr("id").split("-");
        	productIdVal = productIdVal[1];
        	var rateVal = $(this).attr("id").split("-");
        	rateVal = rateVal[1];
        	var ipVal = '127.0.0.1';

          	$.ajax({
                type: "POST",
                url:  "plugins/rate.php",
                data: { request: 'vote', productId: productIdVal, rate: rateVal, ip: ipVal },
                success: function(msg) {
                	$("div.rate").html('<strong>' + msg + '</strong>');
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                	$("div.rate").html('Wystąpił błąd!');
                }
              });

         });  
    });

    $(function() {
		$('a[@rel*=lightbox-product]').lightBox();
	});
/*
	$("#show-full").click(function(){
		$("#full").slideDown("slow"); 
	});
*/

/*
	var display;
  
    $("div#pages span").each(function(){
    	// klik na wybranym span reszty nie uwzglednia
        $(this).click(function(){
        	$("div#pages span").css('background', '#fff');
        	$("div#pages span").css('color', '#000');
        	$(this).css('background', '#297CC0');
        	$(this).css('color', '#fff');
        	display = $("#" + $(this).attr("id") + "-rotator").css("display");
        	if (display == 'block')
        		return true;
        	$("div#rotator > div").each(function(){ $(this).hide(); });  
        	$("#" + $(this).attr("id") + "-rotator").show();  
        	//return true;  
         });  
    });  
*/

});
