// This JS library manages the hiding/showing of the Print and Add to My Save Articles links in the article tools section of an article page
// jquery functions
$(document).ready(function(){
	// add print link
	$('#tools').prepend('<li class="print"><a href="#print" title="Print this news article">Print</a></li>');
	$('#tools li.print a').click(function() {
		window.print();
		return false;
	});
	
	// show save link
	$('#tools li.clip').show();	
	
	// show share article list
	$('div#bookmarkList').hide();
	
	$('#shareArticle h3 a').toggle(function() {
		$('#shareArticle div#bookmarkList').fadeIn('slow', function(){
			$(this).addClass('showList');
		});
	}, function() {
		$('#shareArticle div#bookmarkList').fadeOut('slow', function(){
			$(this).removeAttr('class');
		});
	});
});


var LinkSaver			= {
	saveLink : function (sActionURL,eElement,sSuccess,sFailure) {
		$.ajax({url: sActionURL, 
			type: 'GET',
			success: function(data){
				LinkSaver.saveLinkLoaded(eElement, sSuccess);
			},
			error: function(data) {
				LinkSaver.saveLinkLoaded(eElement,sFailure);
			}
		});
	},
	
	saveLinkLoaded : function (eElement,sMessage) {
		$(eElement).html(sMessage);
		eElement.onclick		= '';
	},
	
	toggleMessage : function (sID) {
		$('#' + sID).toggle();
	}
}
