$(document).ready(function(){
						   

	$('#footer-widgets ul li:last').css('background','none');
						   
	$('#sidebar>ul').has('li').css({
			'display':'block',
			'padding-top':'20px',
			'padding-right':'40px',
			'padding-bottom':'0',
			'padding-left':'28px'
			
			});
	var maxHeight = 0;
	var temp = 0;
	$('#footer-widgets ul li').each(function(){
				var height = $(this).height();
				if( height > temp ){ 
					maxHeight = height ;
				}
				else{ maxHeight = temp; }
				temp = height;							 
				});


	 $('#footer-widgets ul li').css('height',maxHeight);
	 
	// client logo slider script
	
	var noLists = $('.client-slider-container .slides li').size();
	var ulWidth = noLists * 145; 
	var maxctr = Math.ceil( noLists / 6 );
	var ctr = 1;
    $('.client-slider-container .slides').css('width',ulWidth);
	$('.client-slider .prev').click(function(){
			$('.client-slider .next').css({
						'background-position':'0 0', 
						'cursor':'pointer'
						});
			if(ctr > 1){
				ctr--;
				$('.client-slider-container .slides').animate({'left':'+=870px'},'slow',
						 function(){
								 if( ctr == 1 ){
									$('.client-slider .prev').css({
												'background-position':'0 -18px', 
												'cursor':'default'
												});
									}
					 });
				}								 
			});
	
	$('.client-slider .next').click(function(){
			$('.client-slider .prev').css({
							'background-position':'0 0', 
							'cursor':'pointer'
							});
			if( ctr < maxctr){
				ctr++;
				$('.client-slider-container .slides').animate({'left':'-=870px'},'slow',
					function(){
							if( ctr == maxctr ){
								$('.client-slider .next').css({
											'background-position':'0 -18px', 
											'cursor':'default'
											});
								}
							
					});
				}								 
			});
	
	
	
	// gallery slider script
	
	var noListsGal = $('.gallery-slider-container .g-slides li').size();
	var ulWidthGal = noListsGal * 210; 
	var maxctrGal = Math.ceil( noListsGal / 4 );
	var ctrGal = 1;
    $('.gallery-slider-container .g-slides').css('width',ulWidthGal);
	$('.gallery-slider .prev').click(function(){
			$('.gallery-slider .next').css({
						'background-position':'0 0', 
						'cursor':'pointer'
						});
			if(ctrGal > 1){
				ctrGal--;
				$('.gallery-slider-container .g-slides').animate({'left':'+=840px'},'slow',
						 function(){
								 if( ctrGal == 1 ){
									$('.gallery-slider .prev').css({
											'background-position':'0 -18px', 
											'cursor':'default'
											});
									}
					 });
				}								 
			});
	
	$('.gallery-slider .next').click(function(){
			$('.gallery-slider .prev').css({
							'background-position':'0 0', 
							'cursor':'pointer'
							});
			if( ctrGal < maxctrGal){
				ctrGal++;
				$('.gallery-slider-container .g-slides').animate({'left':'-=840px'},'slow',
					function(){
							if( ctrGal == maxctrGal ){
								$('.gallery-slider .next').css({
										'background-position':'0 -18px', 
										'cursor':'default'
										});
								window.location = 'http://metaleapdesign.com/carrotandstick/gallery/';
								
								}
							
					});
				}								 
			});
	
	
	// Gallery page vertical scroller
	
	var galImages = $('.ngg-gallery-thumbnail-box').size();
	var maxRows = Math.ceil( galImages / 4 ) - 3;
	var row = 1;
	
	$('span.slideDown').click(
		function(){
			$('span.slideUp').css({
					'background-position':'0 0',				
					'cursor':'pointer'				
					});
			
			if( row > 1){
				row--;
				$('.ngg-galleryoverview').animate({'top':'+=160px'},'slow',
							function(){
								if( row == 1){
									$('span.slideDown').css({
										'background-position':'0 -32px',				
										'cursor':'default'				
										});
									}
								}					  
						);
				}
			}					  
		);


	$('span.slideUp').click(
		function(){
			$('span.slideDown').css({
					'background-position':'0 0',				
					'cursor':'pointer'				
					});
			
			if( row < maxRows){
				row++;
				$('.ngg-galleryoverview').animate({'top':'-=160px'},'slow',
							function(){
								if( row == maxRows){
									$('span.slideUp').css({
										'background-position':'0 -16px',				
										'cursor':'default'				
										});
									}
								}					  
						);
				}
			}					  
		);
	
	
	// Gallery images hover effect
	
	
//  $('.ngg-gallery-thumbnail-box').hover(function() {
//	$(this).css({'z-index' : '9999'}); /*Add a higher z-index value so this image stays on top*/ 
	//$(this).find('div.ngg-gallery-thumbnail').addClass("ngg-gallery-thumbnail-hover");
//	$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
	//	.animate({
			//marginTop: '-10px', /* The next 4 lines will vertically align this image */ 
			//marginLeft: '-10px',
		//	top: '-35px',
		//	left: '-40px',
		//	width: '306px', /* Set new width */
		//	height: '206px', /* Set new height */
			
		// }, 200); /* this value of "200" is the speed of how fast/slow this hover animates */

	// } , function() {
	// $(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
	// $(this).find('div.ngg-gallery-thumbnail').removeClass("ngg-gallery-thumbnail-hover");
	// $(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
	//	.animate({
	// 		marginTop: '0', /* Set alignment back to default */
	//		marginLeft: '0',
	//		top: '0',
	//		left: '0',
	//		width: '232px', /* Set width back to default */
	//		height: '152px' /* Set height back to default */
			
	//	}, 200); 
// });
	
});



