//Activating news slider
$(function() {
	
		$( "#news_slider" ).accessNews({
			headline : "The News",
			speed : "normal",
			slideBy : 4
		});
		
	});


Cufon.replace("h3");
Cufon.replace("h4");
Cufon.replace("#content_date");
Cufon.replace(".overview_date");
Cufon.replace("#news_slider_nav a");
Cufon.replace("#go_back");
Cufon.replace("#menu ul li a");

//OPENS LINKS IN NEW WINDOW/TAB
$(function() {
	$(".external").attr("target","_blank");
});

function resizeImage() {
	var window_height = parseInt($(window).height());
	var window_width  = parseInt($(window).width());
	
	var image_width = parseInt($('#background-image').attr('width'));
	var image_height = parseInt($('#background-image').attr('height'));

	var height_ratio = window_height / image_height
	var width_ratio = window_width / image_width
	
	
	if (height_ratio > width_ratio) {
		var new_height = Math.ceil(height_ratio * image_height);
		var new_width = Math.ceil(height_ratio * image_width);
		
	} else {
		var new_height = Math.ceil(width_ratio * image_height);
		var new_width = Math.ceil(width_ratio * image_width)
	}

	$('#background-image').attr('width', new_width);
	$('#background-image').attr('height', new_height);
	
	// Render offsets
	var lMargin = Math.floor((new_width-window_width)/2);
	var hMargin = Math.floor((new_height-window_height)/2);
	$('#background-image').css('margin-left', '-'+lMargin+'px');
	$('#background-image').css('margin-top', '-'+hMargin+'px');
	
}