$(function()
{
	var hideDelay = 000;  
	var currentID;
	var hideTimer = null;

	// One instance that's reused to show info for the current person
	/*var container = $('<div id="currencyPopupContainer">'
      + '<table width="" border="0" cellspacing="0" cellpadding="0" align="center" class="currencyPopupPopup">'
      + '<tr>'
      + '   <td class="corner topLeft"></td>'
      + '   <td class="top"></td>'
      + '   <td class="corner topRight"></td>'
      + '</tr>'
      + '<tr>'
      + '   <td class="left">&nbsp;</td>'
      + '   <td><div id="currencyPopupContent"></div></td>'
      + '   <td class="right">&nbsp;</td>'
      + '</tr>'
      + '<tr>'
      + '   <td class="corner bottomLeft">&nbsp;</td>'
      + '   <td class="bottom">&nbsp;</td>'
      + '   <td class="corner bottomRight"></td>'
      + '</tr>'
      + '</table>'
      + '</div>');*/
	
	var container = $('<div id="currencyPopupContainer">'
      + '<div class="currencyPopupPopup">'
      + '   <div id="currencyPopupContent"></div>'
      + '</div>'
      + '</div>');

	$('body').append(container);

	$('.currencyConverter').live('mouseover', function()
	{
		var setting = $(this).attr('rel').split(',');
		var price = setting[0];
		var lang = setting[1];
		var pathFile = "";
		
		if (price == '')
			return;
			
		if(lang == "en" || lang == ""){
			pathFile = "currency.php";
		}else{
			pathFile = "../currency.php";
		}

		if (hideTimer)
			clearTimeout(hideTimer);

		var pos = $(this).offset();
		var width = $(this).width();
		container.css({
			//left: (pos.left + width) + 'px',
			left: pos.left + 'px',
			//top: pos.top - 20 + 'px'
			top: pos.top - 100 + 'px'
		});
		$('#currencyPopupContent').css({
			'background-image':'url(http://www.u5uk.com/you/akando/INC/templates/June2010_theme/images/wait.gif)'
		});

		$('#currencyPopupContent').html('&nbsp;');
		
		$.ajax({
			type: 'GET',
			//url: 'currency.php',
			url: pathFile,
			data: 'price=' + price,
			success: function(data)
			{
				//alert(data);
				$('#currencyPopupContent').html(data);
				$('#currencyPopupContent').css({
					'background-image':'none'
				});
			}
		});

		container.css('display', 'block');
	});

	$('.currencyConverter').live('mouseout', function()
	{
		if (hideTimer)
			clearTimeout(hideTimer);
		hideTimer = setTimeout(function()
		{
			container.css('display', 'none');
		}, hideDelay);
	});

	// Allow mouse over of details without hiding details
	$('#currencyPopupContainer').mouseover(function()
	{
		if (hideTimer)
			clearTimeout(hideTimer);
	});

	// Hide after mouseout
	$('#currencyPopupContainer').mouseout(function()
	{
		if (hideTimer)
			clearTimeout(hideTimer);
		hideTimer = setTimeout(function()
		{
			container.css('display', 'none');
		}, hideDelay);
	});
	
});
