jQuery(document).ready(function() {
								
								
    jQuery('#nav ul li > a')
	.bind('mouseenter',function(){
		jQuery(this).css('opacity','1').animate({opacity:0}, 300)
	}).bind("mouseleave",function(){
		jQuery(this).animate({opacity:1 }, 200) 
	});
	jQuery("#loopedSlider").loopedSlider();

    initSlider();
    initCarousel();
    
});

// Home Slider   
function initSlider(){
     var slidesAmount = jQuery("#slider ul li.orphan").length; // Calculate the Amount of slides
     var nudgeValue = 0;
     var nudgeIncroment = -700;
     var slidesAmountOffset = slidesAmount - 1; // Adjust for the negative ovelap 
     var nudgeMax = slidesAmountOffset * nudgeIncroment; // Calculate and store the max possible length of the carousel
     
    
    jQuery("#slider .img-left, #slider .img-right").click(function(){
        if(nudgeValue <= nudgeMax)
        {
            nudgeValue = 0;
            jQuery("#slider .grip").animate({
                marginLeft: nudgeValue
            },1500);
        } 
        else 
        {
            nudgeValue =  nudgeValue + nudgeIncroment;
            jQuery("#slider .grip").animate({
                marginLeft: nudgeValue
            }, 400);      
        }

          
    });
};

// HORIZONTAL THEME CAROUSEL 
function initCarousel(){
    
     var slidesAmount = jQuery("#carousel ul li").length; // Calculate the Amount of slides
     var nudgeValue = 0;
     var nudgeIncroment = -240;
     var slidesAmountOffset = slidesAmount - 4; // Adjust for the negative ovelap 
     var nudgeMax = slidesAmountOffset * nudgeIncroment; // Calculate and store the max possible length of the carousel
     
    
    jQuery("#carousel .img-left, #carousel .img-right").click(function(){
        if(nudgeValue <= nudgeMax)
        {
            nudgeValue = 0;
            jQuery("#carousel .grip").animate({
                marginLeft: nudgeValue
            },1500);
        } 
        else 
        {
            nudgeValue =  nudgeValue + (nudgeIncroment * 2) ;
            jQuery("#carousel .grip").animate({
                marginLeft: nudgeValue
            }, 400);
          
                 
        }

          
    });
};

