$j(function(){

	$j("body").append('<iframe id="popup" frameborder="0" style="display:none;text-align:left;padding:0;margin:0;"></iframe>');
	$j("#popup").dialog({ autoOpen: false, modal: true });

	$j( "#popup" ).live( "dialogclose", function(event, ui) {
	    $j(this).attr("src", "");
	    $j("html").css({"overflow":"auto"});
	});

	$j(".popup").live('click', function(){

		var title = $j(this).attr("title");
		var link = $j(this).attr("data-url");
		var height = $j(this).attr("data-height");
		var width = $j(this).attr("data-width");

		if(width < 1)
		{
		    width = $j(window).width() * 0.95;
		}

		if(height < 1)
		{
		    height = $j(window).height() * 0.92;
		}

		$j("#popup").attr("src", link);

		$j("#popup").dialog( "option", "title", title );

		$j("#popup").dialog( "option", "width", parseInt(width) );

		$j("#popup").dialog( "option", "height", parseInt(height) );

		$j("html").css({"overflow":"hidden"});

		$j("#popup").dialog('open');

		$j("#popup").css({"width" : "100%"});

		return false;
	});

	$j(".termTrack").live('click', function(){
	    $j.ajax({
		    type: "POST",
		    url: "/share/ajax/page/term_engine_track.php",
		    data:
		    {
			    "user" : $j("#user_id").val(),
			    "engine" : $j(this).attr("data-engine"),
			    "profile" : $j("#profile_id").val()
		    },
		    success: function(result){}
	    });
	});
});
