function confCancel(url)
{
	if(confirm("Discard all unsaved changes? \n"+"Click Ok to discard or Cancel to remain on this page."))
	{
		window.location = url;
	}
	return false;
}

function toggleEntryPhoto(obj)
{
	var arrPhotoNum = obj.id.split(".");
	var photoNum = arrPhotoNum[1];
	var photoStatus = document.getElementById("photo."+photoNum+".selected");

	if(photoStatus.checked)
	{
		document.getElementById("photo."+photoNum).style.borderColor = "#FFFFFF";
		document.getElementById("photo."+photoNum+".selected").checked = false;
	}
	else
	{
		document.getElementById("photo."+photoNum).style.borderColor = "#00CC00";
		document.getElementById("photo."+photoNum+".selected").checked = true;
	}
}

function EditEntryUploadPhotos() {
	var f;
	var confStr = "This entry will be saved as a draft and you will be taken to your photo album. \n";
	confStr+= "Click Ok to continue";
	if(confirm(confStr)) {		
		f = document.getElementById("EntryForm");
		f.STATUS[1].checked = true;
		f.Redirect.value = "MyPhotoAlbum.cfm";
		f.submit();
	}
}

function confirmDeletePhoto(strPhotoId)

{
	var f;
	var strMsg = "Are you sure you want to delete this photo?";
	if(confirm(strMsg))
	{
		f = document.getElementById("Photos");
		f.PhotoID.value = eval(strPhotoId);
		f.submit();
	}
}


function confirmDeleteEntry(strEntryId)
{
	var f;
	var strMsg = "Are you sure you want to delete this entry? \n";
	strMsg+=     "Note that photos associated with this entry will not be deleted.";
	if(confirm(strMsg))
	{
		f = document.getElementById("Entries");
		f.EntryID.value = eval(strEntryId);
		f.submit();
	}
}


function confirmDeleteReview(strReviewId)
{
	var f;
	var strMsg = "Are you sure you want to delete this review?";
	if(confirm(strMsg))
	{
		f = document.getElementById("Reviews");
		f.ReviewID.value = eval(strReviewId);
		f.submit();
	}
}


function showHelp(strHelpAnchor)
{
	openWindow("/help/index.cfm#"+strHelpAnchor,"Help",400,300);
}

function textareaCount(strAreaId, intMaxChars) {
	var numChars = document.getElementById(strAreaId).value.length;
	if(intMaxChars - numChars >= 0) {
		document.getElementById(strAreaId+".charCount").innerHTML = (intMaxChars - numChars) + " characters remaining";
	}
	else {
		document.getElementById(strAreaId+".charCount").innerHTML = "<span style='color:#FF0000;'>Warning: Text is too long. Please limit to a maximum of "+intMaxChars+" characters.</span>";
	}
	
}

function confirmDeleteJourney() {
	if(confirm("Are you sure you want to delete your Journey?"+"\n"+"Continuing will remove your Journey, as well as your reviews, photos and Journey entries."+"\n"+"Click OK to delete your Journey.")) {
		return true;
	}
	else {
		return false;
	}
}

function checkChangePassword() {
	
	if(document.getElementById("Password1").value.length < 6) {
		alert("Your new password is too short."+"\n"+"Please enter a password that is at least 6 characters long.");
		return false;
	}
	
	if(document.getElementById("Password1").value != document.getElementById("Password2").value) {
		alert("Passwords do not match."+"\n"+"Please confirm your new password.");
		return false;
	}
	
}