/**
 * Provide onclick functionality for the TV help buttons
 *
 * @package agdistis
 * @version $Id: tv_help.js,v 1.3 2009/11/13 17:03:40 jlu Exp $
 */
$(document).ready(
	function()
	{

		// these functions are populated by synlib.js, but the code scanner needs placeholders here

		var hide_disruptive_overlay_elements = hide_disruptive_overlay_elements || function () { };
		var show_disruptive_overlay_elements = show_disruptive_overlay_elements || function () { };


		var repl_id = 'tv_popup_replacement_container',
		    repl, pop_cont, pop;

		// move popup to end of DOM

		$('body').append('<div id="' + repl_id + '"><div class="tv_nav_info"></div></div>');
		repl = $('#' + repl_id);
		$('.tv_nav_info', repl).css('position', 'static').append($('#tv_popup_container').remove());
		pop_cont = $('#tv_popup_container').css('position', 'static');
		pop = $('#tv_popup').css('position', 'absolute');


		$("#tv_ordering_instructions").click(
			function(ev)
			{
				var top = $('#tv_ordering_instructions').offset().top + 20,
				    left = ev.pageX - 305;

				pop.css({top: top + 'px', left: left + 'px'});

				hide_disruptive_overlay_elements();
				pop_cont.show();
				return false;
			}
		);
		$("#tv_popup_close").click(
			function()
			{

				pop_cont.hide();	
				show_disruptive_overlay_elements();
				return false;
			}
		);
	}
);
