//------------------------------------------------------------------------------
// Class:  AlbumPhoto
//------------------------------------------------------------------------------
// Author:  CL
// Date:  2008/01/30
// Description:  This class defines the functions used by the Album section.
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
function AlbumPhoto()
{	
	//--------------------------------------------------------------------------
	var previouslySelectedID = "";
	var previouslySelectedIntID = 0;
	var intAlbumID = 0;
	var aImageName = new Array();
	var aImageLabel = new Array();
	var aImageCaption = new Array();
	var aImageDetail = new Array();
	var aImageWidth = new Array();
	var aImageHeight = new Array();
	var currentPhotoID = 0;
	var strWebPathOriginal = "";
	var strWebPathNormal = "";
	var intMaxIndex = 0;
	var strRootName = "";
	var currentPg = 1;
	var intTotalPhotos = 0;
	var previewPhotoSizeType = 0;
	var previewPhotoSizeWidth = 0;
	var previewPhotoID = "";
	var ENABLE_CF_HOTLINK = false; 
	var intViewType = 0;
	var intCommentSetting = 0;
	var intCommentNotification = 0;
	
	// Methods:
	this.preparePhotos = preparePhotos;
	this.showPhoto = showPhoto;
	this.showNext = showNext;
	this.showPrevious = showPrevious;
	this.displayNextArrow = displayNextArrow;
	this.displayPreviousArrow = displayPreviousArrow;
	this.displayDetails = displayDetails;
	this.setPhotoPreviewSize = setPhotoPreviewSize;
	this.getNewAspectRatioWidth = getNewAspectRatioWidth;
	this.getNewAspectRatioHeight = getNewAspectRatioHeight;
	this.showArrowsForPhoto = showArrowsForPhoto;
	this.sortAlbumPhotos = sortAlbumPhotos;
	this.addComment = addComment;
	this.showAddCommentFormBox = showAddCommentFormBox;
	this.regenerateSecurityCode = regenerateSecurityCode;
	this.editComment = editComment;
	this.deleteComment = deleteComment;
	this.displayProfile = displayProfile;
	this.escapeHTML = escapeHTML;
	this.previewComment = previewComment;
	this.showEmailToFriend = showEmailToFriend;
	this.previewEmailToFriend = previewEmailToFriend;
	this.sendEmailToFriend = sendEmailToFriend;
	this.updateDefaultTextRecipientName = updateDefaultTextRecipientName;
	this.updateDefaultTextSenderName = updateDefaultTextSenderName;
	
	//--------------------------------------------------------------------------
	
	function preparePhotos(iAID, prevSelID, iprevSelID, sOriginalPath, sNormalPath, aImgName, aImgLabel, aImgCaption, aImgDetail, aImgWidth, aImgHeight,iMaxIndex,sRootName,pageNum,totalPhotos,photoID, photoWidth, typeID,isEnableHotlink,viewType,iCS,iCN)
	{
		intAlbumID = iAID;
		previouslySelectedID = prevSelID;
		previouslySelectedIntID = iprevSelID;
		strWebPathOriginal = sOriginalPath;
		strWebPathNormal = sNormalPath;
		aImageName = aImgName.slice();
		aImageLabel = aImgLabel.slice();
		aImageCaption = aImgCaption.slice();
		aImageDetail = aImgDetail.slice();
		aImageWidth = aImgWidth.slice();
		aImageHeight = aImgHeight.slice();
		currentPhotoID = aImageDetail[0];
		intMaxIndex = iMaxIndex;
		strRootName = sRootName;
		currentPg = pageNum;
		intTotalPhotos = totalPhotos;
		previewPhotoID = photoID;
		previewPhotoSizeWidth = photoWidth;
		previewPhotoSizeType = typeID;
		ENABLE_CF_HOTLINK = isEnableHotlink;
		intViewType = viewType;
		intCommentSetting = iCS;
		intCommentNotification = iCN;
	}
	
	//--------------------------------------------------------------------------
	
	function showPhoto(strThumbID, intIndex, strFileName)
	{
		if(previouslySelectedID !="")
		{
			document.getElementById(previouslySelectedID).className = "img-box";
		}
		if(ENABLE_CF_HOTLINK)
		{
			var thePath = "_var/displayPhoto.cfm?a=" + intAlbumID + "&photo=" + strFileName + "&type=2";
			var theDownloadPath = "_var/displayPhoto.cfm?a=" + intAlbumID + "&photo=" + strFileName + "&type=3";
		}
		else
		{
			var thePath = strWebPathNormal + strFileName;
			var theDownloadPath = strWebPathOriginal + strFileName;
		}
		var strPhotoCaption = aImageCaption[intIndex-1];
		var strPhotoLabel = aImageLabel[intIndex-1];
		currentPhotoID = aImageDetail[intIndex-1];
		currentWidth = aImageWidth[intIndex-1];
		currentHeight = aImageHeight[intIndex-1];
		document.getElementById(strThumbID).className = "img-box-selected";
		document.getElementById("thePhoto").innerHTML = "<img id='" + previewPhotoID + "' src='" + thePath + "' width='" + this.getNewAspectRatioWidth(currentWidth,currentHeight,previewPhotoSizeWidth)  + "' height='" + this.getNewAspectRatioHeight(currentWidth,currentHeight,previewPhotoSizeWidth)  + "'>";
		//document.getElementById("thePhoto").style.width = this.getNewAspectRatioWidth(currentWidth,currentHeight,previewPhotoSizeWidth) + "px";
		if(document.getElementById("thePhoto").className == "")
		{
			document.getElementById("coverOverlayProtect").style.height = this.getNewAspectRatioHeight(currentWidth,currentHeight,previewPhotoSizeWidth) + "px";
		}
		else
		{
			var sumHeight = parseInt(this.getNewAspectRatioHeight(currentWidth,currentHeight,previewPhotoSizeWidth)) + 20;
			document.getElementById("coverOverlayProtect").style.height = sumHeight + "px";
		}
		document.getElementById("photoCounter").innerHTML = ((currentPg - 1) * intMaxIndex) + intIndex;
		document.getElementById("photoLabel").innerHTML = strPhotoLabel + "<br/>";
		document.getElementById("caption").innerHTML = strPhotoCaption + "<br/>";
		/*
		if(strPhotoCaption.length > 0)
		{
			document.getElementById("captionSection").width = Math.round(this.getNewAspectRatioWidth(currentWidth,currentHeight,previewPhotoSizeWidth) * 0.80);
		}
		else
		{
			document.getElementById("captionSection").width = Math.round(this.getNewAspectRatioWidth(currentWidth,currentHeight,previewPhotoSizeWidth) * 0.50);
		}
		*/
		//document.getElementById("photoViewArea").width = document.getElementById("captionSection").width;
		if(document.getElementById("downloadLink"))
		{
			document.getElementById("downloadLink").href = theDownloadPath;
		}
		this.displayNextArrow(intIndex);
		this.displayPreviousArrow(intIndex);
		previouslySelectedID = strThumbID;
		previouslySelectedIntID = intIndex;
		$.get("/gallery/_var/inc_incrementPhotoCount.cfm?a=" + intAlbumID + "&pID=" + currentPhotoID);
		var newCommentURL = "inc_getAlbumPhotoComment.cfm?a=" + intAlbumID + "&pID=" + currentPhotoID + "&cs=" + intCommentSetting + "&cn=" + intCommentNotification ;
		ColdFusion.navigate(newCommentURL, 'theDiv2');
	}
	
	//--------------------------------------------------------------------------
	
	function showNext()
	{	
		var arrayIndex = previouslySelectedIntID;
		var strNextPhotoImageName = aImageName[arrayIndex];
		var intIndex = previouslySelectedIntID + 1;
		var strThumbID = "thumb_" + intIndex;
		this.showPhoto(strThumbID, intIndex, strNextPhotoImageName, arrayIndex);
	}
	
	//--------------------------------------------------------------------------
	
	function showPrevious()
	{
		var arrayIndex = previouslySelectedIntID - 1;
		var strPreviousPhotoImageName = "";
		if(arrayIndex > 0)
		{
			strPreviousPhotoImageName = aImageName[arrayIndex-1];
		}
		else
		{
			strPreviousPhotoImageName = aImageName[0];
		}
		var intIndex = previouslySelectedIntID - 1;
		var strThumbID = "thumb_" + intIndex;
		arrayIndex = arrayIndex - 1 ;
		this.showPhoto(strThumbID, intIndex, strPreviousPhotoImageName, arrayIndex);
	}
	
	//--------------------------------------------------------------------------
	
	function displayNextArrow(intIndex)
	{
		/*
			show if it is not the last photo
				- last photo means if current index = max index and in last page (current page index * page num = total photos)
		*/
		if(currentPg > 1)
		{
			var currentPagesIndexInTotal = ((currentPg - 1) * intMaxIndex) + aImageName.length;
			
		}
		else
		{
			var currentPagesIndexInTotal = currentPg * aImageName.length;
		}
		// last page
		
		if(currentPagesIndexInTotal >= intTotalPhotos)
		{
			
			if(intIndex < aImageName.length)
			{
				
				var strNextFn = 'onClick = \'oAlbumPhoto.showNext(); return false;\'';
				document.getElementById("next").innerHTML = "<a href='javascript:void(0)'" + strNextFn +"><img src='/" + strRootName + "/img/skin/arrow_next.gif' border='0'></a>";
			}
			else
			{
				document.getElementById("next").innerHTML = "<div style='width:50px;'>&nbsp;</div>";
			}
		}
		// not last page
		else
		{	
			if(intIndex < aImageName.length)
			{	
				var strNextFn = 'onClick = \'oAlbumPhoto.showNext(); return false;\'';
				document.getElementById("next").innerHTML = "<a href='javascript:void(0)'" + strNextFn +"><img src='/" + strRootName + "/img/skin/arrow_next.gif' border='0'></a>";
			}
			else
			{
				var intNextPage = currentPg + 1;
				var strNextURL = "javascript:ColdFusion.navigate('inc_albumPhotos.cfm?a=" + intAlbumID + "&s=" + intViewType + "&p=" + intNextPage + "', 'theDiv');";
				document.getElementById("next").innerHTML = "<a href='javascript:void(0)' onClick=\"" + strNextURL + "\"><img src='/" + strRootName + "/img/skin/arrow_next.gif' border='0'></a>";
			}
		}
	}
	
	//--------------------------------------------------------------------------
	
	function displayPreviousArrow(intIndex)
	{
		/*
			show if it is not the first photo
				- first photo means if first page and index = 1
		*/
		// first page
		if(currentPg == 1)
		{
			if(intIndex > 1)
			{
				var strPreviousFn = 'onClick = \'oAlbumPhoto.showPrevious(); return false;\'';
				document.getElementById("previous").innerHTML = "<a href='javascript:void(0)'" + strPreviousFn +"><img src='/" + strRootName + "/img/skin/arrow_previous.gif' border='0'></a>";
			}
			else
			{
				document.getElementById("previous").innerHTML = "<div style='width:50px;'>&nbsp;</div>";
			}
		}
		// otherpages
		else
		{
			if(intIndex > 1)
			{
				var strPreviousFn = 'onClick = \'oAlbumPhoto.showPrevious(); return false;\'';
				document.getElementById("previous").innerHTML = "<a href='javascript:void(0)'" + strPreviousFn +"><img src='/" + strRootName + "/img/skin/arrow_previous.gif' border='0'></a>";
			}
			else
			{
				var intPreviousPage = currentPg - 1;
				var strNextURL = "javascript:ColdFusion.navigate('inc_albumPhotos.cfm?a=" + intAlbumID + "&s=" + intViewType + "&p=" + intPreviousPage + "&isPrevPage=1" + "', 'theDiv');";
				document.getElementById("previous").innerHTML = "<a href='javascript:void(0)' onClick=\"" + strNextURL + "\"><img src='/" + strRootName + "/img/skin/arrow_previous.gif' border='0'></a>";
			}
			
		}
	}
	
	//--------------------------------------------------------------------------
	
	function displayDetails()
	{
		$.ajax({
				type: "GET",
				url: "_var/inc_photoDetails.cfm?a=" + intAlbumID + "&pID=" + currentPhotoID,
				dataType: "html",
				success: function(data){
					dhtmlwindow.open('photoInfo1', 'div', 'photoInfo', 'Photo Info', 'width=350px,height=250px,center=1,resize=0, scrolling=1');
					document.getElementById('photoInfoDetails').innerHTML = data;
					//document.getElementById('photoInfo').style.display = "block";
					//YAHOO.photoInfo.container.photoInfo.show();
				},
				error: function(){
					dhtmlwindow.open('photoInfo1', 'div', 'photoInfo', 'Photo Info', 'width=350px,height=150px,center=1,resize=0, scrolling=1');
					document.getElementById('photoInfoDetails').innerHTML = "<div class='photoDetailsText'>Unable to get info for this photo.</div>";
					//document.getElementById('photoInfo').style.display = "block";
					//YAHOO.photoInfo.container.photoInfo.show();
				}
			});
	}
	
	//--------------------------------------------------------------------------
	
	function setPhotoPreviewSize(photoID, photoWidth, typeID,setCookie)
	{
		var currentlySelectedIndex = previouslySelectedIntID;
		currentWidth = aImageWidth[currentlySelectedIndex-1];
		currentHeight = aImageHeight[currentlySelectedIndex-1];
		var thePath = document.getElementById(previewPhotoID).src;
		document.getElementById("thePhoto").innerHTML = "<img id='" + previewPhotoID + "' src='" + thePath + "' width='" + this.getNewAspectRatioWidth(currentWidth,currentHeight,photoWidth)  + "' height='" + this.getNewAspectRatioHeight(currentWidth,currentHeight,photoWidth)  + "'>";
		//document.getElementById("thePhoto").style.width = this.getNewAspectRatioWidth(currentWidth,currentHeight,photoWidth) + "px";
		//document.getElementById("captionSection").width = Math.round(this.getNewAspectRatioWidth(currentWidth,currentHeight,photoWidth) * 0.80);
		//document.getElementById("photoViewArea").width = document.getElementById("captionSection").width;
		if(setCookie ==1)
		{
			$.get("/gallery/_var/inc_setPhotoPreviewSize.cfm?s=" + typeID);
			previewPhotoSizeWidth = photoWidth;
			for(var i=1; i < 4; i++)
			{
				sTagID = "previewSize" + i;
				if(i==typeID)
				{
					
					document.getElementById(sTagID).style.fontWeight = "bold";
				}
				else
				{
					document.getElementById(sTagID).style.fontWeight = "";
				}
			}
		}
	}
	
	//--------------------------------------------------------------------------
	
	function getNewAspectRatioWidth(currentWidth,currentHeight,photoWidth)
	{
		if(currentWidth > photoWidth)
		{
			currentWidth = photoWidth;
		}
		return currentWidth;
	}
	
	//--------------------------------------------------------------------------
	
	function getNewAspectRatioHeight(currentWidth,currentHeight,photoWidth)
	{
		if(currentWidth > photoWidth)
		{
			currentHeight = Math.round((photoWidth * currentHeight)/currentWidth);
		}
		return currentHeight;
	}
	
	//--------------------------------------------------------------------------
	
	function showArrowsForPhoto(isDisplay)
	{
		if(isDisplay == 1)
		{
			document.getElementById('previous').style.display = 'block';
			document.getElementById('next').style.display = 'block';
		}
		else
		{
			document.getElementById('previous').style.display = 'none';
			document.getElementById('next').style.display = 'none';
		}
	}
	
	//--------------------------------------------------------------------------
	
	function sortAlbumPhotos(sURL)
	{
		ColdFusion.navigate(sURL, 'theDiv');
	}
	
	//--------------------------------------------------------------------------
	
	function addComment()
	{
		document.frmComment.isAddComment.value = 1;
	}
	
	//--------------------------------------------------------------------------
	
	function showAddCommentFormBox(iType)
	{
		if(iType == 1)
		{
			document.getElementById('addCommentFormShow').style.visibility = "hidden";
			$("#addCommentForm").slideDown("slow");
		}
		else
		{
			window.scrollTo(0,document.documentElement.scrollTop);
			document.getElementById('addCommentFormShow').style.visibility = "visible";
			$("#addCommentForm").slideUp("slow");
		}
	}
	
	//--------------------------------------------------------------------------
	
	function regenerateSecurityCode(sImgFileName,sImgName,sCaptchaID,intF,intW,intH,intT)
	{
		if(document.getElementById('generateCaptchaError'))
		{
			document.getElementById('generateCaptchaError').innerHTML = "&nbsp;";
				
			$.ajax({
				type: "POST",
				url: "/gallery/_var/inc_generateSecurityCode.cfm",
				data: "intF=" + intF + "&intW=" + intW + "&intH=" + intH + "&intType=" + intT,
				dataType: "html",
				success: function(html){
						setTimeout(
							function(){
								document.getElementById(sImgName).src = "/gallery/img/temp/" + sImgFileName + "?" + Math.floor(Math.random()*100000000);
								document.getElementById(sCaptchaID).value = html;
							}, 300
						);
					},
					error: function(){
						setTimeout(
							function(){
								document.getElementById('generateCaptchaError').innerHTML = "* Unable to generate the image. Please try again or refresh this page.";
							}, 300
						);
					}
			});
		}
	}
	
	//--------------------------------------------------------------------------
	
	function editComment(aID,pID,cID,countID)
	{
		var theURL = "/gallery/_var/inc_editComment.cfm?a=" + aID + "&p=" + pID + "&c=" + cID + "&countID=" + countID;
		var divWindowTitle = "Edit Comment #" + countID; 
		var popup = dhtmlwindow.open('photoEditComment', 'iframe', theURL, divWindowTitle, 'width=550px,height=350px,center=1,resize=0, scrolling=1');
		popup.onclose=function(){
			document.getElementById('_iframe-photoEditComment').setAttribute('src', 'about:blank', 0);
			return true;
		}
	}
	
	//--------------------------------------------------------------------------
	
	function deleteComment(aID,pID,cID,countID)
	{
		var theURL = "/gallery/_var/inc_deleteComment.cfm?a=" + aID + "&p=" + pID + "&c=" + cID + "&countID=" + countID;
		var divWindowTitle = "Delete Comment #" + countID; 
		var popup = dhtmlwindow.open('photoDeleteComment', 'iframe', theURL, divWindowTitle, 'width=550px,height=150px,center=1,resize=0, scrolling=1');
		popup.onclose=function(){
			document.getElementById('_iframe-photoDeleteComment').setAttribute('src', 'about:blank', 0);
			return true;
		}
	}
	
	//--------------------------------------------------------------------------
	
	function displayProfile(usrT,usrID)
	{
		$.ajax({
				type: "GET",
				url: "/gallery/_var/inc_getUserProfile.cfm",
				data: "uType=" +  usrT + "&usrID=" + usrID,
				dataType: "html",
				success: function(html){
						document.getElementById('profileInfo').innerHTML = html;
						var popup = dhtmlwindow.open('photoInfo1', 'div', 'profileInfo', 'Profile Info', 'width=550px,height=150px,center=1,resize=0, scrolling=1');
					}
		});
	}
	
	//--------------------------------------------------------------------------
	
	function escapeHTML(str)
	{
		var div = document.createElement('div');
		var text = document.createTextNode(str);
		div.appendChild(text);
		return div.innerHTML;
	}
	
	//--------------------------------------------------------------------------
	
	function previewComment()
	{
		var currDateTimeString = "";
		var d = new Date();
		currDateTimeString = dateFormat(d, "dddd, mmmm d, yyyy @ h:MM:ss TT") + ' PDT';
		
		var strNameSection = "";
		var strURL = document.frmComment.url.value;
		var strURLHTML = " <span title='" + strURL + "' style='cursor:pointer; cursor:hand;'><u>(Home Page)</u></span> "
		if(document.frmComment.intUserType.value == 0)
		{
			//strNameSection = this.escapeHTML(document.frmComment.name.value) + strURLHTML;
			strNameSection = this.escapeHTML(document.frmComment.name.value);
		}
		else
		{
			//strNameSection = this.escapeHTML(document.frmComment.signedInAlias.value) + strURLHTML;
			strNameSection = this.escapeHTML(document.frmComment.signedInAlias.value);
		}
		document.getElementById('previewComment').innerHTML = 
			'<div align="left" style="padding:0px 0px 0px 10px;">'
			+ '<div class="photoInfoDetailsTitle">Preview Comment:</div>'
			+ '<div id="previewCommentDetails">'
			+ '<div id="previewCommentName">' + strNameSection + ' said: </div>'
			+ '<div id="previewCommentContent">' + this.escapeHTML(document.frmComment.commentText.value) + '</div>'
			+ '<div id="previewCommentDate">' + currDateTimeString + '</div>'
			+ '</div>'
		 	+ '</div>'
		var popup = dhtmlwindow.open('photoInfo1', 'div', 'previewComment', 'Preview Comment', 'width=450px,height=250px,center=1,resize=0, scrolling=1');
	}
	
	//--------------------------------------------------------------------------

	function showEmailToFriend(showTypeID,sImgFileName,sImgName,sCaptchaID,intF,intW,intH,intT)
	{
		if(showTypeID == 0)
		{
			document.getElementById('albumEmailToFriend').style.display = "none";			
		}
		else
		{
			this.regenerateSecurityCode(sImgFileName,sImgName,sCaptchaID,intF,intW,intH,intT);
			var popup = dhtmlwindow.open('albumEmailToFriend', 'div', 'emailToFriendDiv', "Share this Album", 'width=550px,height=800px,top=50px,left=300px,center=0,resize=0, scrolling=1');
		}
	}
	
	//--------------------------------------------------------------------------
	
	function previewEmailToFriend(showTypeID)
	{
		if(showTypeID == 0)
		{
			document.getElementById('albumEmailToFriendPreview').style.display = "none";			
		}
		else
		{	
			document.getElementById('previewSenderName1').innerHTML = oCommon.escapeHTML(document.getElementById('emailFriendName').value);
			document.getElementById('previewSenderName2').innerHTML = oCommon.escapeHTML(document.getElementById('emailFriendName').value);
			document.getElementById('previewSenderEmail').innerHTML = oCommon.escapeHTML(document.getElementById('emailFriendEmail').value);
			var sEmailString = oCommon.escapeHTML(document.getElementById('emailFriendRecipientName').value);
			if(document.getElementById('emailFriendRecipientEmail').value.length > 0)
			{
				sEmailString = sEmailString + "  <" + oCommon.escapeHTML(document.getElementById('emailFriendRecipientEmail').value) + ">" ;
			}
			document.getElementById('previewRecipients').innerHTML = oCommon.escapeHTML(sEmailString);
			document.getElementById('previewSubject').innerHTML = oCommon.escapeHTML(document.getElementById('emailFriendSubject').value);
			document.getElementById('previewRecipientNameGreeting').innerHTML = oCommon.escapeHTML(document.getElementById('emailFriendRecipientName').value);
			document.getElementById('previewOptionalMessage').innerHTML = oCommon.escapeHTML(document.getElementById('emailFriendMessage').value);
			var popup = dhtmlwindow.open('albumPermalink1', 'div', 'previewEmailToFriend', "Share this Album - Preview", 'width=550px,height=300px,center=1,resize=0, scrolling=1');
		}
	}
	
	//--------------------------------------------------------------------------
	
	function sendEmailToFriend(iAlbumID)
	{
		document.getElementById('emailToFriendErrorMsg').innerHTML = "";
		var strData = "emailFriendName=" + oCommon.escapeHTML(document.getElementById('emailFriendName').value)
				+ "&emailFriendEmail=" + oCommon.escapeHTML(document.getElementById('emailFriendEmail').value)
				+ "&emailFriendRecipientName=" + oCommon.escapeHTML(document.getElementById('emailFriendRecipientName').value)
				+ "&emailFriendRecipientEmail=" + oCommon.escapeHTML(document.getElementById('emailFriendRecipientEmail').value)
				+ "&emailFriendSubject=" + oCommon.escapeHTML(document.getElementById('emailFriendSubject').value)
				+ "&emailFriendMessage=" + oCommon.escapeHTML(document.getElementById('emailFriendMessage').value)
				+ "&emailToFriendSecurityCode=" + oCommon.escapeHTML(document.getElementById('emailToFriendSecurityCode').value)
				+ "&emailToFriendHashSecurityCode=" + oCommon.escapeHTML(document.getElementById('emailToFriendHashSecurityCode').value)
				+ "&isSendEmailToFriend=1"
				;
		$.ajax({
				type: "POST",
				url: "/gallery/_var/inc_sendEmailToFriend.cfm?a=" + iAlbumID,
				data: strData,
				dataType: "xml",
				success: function(xml){
					var emailSentStatus = jQuery('sentStatus', xml).text();
					var emailSentErrorMsg = jQuery('sentErrorMsg', xml).text();
					if(emailSentStatus == 'false')
					{
						document.getElementById('emailToFriendErrorMsg').innerHTML = emailSentErrorMsg;
						document.getElementById('emailToFriendErrorMsg').className = 'emailToFriendErrMesgBox';
						document.getElementById('emailToFriendSecurityCode').value = "";
					}
					else
					{
						document.getElementById('emailToFriendErrorMsg').innerHTML = emailSentErrorMsg;
						document.getElementById('emailToFriendErrorMsg').className = 'emailToFriendSuccessMesgBox';
						document.getElementById('emailFriendRecipientName').value = "";
						document.getElementById('emailFriendRecipientEmail').value = "";
						document.getElementById('emailFriendSubject').value = "";
						document.getElementById('emailFriendMessage').value = "";
						document.getElementById('emailToFriendSecurityCode').value = "";
						document.getElementById('previewRecipientNameGreetingDefault').innerHTML = "";
					}
				},
				error: function(){
					document.getElementById('emailToFriendErrorMsg').innerHTML = '* Unable to send email message.<br/>';
					document.getElementById('emailToFriendErrorMsg').className = 'emailToFriendErrMesgBox';
					document.getElementById('emailToFriendSecurityCode').value = "";
				}
		});
	}
	
	//--------------------------------------------------------------------------
	
	function updateDefaultTextRecipientName()
	{
		document.getElementById('previewRecipientNameGreetingDefault').innerHTML = oCommon.escapeHTML(document.getElementById('emailFriendRecipientName').value);
	}
	
	//--------------------------------------------------------------------------
	
	function updateDefaultTextSenderName()
	{
		document.getElementById('previewSenderNameDefault').innerHTML = oCommon.escapeHTML(document.getElementById('emailFriendName').value) + " ";
		document.getElementById('previewSenderNameDefault2').innerHTML = oCommon.escapeHTML(document.getElementById('emailFriendName').value) + " ";
	}
}

// Create Object
oAlbumPhoto = new AlbumPhoto();
//--------------------------------------------------------------------------
