/* EQUALIZER */
function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}

$(window).load(function(){
	equalHeight($('#promos .promo'));
    equalHeight($('#teasers .teaser'));
});

$(function(){
	function moveBioImage(){
		$('.bioDetails').each(function(){
			var image = $(this).children('.imgBlock');
			var target = $(this).children('p:first');
			image.prependTo(target);
		
		});
	}
	$('[title]').attr('title', function(i, title) {
    	$(this).data('title', title).removeAttr('title');
	});
	
	$("a[href^='http:']:not([href*='" + window.location.host + "'])").each(function() {               
        $(this).attr("target", "_blank");
    });
    
    $('#content-full img').each(function(){
    	var parId = $(this).parent().attr('id');
    	if(parId !== 'mainart'){
    		var alignClass = $(this).attr('class');
    		var cutline = $(this).attr('alt');
    		var imgWidth = $(this).width();
    		if(imgWidth < 100){
    			imgWidth = '100%';
    		}
    		$(this).wrap('<div class="imgBlock" />');
    		var newBlock = $(this).parent('.imgBlock');
    		newBlock.addClass(alignClass).append('<p class="cutline" style="width:'+imgWidth+'px;">'+cutline+'</p>');
    		$(this).removeClass(alignClass);
    		var parClass = newBlock.parent().attr('class');
    		if(parClass == 'bioDetails'){
    			console.log('bio');
    			moveBioImage();
    		}    		
    	}
    });
    
});


