jQuery(function() {

	$.fn.setAllToMaxHeight = function(){
		return this.height( Math.max.apply(this, $.map( this , function(e){ return $(e).height() }) ) );
	}
	
	$('.widget .post-details').remove();
	
	
	//$('.bns-featured-category .post div').each(function(idx,el){
		//el.style.overflowX='';
	//});
	
	//$('.post_box_container').setAllToMaxHeight()

// usage: $(‘div.unevenheights’).setAllToMaxHeight()

	var theWindow = $(window),
	$bg = $("#bg"),
	aspectRatio = $bg.width() / $bg.height();
	function resizeBg() {
		if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
			$bg.removeClass().addClass('bgheight');
		} else {
			$bg.removeClass().addClass('bgwidth');
		}
	}
	theWindow.resize(function() {
		resizeBg();
	}).trigger("resize");
	
	$('img').attr("title","");
	
	$('a.inkaras').click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});
	
		// submeniu apacios borderis
	//$("#menu-main li ul.sub-menu li:last-child a").css('border-bottom-width', '2px');
	// submeniu virsaus shadowsas
	//$('#menu-main li ul.sub-menu').prepend('<li class="li_shadow"><span></span></li>');
	// submeniu iscentravimas
	$("#menu-kaire-meniu li ul.sub-menu, #menu-desine-meniu li ul.sub-menu").each(function(){
	
		var ul_width = $(this).width();
		$(this).width(ul_width + 70 + "px");

	});
	
	//$("#menu-item-429, #menu-item-427").css('padding-right','50px'); // maistas ir kelione
	// submeniu animacija
	$("#menu-kaire-meniu li, #menu-desine-meniu li").mouseover(function() {
		$(this).find("ul.sub-menu").filter(':not(:animated)').animate({"height": "show"}, 200, "swing");
		$(this).hover(function() {}, function(){
			$(this).find("ul.sub-menu").animate({"height": "hide",}, 100);
			//$(this).find("ul.children").animate({"height": "hide", "opacity": "hide"}, 200);
		});
	});
	
	// centravimas
	/*
	var sponoriai_width = 0;
	$('#sponsoriai a').each(function() {
    sponoriai_width += $(this).outerWidth( true );});
	$('#sponsoriai').css('width', sponoriai_width + 'px');
	
	
	$('#sponsoriai a').each(function() {
    sponoriai_width += $(this).outerWidth( true );});
	*/
    
    
    

});


$(window).load(function () {
  
  // loop through all elements with "equal-height" class
$('.post_box_container').each(function(){

	// set newHeight to zero
	var newHeight = 0;

	// loop through children to identify biggest height
	$(this).children('.post_box').each(function(){
		var currentHeight = $(this).find('h2').height();
		if (currentHeight >= newHeight){
			newHeight = currentHeight;
		}
	});
	
	$(this).children('.post_box').each(function(){
		var hashdu = $(this).find('h2').height();
		console.log(hashdu + " :)");
		if (hashdu < newHeight) {
			var skirtumas = newHeight - hashdu;
			$(this).find('h2').css('padding-top', skirtumas + 'px');
		}
	});
	
});
  
  
});
