function albumsOnUpdate() {
	var album = document.getElementsByClassName("ai");
	var string = "";
	for (i = 0; i < album.length; i++) {
		if (i > 0) string += "|";
		string += album[i].id.replace("ai_", "");
	}
	new Ajax.Request("/?ajaxReq=saveAlbumItemOrder&album_id=" + album_id + "&string=" + string);
}

function deleteAlbumItem(id) {
    new Ajax.Request("/?ajaxReq=deleteAlbumItem&album_id=" + album_id + "&id=" + id);
    $("ai_" + id).remove();
    Sortable.create('sort_album', { tag:'div', only:'ai', constraint:false, onUpdate:albumsOnUpdate });
}

function albumsHelpHide() {
	$("help").hide();
	new Ajax.Request("/?ajaxReq=albumsHelpHide&album_id=" + album_id);
}

function checkTitle() {
	var title = document.form_create_an_album.title.value;
	if (title.length < 1) {
		$('span_title').innerHTML = 'You must enter a title.';
	} else {
		$('span_title').innerHTML = '';
	}
}

function postEditAlbumDesc(id) {
	new Ajax.Request("/?ajaxReq=postEditAlbumDesc&id=" + id + "&desc=" + escape(document.form_desc.desc.value));

	var desc = document.form_desc.desc.value;
	if (!desc) desc = "Click to Add a Description";

	$("desc").innerHTML = desc;
	$("desc_edit").hide();
	$("desc").show();
}