$(window).load(function(){ 
var currentElem=4;
 // $('.infiniteCarousel').infiniteCarousel();
 				$('ul#galleryul li:first').before($('ul#galleryul li:last'));  

 $('ul#galleryul').css('left','-400px');
 
  $('a.gall-prev').click(function(event){
    	$('ul#galleryul').animate({'left':'+=400'}, 100, function () {
    	
    			$('ul#galleryul li:first').before($('ul#galleryul li:last'));  
			 	 $('ul#galleryul').css({'left' : -400});
    	} );
    	


 
 })
 
   $('a.gall-next').click(function(event){
 	$('#galleryul').animate({'left':'-=400'},100, function() {
   $('ul#galleryul li:last').after($('ul#galleryul li:first')); 

			 	             $('ul#galleryul').css({'left' : -400});	
 	});

 
 })
  
 var galleryelements =  $('#gal li').size();
// if(galleryelements > 4) $('.infiniteCarouselMini').infiniteCarousel();
if(galleryelements == 3)  {
$('#gal li img, #gal li').css({'width':'166px', 'height':'124px'});
$('.infiniteCarouselMini .wrapper').css('height','124px');
}
if(galleryelements  <= 4) {
$('a.gall-prev-mini, a.gall-next-mini').hide();
} else {
currentElem=4;

}

   		if (currentElem<=4) {$('a.gall-prev-mini').css('opacity','0.2')}else{$('a.gall-prev-mini').css('opacity','1')}

  $('a.gall-prev-mini').click(function(event){
     if (currentElem>4) {

    	$('ul#minigallery').animate({'left':'+=125'}, 100 );
    	currentElem--;
   		if (currentElem>=galleryelements) {$('a.gall-next-mini').css('opacity','0.2')}else{$('a.gall-next-mini').css('opacity','1')}
   		if (currentElem<=4) {$('a.gall-prev-mini').css('opacity','0.2')}else{$('a.gall-prev-mini').css('opacity','1')}
   	} 

 });
 
   $('a.gall-next-mini').click(function(event){
   if (currentElem<galleryelements) {
 	$('ul#minigallery').animate({'left':'-=125'},100 );
 	    	currentElem++;
	}
   		if (currentElem<=4) {$('a.gall-prev-mini').css('opacity','0.2')}else{$('a.gall-prev-mini').css('opacity','1')}
   		if (currentElem>=galleryelements) {$('a.gall-next-mini').css('opacity','0.2')}else{$('a.gall-next-mini').css('opacity','1')}
 
 })







	//Full Caption Sliding (Hidden to Visible)
	$('.boxgrid.captionfull').hover(function(){

		$(".cover", this).stop().animate({top:'237px'},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top:'320px'},{queue:false,duration:160});
	});
	  
	  
	  
		$('.item').hover(function(){
		$(".item-cover", this).stop().animate({top:'-60px'},{queue:false,duration:120});
	}, function() {
		$(".item-cover", this).stop().animate({top:'0px'},{queue:false,duration:120});
	});
	    
	
	  	  
  
  $('.boxcaption').css({'opacity':'0.75'});

  
  
});
