$(function() {
	if($('.scrollable .items').find('div').length > 1){
		$(".scrollable").scrollable({circular: true}).navigator().autoscroll({ autoplay: true, interval: 5000 });
	}
	
	$('#secondary .Special').each(function(){
		$(this).find('.srp-widget-singlepost').last().css('border',0);
	});
	
	$('#nav li').each(function(){
		if(!$(this).parent().hasClass('children')){
			$(this).mouseenter(function(){
				$('#nav li').find('ul').each(function(){
					$(this).hide();
				});
				$(this).find('.children:first').show().mouseleave(function(){
					$(this).hide();											   
				});
			});
		}
	});
	
	$('#nav .children li').each(function(){
		$(this).mouseenter(function(){
			$(this).parent().find('ul').each(function(){
				$(this).hide();
			});
			$(this).find('.children:first').css('marginLeft', $(this).width()+10).show().mouseleave(function(){
				$(this).hide();											   
			});
		});
	});
	
	if($('.grid').length > 0){
		totalItems = $('.grid ul li').length;
		perRow = 4;
		totalRows = Math.floor(totalItems/perRow);
		bottomRow = totalRows*perRow;
		if(bottomRow == totalItems){
			bottomRow = bottomRow - perRow;	
		}
		i = 1;
		
		$('.grid ul li').each(function(){ 
			if(i == 4 || i == 8 || i == 12 || i == 16 || i == 20 || i == 24 || i == 28 || i == 32 || i == 34 || i == 40){
				$(this).css('borderRight', 'none');	
			}
			
			if(i > bottomRow){
				$(this).css('borderBottom', 'none');	
			}
			
			myHeight = $(this).find('a').height();
			paddingTop = (130-myHeight)/2;
			newHeight = paddingTop+myHeight;
			
			$(this).find('a').css('paddingTop', paddingTop);
			$(this).find('a').css('height', newHeight);
			
			
			++i;
		});
	}
});
