jQuery(document).ready(function() {
	//PopUp reference variable
	var popObj = jQuery('#popupLink');
	var popRef = popObj.attr('href');
	//Get the JSON data for the pop-up graphic
	jQuery.ajax({
		type: "GET",
		url: popRef,
		dataType: "json",
		success: function(data) {
			if ( data != null && data != "" )
			{
				var output = '<a ';
				var target = "";
				var link = data.link_url;
				
				var link_srch = /^\[(.*)\]/g;

				if (link_srch.test(link) == true)
				{
					target = link.substring(1, link_srch.lastIndex - 1);
					link = link.substring(link_srch.lastIndex, link.length);
					
					output += 'target="' + target + '" '; 
				}
				
				output += 'href="' + link + '"><img alt="" src="' + data.image_location + '" border="0" /></a>';
				
				var popParent = popObj.parent();
				
				//set the html of the parent. clears the link.
				popParent.html(output);
				
				//load the pop-up into the window
				popParent.overlay({
					api: true,
					closeOnClick: false,
					expose: {
						color: '#111',
						loadSpeed: 200,
						opacity: 0.8
					}
				}).load();
			}
		}
	});
});