// Attach the functions below to the relevant links on the page
$(function(){
		   
	$('a.metadata_action_bookmark').click(function(e){
		e.preventDefault();
		metadataBookmark();
	});
	
	$('a.metadata_action_fontsize').click(function(e){
		e.preventDefault();
		metadataFontsize();
	});

	$('a.product_print').click(function(e) {
		e.preventDefault();
		metadataPrint();
	});

});

// Add to favourites functionality
function metadataBookmark() {
	
	var title = $('title').html() + ' : ' + $('h1.article_title').html();
	var url = window.location.href;
	
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url, "");
	} else if (window.external) { // IE Favorite
		window.external.AddFavorite(url, title);
	} else if (window.opera && window.print) { // Opera Hotlist
		return true;
	}
}

// Send page via mail
function metadataEmail() {
	document.location = "mailto:?subject=Audiovisual - an article for you&Body=" + escape(window.location.href);
}
	
	
// Print current page
function metadataPrint() {
	
	// To do: PREP PRINT.CSS for this to work correctly	
	window.print();
	
}

// Change font size
function metadataFontsize() {
        
	// Get the pixel size of the font inside the article body
	var fontSize = parseInt($('.article_body').css('font-size').replace('px',''));

	if (fontSize) {
		fontSize = fontSize + 2;
		if (fontSize > 18) { fontSize = 13; }
		$('.article_body')
		.css({
			'fontSize':fontSize,
			'lineHeight':'1.5em'
		});
		// Set the FlashArticleFontSize cookie
		$.cookies.set('sportDayFontSize',fontSize);
	}

}