$(document).ready(
	function()
	{
		$(".editAlbumHide").hide();
		$("#albumAccordion").accordion({header: 'h2'});
		$("#imageAccordion").accordion({header: 'h2'});
		$("#uploadify").uploadify({
			'uploader'       : '../manage/uploadify.swf',
			'script'         : '../manage/uploadify.php',
			'cancelImg'      : '../images/cancel.png',
			'fileDesc'       : 'Allowable Images',
			'fileExt'        : '*.jpg;*.jpeg;*.png;*.gif',
			'buttonText'     : 'SELECT',
			'queueID'        : 'fileQueue',
			'auto'           : false,
			'multi'          : true
		});
	}
);

function getAlbumInfo(albumID)
{
	if (albumID != 0)
	{
		$.post("../manage/albumList.php", {fetchAlbumID: albumID}, function(data)
		{
			if (data.length > 0)
			{
				albumArray = data.split("|");
				document.getElementById("editAlbumName").value = albumArray[0];
				document.getElementById("editAlbumDesc").value = albumArray[1];
				parentSelect = document.getElementById("editAlbumPID");
				parentSelect.options.length = 0;
				parentSelect.add(new Option("(main)", "0"), null);
				j = 1;

				for (i = 3; i < albumArray.length; i++)
				{
					key = albumArray[i];
					value = albumArray[i+1];
					
					if (""+albumID+"" != key)
						parentSelect.add(new Option(value, key), null);

					if (albumArray[2] == key)
						parentSelect.options[j].selected = true;
					
					i++;
					j++;
				}
			}
		});
	}
}

function getAlbumImages(albumID)
{
	if (albumID != 0)
	{
		$.post("../manage/albumImages.php", {fetchAlbumID: albumID}, function(data)
		{
			if (data.length > 0)
			{
				$("#getAlbumImages").html(data);
			}
		});
	}
}

function getImagesMove(albumID)
{
	if (albumID != 0)
	{
		$.post("../manage/albumMove.php", {fetchAlbumID: albumID}, function(data)
		{
			if (data.length > 0)
			{
				$("#getImagesMove").html(data);
			}
		});
	}
}

function showLogHere(show)
{
	if (show)
	{
		$.post("../manage/showLog.php", {showLog: true}, function(data)
		{
			if (data.length > 0)
			{
				$("#showLogMessages").html(data);
			}
		});
	}
}
