
//
// album-edit.js
// by Jonathan A. Marshall, wellrounded.com
// for New York Magazine, 2006-09-13
//

var albumEditClosed=null,albumEditOpen=null, albumEditTitle=null;

function albumEdit(n){
}

function albumDelete(n){
 var albumName=document.getElementById('albumName'+n).value;
 if(!confirm('Are you sure you want to delete your album\n"'+albumName+'"?'))return;
 document.getElementById('rm'+n).value = "remove_album";
 document.getElementById('albumEditForm'+n).submit();
}

function albumEditCancel(){
}

function albumEditSave(n){
 var albumName=document.getElementById('albumName'+n).value;
 if((albumName=albumNameValid(albumName))==null)return false;
 //document.getElementById('albumName'+n).value=albumName;
 //document.getElementById('albumEditForm'+n).submit();
 return true;
}

function albumNameValid(name){
 name=name.replace(/^\s+|\s+$/g,'');
 if(name.length>64)return albumAlert('be too long');
 if(name.length<2)return albumAlert('be too short');
 if(name == 'Enter Album Name Here' )return albumAlert('have a non permitted name');
 if(name.match(/[^\w \.\,\:\;\(\)\*\$\@\!\'\"]/))return albumAlert('contain impermissible characters');
 return name;
}

function albumMakePublic(n) {
	document.getElementById('rm'+n).value = "mark_album_shared";
	document.getElementById('albumEditForm'+n).submit();
}

function albumMakePrivate(n) {
	document.getElementById('rm'+n).value = "mark_album_private";
	document.getElementById('albumEditForm'+n).submit();
}

function albumAlert(s){alert("Your new album name would\n"+s+".\nPlease type a different album name.");return null;}
