$(document).ready(function()
{
  $(".mo").hover(function()
  {
	  $(this).css({'background-color' : '#F5F5DC' });
	},
	function()
	{
	  $(this).css({'background-color' : '#fff' });
	});
});

function show(val)
{
	$("#"+val).slideDown('slow');
	$("#"+val+"_toggle").html('<a href="javascript: void(0);"><img src="images/delete.png" border="0" alt="Click To Hide Individual URL Allocation" title="Click To Hide Individual URL Allocation" onclick="hide(\''+val+'\');"></a>');
}

function hide(val)
{
	$("#"+val).slideUp('slow');
	$("#"+val+"_toggle").html('<a href="javascript: void(0);"><img src="images/add.png" border="0" alt="Click To See Individual URL Allocation" title="Click To See Individual URL Allocation" onclick="show(\''+val+'\');"></a>');
}

function remove(val, te, krmid)
{
	if (confirm('Are you sure you want to REMOVE this traffic exchange from your TE Command Post?'))
	{
		$("#"+val).slideUp('slow', function()
		{
			$("#"+val+"_table").fadeOut('slow', function()
			{
				$.post("worker.php", { action: "doRemoveTe", te_id: te, who: krmid } );
			})
		});
	}
}

function doLoad(te, kval, uval, ptype)
{
	if (!uval)
	{
		return;
	}
	
	$.get('tecp_get_html.php', { te_id: te, k: kval, u: uval, type: ptype }, function(data){
		
		$('#loading_'+te).css({'display' : 'none'});
		
		if (!data)
		{
			return;
		}
		
		$('#te_'+te).html(data);
		
		$.get('a.php', { te_id: te, k: kval, u: uval, type: ptype }, function(data){
			var str = data.split('|');
			var assigned = str[0];
			var unassigned = str[1];
			$('#assigned_'+te).text(assigned);
			$('#unassigned_'+te).text(unassigned);
		});
	});
}

function doRedirect2(rtype)
{
	if (!rtype)
	{
		window.location = 'http://www.tecommandpost.com/member.php?step=1';
	}
	
	if (rtype == 'credits')
	{
		window.location = 'http://www.tecommandpost.com/tecp_credits.php';
		return;
	}
	
	if (rtype == 'banners')
	{
		window.location = 'http://www.tecommandpost.com/tecp_banners.php';
		return;
	}
	
	if (rtype == 'textlinks')
	{
		window.location = 'http://www.tecommandpost.com/tecp_textlinks.php';
		return;
	}
	
	if (rtype == 'alerts')
	{
		window.location = 'http://www.tecommandpost.com/tecp_te_alerts.php';
		return;
	}
	
	if (rtype == 'com')
	{
		window.location = 'http://www.tecommandpost.com/tecp_commissions.php';
		return;
	}
	
	window.location = 'http://www.tecommandpost.com/member.php?step=1';
	return;
}

function doRedirect(rtype)
{
	setTimeout('redirectGo(\''+rtype+'\')', 5000);
}

function redirectGo(rtype)
{
	if (!rtype)
	{
		window.location = 'http://www.tecommandpost.com/member.php?step=1';
		return;
	}
	
	if (rtype == 'credits' || rtype == 'banners' || rtype == 'textlinks')
	{
		window.location = 'http://www.tecommandpost.com/tecp_credits.php';
		return;
	}
	
	if (rtype == 'credits')
	{
		window.location = 'http://www.tecommandpost.com/tecp_commissions.php';
		return;
	}
	
	//if (rtype == 'banners')
	//{
	//	window.location = 'http://www.tecommandpost.com/tecp_banners.php';
	//	return;
	//}
	
	//if (rtype == 'textlinks')
	//{
	//	window.location = 'http://www.tecommandpost.com/tecp_textlinks.php';
	//	return;
	//}
	
	window.location = 'http://www.tecommandpost.com/member.php?step=1';
	return;
}

function doSilentLoad(te, kval, uval)
{
	//alert(te+' '+k+' '+u);
	$.get('tecp_get.php', { te_id: te, k: kval, u: uval });
}

function doAddTE(teid)
{
	var refval = document.getElementById('te_ref_'+teid).value;
	
	if (!refval)
	{
		refval = '';
	}
	
	window.location = 'http://www.tecommandpost.com/tecp_te_select.php?action=doTeSelect&teselect='+teid+'&refval='+refval;
	return;
}
