/**
*
*/
function refreshUpdates(who)
{
	$("#refresh-loading").show();

	who     = who - 543;
	var url = "http://" + location.host + "/ajax/history.php?who=" + who + "&page=1&secret=" + secret;

	$.get(url, null, function(data){
		if( data != 'false' )
		{
			if( data == 'END-OF-DATA' )
			{
			}
			else
			{
				updCurPage = 1;

				var docs = '' 
					+ '<div>' 
					+ '<p>' 
					+ '  <img src="/imgs/indicator.gif" id="refresh-loading" alt="" style="float: right; display: none;" />' 
					+ '  <a href="javascript:;" onclick="refreshUpdates(' + (who + 543) + ');" class="clean" title="refresh"><img src="/imgs/icons/mini/action_refresh.gif" alt="refresh" class="clean ifn" /></a>'
					+ '  <strong>Recents</strong> ' 
					+ '</p>' 
					+ '</div>'
					+ data
					+ '<div id="mr-more-upds">'
					+ '	<p>'
					+ '		<img src="/imgs/indicator.gif" id="more-loading" alt="" style="float: right; display: none;" />'
					+ '		<a href="javascript:;" onclick="moreUpdates(' + (who + 543) + ');" class="small">more...</a>'
					+ '	</p>'
					+ '</div>'
				;
				$('#mr-updates').html(docs);
			}
		}
		else
		{
			alert("เกิดข้อผิดพลาดบางประการ กรุณา refresh หน้านี้ใหม่แล้วลองอีกทีค่ะ...");
		}
		$("#refresh-loading").hide();
		$("div#mr-updates").find("img.ifn").hover(
			function(){
				$(this).css("opacity","1.0");
				$(this).css("alpha",  "alpha(opacity=100)");
			}, 
			function(){
				$(this).css("opacity","0.4");
				$(this).css("alpha",  "alpha(opacity=40)");
			}
		);
	});
}
/**
*
*/
function moreUpdates(who)
{
	$("#more-loading").show();
	
	who     = who - 543;
	var url = "http://" + location.host + "/ajax/history.php?who=" + who + "&page=" + (updCurPage+1) + "&secret=" + secret;

	$.get(url, null, function(data){
		if( data != 'false' )
		{
			if( data == 'END-OF-DATA' )
			{
				$('#mr-more-upds').before('<div><p><small>แสดงข้อมูลทั้งหมดแล้ว...</small></p></div>');
				$('#mr-more-upds').hide();
			}
			else
			{
				updCurPage = updCurPage + 1;
				$('#mr-more-upds').before(data);
			}
		}
		else
		{
			alert("เกิดข้อผิดพลาดบางประการ กรุณา refresh หน้านี้ใหม่แล้วลองอีกทีค่ะ...");
		}
		$("#more-loading").hide();
		$("div#mr-updates").find("img.ifn").hover(
			function(){
				$(this).css("opacity","1.0");
				$(this).css("alpha",  "alpha(opacity=100)");
			}, 
			function(){
				$(this).css("opacity","0.4");
				$(this).css("alpha",  "alpha(opacity=40)");
			}
		);
	});
}
