jQuery(document).ready(function(){

// Slider 
        var panels_amount = jQuery('.panel').length;
        var panel_width = (jQuery('#categories-slider .panel').width()) + 25 ;
        var panels_width =   ((panels_amount *  panel_width) * -1) + (panel_width * 2);
        var panels_shift =    (panel_width * 3)*-1;
        var current_shift = 0;
        
        if(panels_amount > 2){
        if(current_shift == 0){
            
                jQuery('.carousel-nav .back').animate({
                    opacity:0 
                },800,'easeInOutSine')
         }

        jQuery('.carousel-nav .next').click(function(){
            
            if( current_shift + panels_shift < panels_width  ) //End
            {
                 current_shift =  panels_width;
                 jQuery(this).animate({
                    opacity: 0
                 },800,'easeInOutSine')
                 jQuery('.carousel-nav .back').animate({
                    opacity:1 
                },800,'easeInOutSine')
                  //alert('1');                
            }     
            else{
                   current_shift = current_shift +  panels_shift;
                   jQuery(this).animate({
                        opacity: 1
                     },600,'easeInOutSine');
                jQuery('.carousel-nav .back').animate({
                    opacity:1 
                },800,'easeInOutSine');
                //alert('2');
            }

        jQuery('#categories-slider').animate({ marginLeft: current_shift }, 650,'easeInOutSine'); //Action

        });
        
        jQuery('.carousel-nav .back').click(function(){
        
       
           if( current_shift - panels_shift > 0){
                    current_shift = 0;
                    
                jQuery('.carousel-nav .back').animate({
                    opacity:0 
                },800,'easeInOutSine')   
             jQuery('.carousel-nav .next').animate({
                    opacity:1 
                },800,'easeInOutSine')
                    
                    //alert('3'); 
            }
               else{
                   current_shift = current_shift -  panels_shift;
               jQuery('.carousel-nav .next').animate({
                    opacity:1 
                },800,'easeInOutSine')
               
            if(current_shift == 0){
            
                jQuery('.carousel-nav .back').animate({
                    opacity:0 
                },800,'easeInOutSine') 
         }
                   //alert('4'); 
            } 

       jQuery('#categories-slider').animate({ marginLeft: current_shift }, 650,'easeInOutSine'); //Action

        });
        }  
        else {
             jQuery('.carousel-nav').hide();
        }     

		$('.notabig2').hover(function(){
			$(".cover",this).stop().animate({top:'40px'},{queue:false,duration:160});
			$("span a", this).css({'text-decoration' : 'underline'});
		}, function() {
			$(".cover",this).stop().animate({top:'0px'},{queue:false,duration:160});
			$("span a", this).css({'text-decoration' : 'none'});
		});

		$('.coverx').each(function(){
				 $('.coverx').css("left",200);
		});

		$('.notabig3').hover(function(){
			$(".coverx", this).stop().animate({left:'0px'},{queue:false,duration:300});
		}, function() {
			$(".coverx", this).stop().animate({left:'200px'},{queue:false,duration:300});
		});



});