$(document).ready(function(){
		//load image:
		var mafImg = $('<img />').attr('src', '/images/maf3.png');
		var dialogueImg = $('<img />').attr('src', '/images/dialogue.png');
		
	$('.articleContent img').load(function(){
		if($(this).width() > 600){
			var width = $(this).width();
			var height = $(this).height();
			
			if(width > height)
				var perc = (550 / width);
			else
				var perc = (550 / height);
				
			var new_width = Math.round(width * perc);
			var new_height = Math.round(height * perc);
			
			//$(this).animate({width:new_width, height:new_height});
			$(this).css({'width':new_width, 'height':new_height})
			
			$(this).wrap($('<a />').attr('href', $(this).attr('src')));
		}
	});
	
	$('#articleAuthor').click(function(){
		if($('#infoDiv').css('display') == 'none'){
			var position = $('#articleAuthor').offset();
			var top = position.top + 12;
			var left = position.left - 20;
			$('#infoDiv').css({'top':top, 'left':left}).fadeIn('normal');
		} else {
			$('#infoDiv').fadeOut('normal');
		}
	});
	
	$('.btnText').hover(function(){ 
		$(this).css({'color':'#ae0000', 'cursor':'pointer'});
	}, function() {
		$(this).css({'color':'#ff0000'});
	}).mousedown(function(){
		$(this).css({'color':'#ff7272'});
	}).mouseup(function(){
		$(this).css({'color':'#ff0000'});
	}).click(function(){
		if($('#infoDiv').css('display') == 'block'){
			$('#infoDiv').fadeOut('normal');
		}
	});
	
	$('.downloadImage')
	.mouseenter(function() { $(this).css('opacity','0.8'); })
	.mouseleave(function() { $(this).css('opacity','1'); })
});
