
function updatePhotoData(artistId){
	document.siteMasterForm.submit();
}
//START GET PHOTO ALBUMS
function getAlbums(){
//Define variables
var photosVar = new photosClass;
photosVar.setHTTPMethod("POST");

//Removes all options for the select box
var i;
var selectbox = document.addPhotosForm.albumID;
selectbox.length = 0;

//Call CFC Function
var photosReturn = photosVar.getAlbums();

for(i=0;i<photosReturn.DATA.length;i++){
	var newOption = document.addPhotosForm.albumID;
	newOption.options[newOption.options.length] = new Option(photosReturn.DATA[i][photosReturn.COLUMNS.findIdx('TITLE')], photosReturn.DATA[i][photosReturn.COLUMNS.findIdx('PHOTOID')]);
	if(i==0){ document.addPhotosForm.albumID.options[i].selected=true; }
}}
//END GET PHOTO ALBUMS





//START Manage Images
function displayUploadImage(typeID,type){
if(type == 'video'){
	document.getElementById('uploadImageFrame').contentWindow.window.location='frameUploadImage.cfm?type='+type+'&id='+typeID; //Reloads the frame
}else{
	if(type == 'editVideo'){ type = 'video'}

	document.getElementById('uploadImageFrame').contentWindow.window.location='scripts/frameUploadImage.cfm?type='+type+'&id='+typeID; //Reloads the frame
}
document.getElementById('uploadImageFrame').height='60';
document.getElementById('imageUploadButtons').style.display='';
document.getElementById('imageCropButtons').style.display='none';
document.getElementById('uploadImageModal').style.display='';
scroll(0,0);
}
//END Manage Images





//START UPLOAD IMAGE
function uploadImage(){
document.getElementById('uploadImageModalContent').style.display='none';
document.getElementById('imageUploadButtons').style.display='none';
document.getElementById('uploadImageModalError').style.display='none';
document.getElementById('uploadImageModalError').innerHTML='';
document.getElementById('uploadImageModalLoader').style.display='';

var imageVal = document.getElementById('uploadImageFrame').contentWindow.document.uploadImageForm.newImage.value;

setTimeout(function(){
if(imageVal == ''){
document.getElementById('uploadImageModalError').innerHTML='Please select an image to upload.';
document.getElementById('uploadImageModalError').style.display='';
document.getElementById('uploadImageModalLoader').style.display='none';
document.getElementById('uploadImageModalContent').style.display='';
document.getElementById('imageUploadButtons').style.display='';
}else{
document.getElementById('uploadImageFrame').contentWindow.document.uploadImageForm.submit();
}
},500);

}
//END UPLOAD IMAGE





//START CROP IMAGE
function cropImage(){
document.getElementById('uploadImageModalContent').style.display='none';
document.getElementById('imageCropButtons').style.display='none';
document.getElementById('uploadImageModalLoader').style.display='';
document.getElementById('orignalShow').style.display='none';
document.getElementById('uploadImageFrame').contentWindow.document.cropImage.submit();

setTimeout(function(){
document.getElementById('uploadImageModalContent').style.display='';
document.getElementById('imageCropButtons').style.display='';
document.getElementById('uploadImageModalLoader').style.display='none';
},500);

}
//END CROP IMAGE

//START USING ORIGNAL IMAGE
function useOrignal(){
document.getElementById('uploadImageFrame').contentWindow.document.cropImage.orignal.value='yes';
document.getElementById('uploadImageModalContent').style.display='none';
document.getElementById('imageCropButtons').style.display='none';
document.getElementById('uploadImageModalLoader').style.display='';
document.getElementById('orignalShow').style.display='none';
document.getElementById('uploadImageFrame').contentWindow.document.cropImage.submit();
setTimeout(function(){
document.getElementById('uploadImageModalContent').style.display='';
document.getElementById('imageCropButtons').style.display='';
document.getElementById('uploadImageModalLoader').style.display='none';
},500);

}
//END USING ORIGNAL IMAGE



//START CLOSE PROFILE MODAL
/*function closeProfileImageModal(){
document.getElementById('profileImageModal').style.display='none';
document.getElementById('profileImageModalContent').style.display='';
document.getElementById('profileImageErrorContainer').style.display='none';
document.getElementById('profileImageLoader').style.display='none';
document.getElementById('profileImageFrame').height='125';
document.getElementById('profileImageCropButtons').style.display='none';
document.getElementById('profileImageUploadButtons').style.display='';

document.getElementById('profileImageFrame').contentWindow.document.profileImageForm.reset();

if(userID != 0){
for(i=1;i<=4;i++){
document.getElementById('profileImageDisplay'+i).innerHTML='<img src="images/avatar.jpg" style="border:1px solid #9ea9b9;"/>';

//START Set values for the hidden image input fields
top.document.forms['addFanProfile'].image.value = 'images/avatar.jpg';
top.document.forms['addMusicianProfile'].image.value = 'images/avatar.jpg';
top.document.forms['addVenueProfile'].image.value = 'images/avatar.jpg';
top.document.forms['addPromoterProfile'].image.value = 'images/avatar.jpg';
//END Set values for the hidden image input fields
}

var profileImageVar = new profileImage;
profileImageVar.deleteProfileImage(userID);

window.profileImageFrame.location='scripts/profileImage.cfm?id='+userID;
}}*/
//END CLOSE PROFILE MODAL


function displayAddPhotos(albumID){
	document.getElementById('addPhotoModal').style.display = '';
	scroll(0,0);
	document.getElementById('photoLoader').style.display='none';
	document.getElementById('photoErrorIn').innerHTML='none';
	document.getElementById('photoModalContent').style.display='';
	document.getElementById('photoErrorContainer').style.display='none';
	document.getElementById('photoButtons').style.display='';
	document.addPhotosForm.albumID.value = albumID;
	document.getElementById('orignalShow').style.display='';
}


function displayEditPhoto(albumID, photoID){
	document.getElementById('editPhotoModal').style.display = '';
	scroll(0,0);
	var photosVar = new photosClass;
	photosVar.setHTTPMethod("POST");
	var photosReturn = photosVar.getAlbumDetails(photoID);
	document.editPhotosForm.photoTitle1.value = photosReturn.DATA[0][photosReturn.COLUMNS.findIdx('TITLE')]
	var description = photosReturn.DATA[0][photosReturn.COLUMNS.findIdx('DESCRIPTION')]
	ColdFusion.RichText.setValue(document.editPhotosForm.photoDescription.id, description);
	document.getElementById("updatePhotoLink").innerHTML = '<a class="defaultLinkHover" style="color:#e22f0c;" href="javascript:updatePhoto(' + albumID +',' + photoID + ');"><b>Update</b></a>'
}

function displayEditAlbum(albumID){
	var photosVar = new photosClass;
	photosVar.setHTTPMethod("POST");
	document.getElementById('editPhotoAlbumModal').style.display = '';
	scroll(0,0);
	var photosReturn = photosVar.getAlbumDetails(albumID);
	document.editPhotoAlbum.title.value = photosReturn.DATA[0][photosReturn.COLUMNS.findIdx('TITLE')]
	var description = photosReturn.DATA[0][photosReturn.COLUMNS.findIdx('DESCRIPTION')]
	ColdFusion.RichText.setValue(document.editPhotoAlbum.description.id, description);
	document.editPhotoAlbum.location.value = photosReturn.DATA[0][photosReturn.COLUMNS.findIdx('LOCATION')]
	document.getElementById("updateAlbumLink").innerHTML = '<a class="defaultLinkHover" style="color:#e22f0c;" href="javascript:updateAlbum(' + albumID + ');"><b>Update</b></a>'
}


function updatePhoto(albumID,photoID) {
	//START EDIT ALBUM
	document.getElementById('editPhotoLoader').style.display='';
	document.getElementById('editPhotoErrorIn').innerHTML='';
	document.getElementById('editPhotoModalContent').style.display='none';
	document.getElementById('editPhotoErrorContainer').style.display='none';
	document.getElementById('editPhotoButtons').style.display='none';

	var photosVar = new photosClass;
	photosVar.setHTTPMethod("POST");
	
	var titleArg = document.editPhotosForm.photoTitle1.value;
	var descriptionArg = ColdFusion.getElementValue(document.editPhotosForm.photoDescription.id, 'editPhotosForm');

	//Call CFC Function
	var photosReturn = photosVar.editAlbum(titleArg,descriptionArg,'',photoID);
	if(photosReturn[0] != false){
		document.getElementById('editPhotoLoader').style.display='none';
		document.getElementById('editPhotoErrorIn').innerHTML=photosReturn[1];
		document.getElementById('editPhotoModalContent').style.display='';
		document.getElementById('editPhotoErrorContainer').style.display='';
		document.getElementById('editPhotoButtons').style.display='';
	}else{
		document.editPhotosForm.reset();
		document.getElementById('editPhotoLoader').style.display='none';
		document.getElementById('editPhotoModal').style.display = 'none';
		document.getElementById('editPhotoErrorIn').innerHTML='';
		document.getElementById('editPhotoModalContent').style.display='';
		document.getElementById('editPhotoErrorContainer').style.display='';
		document.getElementById('editPhotoButtons').style.display='';
		document.editPhotosForm.submit();
	}
	
}
function updateAlbum(albumID) {
	//START EDIT ALBUM
	document.getElementById('editphotoAlbumLoader').style.display='';
	document.getElementById('editphotoAlbumErrorIn').innerHTML='';
	document.getElementById('editphotoAlbumModalContent').style.display='none';
	document.getElementById('editphotoAlbumErrorContainer').style.display='none';
	document.getElementById('editphotoAlbumButtons').style.display='none';

	var photosVar = new photosClass;
	photosVar.setHTTPMethod("POST");
	
	var titleArg = document.editPhotoAlbum.title.value;
	var descriptionArg = ColdFusion.getElementValue(document.editPhotoAlbum.description.id, 'editPhotoAlbum');
	var locationArg = document.editPhotoAlbum.location.value;
	
	//Call CFC Function
	var photosReturn = photosVar.editAlbum(titleArg,descriptionArg,locationArg,albumID);
	if(photosReturn[0] != false){
		document.getElementById('editphotoAlbumLoader').style.display='none';
		document.getElementById('editphotoAlbumErrorIn').innerHTML=photosReturn[1];
		document.getElementById('editphotoAlbumModalContent').style.display='';
		document.getElementById('editphotoAlbumErrorContainer').style.display='';
		document.getElementById('editphotoAlbumButtons').style.display='';
	}else{
		document.editPhotoAlbum.reset();
		document.getElementById('editphotoAlbumLoader').style.display='none';
		document.getElementById('editPhotoAlbumModal').style.display = 'none';
		document.getElementById('editphotoAlbumErrorIn').innerHTML='';
		document.getElementById('editphotoAlbumModalContent').style.display='';
		document.getElementById('editphotoAlbumErrorContainer').style.display='';
		document.getElementById('editphotoAlbumButtons').style.display='';
		document.editPhotoAlbum.submit();
	}
	
}

function changeCover(photoID,source,siteMaster,thumbNail){
	var photosVar = new photosClass;
	photosVar.setHTTPMethod("POST");
	var albumReturn = photosVar.changeAlbumCover(photoID,source,siteMaster,thumbNail);
	document.editAllPhotos.submit();
}


function deletePhoto(photoID,albumId,photoSource,albumSource){
	var profileVar = new profileClass;
	profileVar.setHTTPMethod("POST");
	profileVar.removeItem('photo', photoID);
	if(photoSource == albumSource){
 		var photoVar = new photosClass;
		photoVar.setHTTPMethod("POST");
		photoVar.defaultAlbumCover(albumId);
	}
	document.editAllPhotos.submit();
}


//START ADD PHOTOS
function addPhotos(action){
	
 if(action == 'add'){
//START ADD PHOTO TO ALBUM
	document.getElementById('photoLoader').style.display='';
	document.getElementById('photoErrorIn').innerHTML='';
	document.getElementById('photoModalContent').style.display='none';
	document.getElementById('photoErrorContainer').style.display='none';
	document.getElementById('photoButtons').style.display='none';
	var photosVar = new photosClass;
	photosVar.setHTTPMethod("POST");
	var titleArg = document.addPhotosForm.photoTitle.value;
	var descriptionArg = ColdFusion.getElementValue(document.addPhotosForm.photoDescription.id, 'addPhotosForm');
	var albumIDArg = document.addPhotosForm.albumID.value;
	//Call CFC Function
	var photosReturn = photosVar.preSubmit(titleArg,descriptionArg,albumIDArg);
	if(photosReturn[0] != false){ 
		document.getElementById('photoLoader').style.display='none';
		document.getElementById('photoErrorIn').innerHTML=photosReturn[1];
		document.getElementById('photoModalContent').style.display='';
		document.getElementById('photoErrorContainer').style.display='';
		document.getElementById('photoButtons').style.display='';
	}else{
		displayUploadImage('photo_'+albumIDArg+'_'+titleArg+'_'+descriptionArg,'photos');
		document.getElementById('addPhotoModal').style.display = 'none';
		document.getElementById('photoTitle').value = ''
		document.getElementById('photoDescription').value = ''
	}
//END ADD PHOTO TO ALBUM

}else if(action == 'preSubmitAlbum'){
//START PRESUBMIT ALBUM
	var photosVar = new photosClass;
	photosVar.setHTTPMethod("POST");
	document.getElementById('addPhotoAlbumModal').style.display = '';
//END PRESUBMIT ALBUM

}else if(action == 'addAlbum'){
//START ADD ALBUM
	document.getElementById('photoAlbumLoader').style.display='';
	document.getElementById('photoAlbumErrorIn').innerHTML='';
	document.getElementById('photoAlbumModalContent').style.display='none';
	document.getElementById('photoAlbumErrorContainer').style.display='none';
	document.getElementById('photoAlbumButtons').style.display='none';

	var photosVar = new photosClass;
	photosVar.setHTTPMethod("POST");
	
	var titleArg = document.addPhotoAlbum.title.value;
	var descriptionArg = ColdFusion.getElementValue(document.addPhotoAlbum.description.id, 'addPhotoAlbum');
	var locationArg = document.addPhotoAlbum.location.value;
	var userType = document.addPhotoAlbum.userType.value;
	var communityId = document.addPhotoAlbum.communityId.value;

	//Call CFC Function
	var photosReturn = photosVar.addAlbum(titleArg,descriptionArg,locationArg);
	if(photosReturn[0] != false){
		document.getElementById('photoAlbumLoader').style.display='none';
		document.getElementById('photoAlbumErrorIn').innerHTML=photosReturn[1];
		document.getElementById('photoAlbumModalContent').style.display='';
		document.getElementById('photoAlbumErrorContainer').style.display='';
		document.getElementById('photoAlbumButtons').style.display='';
	}else{
		displayUploadImage('album_'+photosReturn[1]+'_'+photosReturn[2]+'_'+photosReturn[3]+'_','photos');
		//getAlbums();
		
		top.pagination(1,'user','photos','','','0',userType,communityId);
	
		document.addPhotoAlbum.reset();
		//document.addPhotoAlbum.albumID.value = photosReturn[1];
		document.getElementById('photoAlbumLoader').style.display='none';
		document.getElementById('addPhotoAlbumModal').style.display = 'none';
		document.getElementById('photoAlbumErrorIn').innerHTML='';
		document.getElementById('photoAlbumModalContent').style.display='';
		document.getElementById('photoAlbumErrorContainer').style.display='';
		document.getElementById('photoAlbumButtons').style.display='';
	}
//END ADD ALBUM
}}
//END ADD PHOTOS










//START BACK/CLOSE PHOTO MODAL
function clearPhotos(action){

document.getElementById('photoAlbumErrorContainer').style.display='none';

//"BACK" Button functionality for photo album modal
if(action == 'backPhotoAlbum'){
document.getElementById('addPhotoAlbumModal').style.display='none';
document.addPhotoAlbum.reset();

//"BACK" Button functionality for uploading audio to a MUSICIAN'S ACCOUNT
}else if(action == 'backUploadAudioForMusician'){
document.getElementById('uploadAudioModal').style.display='none';
document.getElementById('uploadAudioFrame').contentWindow.document.uploadAudioForm.reset();
document.getElementById('uploadAudioButtonsForMusician').style.display='none';
document.getElementById('uploadAudioButtonsForAlbum').style.display='none';

//"BACK" Button functionality for uploading audio to an ALBUM
}else if(action == 'backUploadAudioForAlbum'){
document.getElementById('uploadAudioModal').style.display='none';
document.getElementById('uploadAudioFrame').contentWindow.document.uploadAudioForm.reset();
document.getElementById('addAlbumModal').style.display='';
document.getElementById('uploadAudioButtonsForMusician').style.display='none';
document.getElementById('uploadAudioButtonsForAlbum').style.display='';

//"BACK" Button functionality for ALBUM
}else if(action == 'backAlbum'){
document.getElementById('addAlbumModal').style.display='none';
document.addAlbum.reset();
document.addAlbum.copyright.style.color='#999999';
document.getElementById('uploadAudioButtonsForMusician').style.display='none';
document.getElementById('uploadAudioButtonsForAlbum').style.display='none';

}else if(action == 'clear'){
jQuery('#addPhotos').slideUp(1000);
document.getElementById('hideAddPhotos').style.display='none';
document.getElementById('showAddPhotos').style.display='';
document.addPhotosForm.reset();
document.addPhotoAlbum.reset();
getAlbums();
document.getElementById('addPhotoAlbumModal').style.display='none';
}else if(action == 'clearPhotos'){
document.addPhotosForm.photoTitle.value = ''
ColdFusion.RichText.setValue(document.addPhotosForm.photoDescription.id, '');
document.getElementById('addPhotoModal').style.display = 'none';

}else if(action == 'clearEditPhotos'){
document.editAllPhotos.reset();
document.getElementById('editPhotoModal').style.display = 'none';

}else if(action == 'clearEditAlbum'){
document.editPhotoAlbum.reset();
document.getElementById('editPhotoAlbumModal').style.display = 'none';
document.getElementById('editphotoAlbumModalContent').style.display = '';
document.getElementById('editphotoAlbumLoader').style.display = 'none';
document.getElementById('editphotoAlbumErrorContainer').style.display = 'none';
}
}
//END BACK/CLOSE PHOTO MODAL
