// JavaScript Document


function displayProcessing()
{
	$('content').hide();
	$('processingContainer').appear();
	delay(2);
	return false;
}
function uploadComplete(element,imageId)
{
	$(element).addClassName('success').update("Successfully Uploaded!");
	if(element == 'large')
		$('imageId').value = imageId;
	else if(element == 'thumb')
		$('thumbId').value = imageId;
}
function editAdminRecent()
{
	$('editRecent').hide();
	$('editProcessing').show();
	window.setTimeout(
	function()
	{
	$('adminEditRecentForm').request(
		{
			onSuccess: function()
						{
							$('editProcessing').hide();
							$('editRecentSuccess').appear();
							window.setTimeout(
								function()
								{
									window.location = "adminRecent.php";
								}, 2000 );
							
						},
			onFailure: function()
						{
							$('editProcessing').hide();
							$('editRecentFailure').appear();
						}
						
		});
	}, 1000 );

}
function editRecentById(newsId)
{
	$('editRecentSection').hide();
	var url = "inc/ajax.php?do=editRecentById&newsId=" + newsId;
	new Ajax.Request(url,
		{
			method: 'post',
			onSuccess: function(html)
						{
							var hash = new Hash(html.responseText.evalJSON());
							$('recentId').value = hash.get('recentId');
							$('editTitle').value = hash.get('editTitle');
							$('imageThumb').src = hash.get('imageThumb');
							$('editDescription').innerHTML = hash.get('editDescription');
							$('editContent').innerHTML = hash.get('editContent');
							$('editPostDateTime').value = hash.get('editPostDateTime');
							Effect.BlindDown('editRecent');
														
						},
			onFailure: function(html)
						{
							alert(html);
						}
		});
}
function addAdminRecent()
{
	if($('imageId').value != 0 || $('thumbId').value != 0)
	{
		$('adminRecent').hide();
		$('adminProcessing').show();
		window.setTimeout(
		function()
		{
		$('adminRecentForm').request(
			{
				onSuccess: function()
							{
								$('adminProcessing').hide();
								$('addRecentSuccess').appear();
								window.setTimeout(
									function()
									{
										window.location = "adminRecent.php";
									}, 2000 );
								
							},
				onFailure: function()
							{
								$('adminProcessing').hide();
								$('addRecentFailure').appear();
							}
							
			});
		}, 1000 );
	}
	else
	{
		alert("You must uploaded a Image Thumb/Image Large!");
	}
}
//////////////////////////////////////////////////////////////////////////////////
function editAdminNews()
{
	$('editNews').hide();
	$('editProcessing').show();
	window.setTimeout(
	function()
	{
	$('adminEditNewsForm').request(
		{
			onSuccess: function()
						{
							$('editProcessing').hide();
							$('editNewsSuccess').appear();
							window.setTimeout(
								function()
								{
									window.location = "adminNews.php";
								}, 2000 );
							
						},
			onFailure: function()
						{
							$('editProcessing').hide();
							$('editNewsFailure').appear();
						}
						
		});
	}, 1000 );

}
function editNewsById(newsId)
{
	$('editNewsSection').hide();
	var url = "inc/ajax.php?do=editNewsById&newsId=" + newsId;
	new Ajax.Request(url,
		{
			method: 'post',
			onSuccess: function(html)
						{
							var hash = new Hash(html.responseText.evalJSON());
							$('newsId').value = hash.get('newsId');
							$('editTitle').value = hash.get('editTitle');
							$('editContent').innerHTML = hash.get('editContent');
							$('editPostDateTime').value = hash.get('editPostDateTime');
							Effect.BlindDown('editNews');
														
						},
			onFailure: function()
						{
							alert("failure");
						}
		});
}
function addAdminNews()
{
	$('adminNews').hide();
	$('adminProcessing').show();
	window.setTimeout(
	function()
	{
	$('adminNewsForm').request(
		{
			onSuccess: function()
						{
							$('adminProcessing').hide();
							$('addNewsSuccess').appear();
							window.setTimeout(
								function()
								{
									window.location = "adminNews.php";
								}, 2000 );
							
						},
			onFailure: function()
						{
							$('adminProcessing').hide();
							$('addNewsFailure').appear();
						}
						
		});
	}, 1000 );
}
function addAdminNote()
{
	$('adminNote').hide();
	$('adminProcessing').appear();
	$('adminNoteForm').request(
		{
			onSuccess: function()
						{
							$('adminProcessing').hide();
							$('addNoteSuccess').appear();
							window.setTimeout(
								function()
								{
									window.location = "adminNotes.php";
								}, 2000 );
							
						},
			onFailure: function()
						{
							$('adminProcessing').hide();
							$('addNoteFailure').appear();
						}
						
		});
}
						
	