/**
 * Provide onclick functionality for the TV help buttons
 *
 * @package agdistis
 * @version $Id: tv_help.js,v 1.4 2009/11/20 15:56:07 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;
			}
		);

		// IE6 breaks links displayed over a transparent png background
		// this makes the whole popup clickable for closing (IE6 only)
		var closer = ($.browser.msie && $.browser.version == '6.0') ? pop : $('#tv_popup_close');

		closer.click(
			function()
			{
				pop_cont.hide();	
				show_disruptive_overlay_elements();
				return false;
			}
		);
	}
);
