jQuery.fn.rdy = function(func){
	this.length && func.apply(this);
	return this;
};
jQuery(document).ready(function($){
	$('html').removeClass('no-js');
	
	
	function custom_last(el,step) {
		el.each(function(){
			if (($(this).index()+1)%step==0) {
				$(this).css('marginRight',0);
			};
		});
	}
	custom_last($('.listingPosts li'),3);
	custom_last($('.contentBox .inlineBoxes'),2);	
	
	$('.toTop').click(function(){
    $('html, body').animate({scrollTop:0}, 'slow');
      return false;
  });
  
  $('.featuredItem').css('height',$('.childCats').height()-20)
  
  function current_body_class(body_class){
  	var has_classes = $('body').attr('class'),
  			has_class = has_classes.split(' '),
  			is_class = 0;
  			
  	for (var i=0; i < has_class.length; i++) {
  		if (has_class[i]==body_class) {
  			is_class = 1;
  		};
		};
		
		if (is_class==1) {
			return true;
		} else {
			return false;
		} 	
  }
  
	$('.post-gallery').rdy(function(){
		var t = $(this),
				thumbs = $('.gallery-thumbs',t),
				main = $('.gallery-main',t);
				
		$('li',thumbs).click(function(){
			var th = $(this),
					clicked = th.index();
					
			th.addClass('s').siblings().removeClass('s');
			$('li',main).eq(clicked).fadeIn().siblings().fadeOut();
			
			return false;
		});
		
		$('a:first',thumbs).click();
		
	});

  
  
  
	if (current_body_class('single-produse') == true || current_body_class('tax-lista-produse') == true) {
		$('li.page-item-176, ').addClass('current_page_item');
	};
  	
});



