
	jQuery(function($) {
		
		$('.alignright').each(function() {
			if($(this).find('.wp-caption-text').length) {
				var t1 = $(this).find('.wp-caption-text').html();
				$(this).find('.wp-caption-text').remove();
				var t2 = $(this).html();
				$(this).replaceWith('<table class="alignright with_caption"><tr><td class="td_caption">' + t1 + '</td><td class="td_img">' + t2 + '</td></tr></table>');
			}
		});
		
		$('.alignleft').each(function() {
			if($(this).find('.wp-caption-text').length) {
				var t1 = $(this).find('.wp-caption-text').html();
				$(this).find('.wp-caption-text').remove();
				var t2 = $(this).html();
				$(this).replaceWith('<table class="alignleft with_caption"><tr><td class="td_img">' + t2 + '</td><td class="td_caption">' + t1 + '</td></tr></table>');
			}
		});
		
		$('.person:last').css({'background':'none'});
									
		$('#banner img').hide().eq(0).show();
		$('#banner_links a:first').addClass('active');
		$('#banner_links li').click(function() {
			var i = $(this).index();
			$('#banner img').stop(true,true).fadeOut(500).eq(i).fadeIn(500);
			$('#banner_links a').removeClass('active').eq(i).addClass('active');
			return false;
		});

		$("#asideContainer .aside .widget_recent_entries .widget-inner ul li:last").addClass('last');
		$("#homepage-posts .homepage-post:last").addClass('last');
		
		$('#footer-box-2').addClass('dc');
		$('#footer-box-2 a').click(function() {
			var city = $(this).text().toLowerCase();
			$(this).closest('#footer-box-2').removeClass('dc ny sf').addClass(city);
			return false;
		});
		
		// make three homepage box titles same height
		var h = 0;
		$('.homepage-posts .entry-title','#homepage-posts').each(function(){ 
			if($(this).height() > h) h = $(this).height();
		}).height(h);
		
		// then, make the boxes same height too
		h = 0;
		$('.the_content_tata','#homepage-posts').each(function(){ 
			if($(this).height() > h) h = $(this).height();
		}).height(h);
						
		// make two footer boxes same height
		var h = ($('#footer-box-1 .aside').height() > $('#footer-box-2 .aside').height())?$('#footer-box-1 .aside').height():$('#footer-box-2 .aside').height();
		$('#footer-box-1 .aside,#footer-box-2 .aside').height(h);
		
		
		
		
					
	});
	
	$(document).ready(function(){
			// finally, make the content same height as the longer one from content and sidebar
if($('#aside').height() > $('#content').height()) {
$('#content').css({'min-height':$('#aside').height()}); }
	/*
	$(".innererer").each(function(){
		//alert($(this).find('h1.entry-title').outerWidth());
			w = $(this).width() - $(this).find('h1.entry-title').outerWidth(true)-50;
			$(this).find('#subpages').width(w);
		});
	*/	
		
		window.setInterval(function () {
       var nexti = $('#banner_links li a.active').parent('li').next('li');
       if(nexti.length == 0) nexti = $('#banner_links li:first');
       nexti.click();
},5000);
		
	});