//function used to attach the ajax handlers to the external link items
$(document).ready(function() {
	var document = $(this);
	
	// only do this if we haven't already init the ajaxManager
	if (!$.ajaxManager.ajaxSettings.arguments)
	{
		$.ajaxManager.initialise({
			responseType: $.ajaxManager.dataType.JSON,
			requestType: $.ajaxManager.requestType.POST
		});
    }
	
	document.find('.mp-ajax-external-link').click(function(event) {
		event.preventDefault();
		
		var link = $(this);
		var id = link.attr('id');
		var href = link.attr('href');

		//make the ajax call
		$.ajaxManager.updateUrl(href);
		$.ajaxManager.onSuccess = function(p_response) {
			processAjaxResponse(p_response);
		};
		$.ajaxManager.makeRequest();
		
	});
	
	//internal method used to wire up the link
	var processAjaxResponse = function(response) {
		var url = response.arguments.lnk;
		open(url,'myWin');
	}
});
