﻿	var _divContextMenu;
	var _isScrollIntoView = false;
//	var _messageObj;

	
	function showContextMenu(clickedObj, offsetWidth, offsetHeight)
	{
		if (offsetWidth == null) offsetWidth = 0;
		if (offsetHeight == null) offsetHeight = 0;
		
		if (_divContextMenu == null)
		{
			_divContextMenu = document.createElement("DIV");
			_divContextMenu.style.position = "absolute";
			_divContextMenu.style.zIndex = 1000;
			document.body.appendChild(_divContextMenu);
		}
		
		_divContextMenu.style.top = (getMenuTop(clickedObj) + offsetHeight) +"px";
		_divContextMenu.style.left = (getMenuLeft(clickedObj) + offsetWidth) +"px";
		
		_divContextMenu.innerHTML = "";
		_divContextMenu.style.display = "none";
	}
	
	
	function hideContextMenu()
	{
		if (_divContextMenu != null && _divContextMenu.style.display == "")
		{
			_divContextMenu.style.display = "none";
		}
	}
	
	function getAJAXForm(url, pars, labelMessage, isScrollIntoView)
	{
		_isScrollIntoView = isScrollIntoView;
		
		var newAjax = new Ajax.Request(
			url,
			{
				method: "post",
				parameters: pars,
				onComplete : getAJAXFormFinish
			});
		
		if (labelMessage == null || labelMessage.length < 1)
		{
			startFloatLabel("입력 양식을 불러오고 있습니다.");
		}
		else
		{
			startFloatLabel(labelMessage);
		}
	}
	
	function getAJAXFormFinish(ajaxRequest)
	{
		stopFloatLabel();

		if (ajaxRequest.responseText != null && ajaxRequest.responseText != "")
		{
			_divContextMenu.innerHTML = ajaxRequest.responseText;
			_divContextMenu.style.display = "";
			
			if (_isScrollIntoView)
			{
				_divContextMenu.scrollIntoView();
			}
		}
	}


	function showUserProfile(clickedObj, userID)
	{
		showContextMenu(clickedObj);
		
		var url = "/Common/AJAX/GetUserProfileTable.aspx";
		var pars
			= "userID=" + encodeURIComponent(userID);
			
		getAJAXForm(url, pars, "프로필을 불러오고 있습니다.");
		
		//getUserProfileTable(userID);
	}
	
	function showPhotoDownloadForm(photoID, fileExt, isUser, layerPositionObj)
	{
		if (isUser)
		{
			downloadPhoto(isUser, photoID, fileExt)
		}
		else
		{
			showContextMenu(layerPositionObj);
			
			var url = "/PhotoShare/AJAX/PhotoDownload.aspx";
			var pars
				= "photoID=" + photoID;
				
			getAJAXForm(url, pars, "다운로드 양식을 불러오고 있습니다.", true);
		}
	}





/*
	function getUserProfileTable(userID)
	{
		var url = "/Common/AJAX/GetUserProfileTable.aspx";
		var pars
			= "userID=" + userID;

		var newAjax = new Ajax.Request(
			url,
			{
				method: "post",
				parameters: pars,
				onComplete : getUserProfileTableFinish
			});
			
		startFloatLabel("Loading...");
	}
	
	function getUserProfileTableFinish(ajaxRequest)
	{
		stopFloatLabel();
		
		if (ajaxRequest.responseText != null && ajaxRequest.responseText != "")
		{
			_divContextMenu.innerHTML = ajaxRequest.responseText;
			_divContextMenu.style.display = "";
		}
	}
*/
	
	
	
	
	function showFavoriteUserList(clickedObj, borderColor)
	{
		showContextMenu(clickedObj, 17);

		var url = "/Common/AJAX/GetFavoriteUserListTable.aspx";
		var pars = "";
		if (borderColor != null)
		{
			if (borderColor.substring(0, 1) == "#")
			{
				borderColor = borderColor.substring(1, 7);
			}

			pars = "borderColor=" + borderColor;
		}
		
		getAJAXForm(url, pars, "관심회원 리스트를 가져오고 있습니다.");
		
		//getFavoriteUserListTable();
	}	
/*
	function getFavoriteUserListTable()
	{
		var url = "/Common/AJAX/GetFavoriteUserListTable.aspx";
		var pars = "";

		var newAjax = new Ajax.Request(
			url,
			{
				method: "post",
				parameters: pars,
				onComplete : getFavoriteUserListTableFinish
			});
			
		startFloatLabel("Loading...");
	}
	
	function getFavoriteUserListTableFinish(ajaxRequest)
	{
		stopFloatLabel();
		
		if (ajaxRequest.responseText != null && ajaxRequest.responseText != "")
		{
			_divContextMenu.innerHTML = ajaxRequest.responseText;
			_divContextMenu.style.display = "";
		}
	}
*/

	function menuSubmitLogin()
	{
		if (document.menuLoginForm.userID.value.replace(/ /g, "").length < 1)
		{
			alert("사용자ID를 입력해 주세요.");
			document.menuLoginForm.userID.focus();
		}
		else if (document.menuLoginForm.userPW.value.replace(/ /g, "").length < 1)
		{
			alert("비밀번호를 입력해 주세요.");
			document.menuLoginForm.userPW.focus();
		}
		else
		{
			document.menuLoginForm.loginSuccessURL.value = location.href;
			document.menuLoginForm.action = "https://" + location.hostname + "/Member/LoginPS.aspx";
			document.menuLoginForm.submit();
		}
	}
	
	
	function showHelp(clickedObj, message, width, borderColor, backgroundColor)
	{
		if (width == null) width = "252px";
		if (borderColor == null) borderColor = "#80C041";
		if (backgroundColor == null) backgroundColor = "#E8F5E1";
		
		showContextMenu(clickedObj);
		
		var formHTML
			= "				<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:" + width + "; border: solid 1px " + borderColor + "; background-color:" + backgroundColor + ";\"> "
			+ "					<tr><td colspan=3 align=\"right\" style=\"font-size:8px; color:White;cursor:pointer; background-color:" + borderColor + "\" onclick=\"javascript:hideContextMenu();\">[X]</td></tr> "
			+ "					<tr style=\"height:7px;\"><td colspan=3></td></tr>"
			+"					<tr> "
			+"						<td width=\"10\"></td> "
			+"						<td align=\"left\" >" + message + "</td> "
			+"						<td width=\"10\"></td> "
			+"					</tr> "
			+ "					<tr style=\"height:7px;\"><td colspan=3></td></tr>"			
			+"				</table> ";
			
			_divContextMenu.innerHTML = formHTML;
			_divContextMenu.style.display = "";
	}
	

	function showLoginForm(clickedObj, borderColor, backgroundColor)
	{
		if (borderColor == null) borderColor = "#80C041";
		if (backgroundColor == null) backgroundColor = "#E8F5E1";
		
		showContextMenu(clickedObj);
		
		var formHTML
			= "				<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border: solid 1px " + borderColor + "; background-color:" + backgroundColor + ";\"> "
			+ "					<tr><td colspan=3 align=\"right\" style=\"font-size:8px; color:White;cursor:pointer; background-color:" + borderColor + "\" onclick=\"javascript:hideContextMenu();\">[X]</td></tr> "
			+"					<tr> "
			+"						<td width=\"10\"></td> "
			+"						<td align=\"center\" > "
			+"							<form name=\"menuLoginForm\" method=\"post\" action=\"javascript:menuSubmitLogin();\"> "
			+"							<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> "
			+"								<input type=\"hidden\" name=\"loginSuccessURL\" value=\"" + location.href + "\" /> "
			+"								<tr height=\"5\"><td></td></tr> "
			+"								<tr> "
			+"									<td align=\"center\"> "
			+"										<table border=\"0\" width=\"112\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\"> "
			+"											<tr> "
			+"												<td height=\"17\" align=\"left\" bgcolor=\"#FFFFFF\"> "
			+"													&nbsp;&nbsp;&nbsp;<img src=\"/images/left/l_login_4.gif\" width=\"8\" height=\"5\" align=\"absmiddle\" /> "
			+"													<span class=\"paddin_b5\"> "
			+"														<input class=\"txtbox_04\" style=\"width: 75px; height: 14px\" name=\"userID\" /> "
			+"													</span> "
			+"												</td> "
			+"											</tr> "
			+"										</table> "
			+"									</td> "
			+"								</tr> "
			+"								<tr height=\"1\"><td></td></tr> "
			+"								<tr> "
			+"									<td align=\"center\"> "
			+"										<table border=\"0\" width=\"112\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\"> "
			+"											<tr> "
			+"												<td height=\"17\" align=\"left\" bgcolor=\"#FFFFFF\"> "
			+"													&nbsp;&nbsp;<img src=\"/images/left/l_login_5.gif\" width=\"13\" height=\"5\" align=\"absmiddle\" /> "
			+"													<span class=\"paddin_b5\"> "
			+"														<input name=\"userPW\" type=\"password\" class=\"txtbox_04\" style=\"width: 75px; height: 14px\" /> "
			+"													</span> "
			+"												</td> "
			+"											</tr> "
			+"										</table> "
			+"									</td> "
			+"								</tr> "
			+"								<tr height=\"1\"><td></td></tr> "
			+"								<tr> "
			+"									<td align=\"center\" valign=\"middle\" > "
			+"										<input type=\"image\" src=\"/images/left/l_login_6.gif\" width=\"43\" height=\"17\"  /> "
			+"										<!--&nbsp;<a href=\"#\"><img src=\"/images/left/l_login_7.gif\" width=\"118\" height=\"17\" border=\"0\" /></a> "
			+"										<a href=\"/Member/MemberJoinAgree.aspx\"><img src=\"/images/left/l_login_8.gif\" width=\"62\" height=\"17\" border=\"0\" /></a>--> "
			+"									</td> "
			+"								</tr> "
			+"							</table> "
			+"							</form> "
			+"						</td> "
			+"						<td width=\"10\"></td> "
			+"					</tr> "
			+"				</table> ";
			
			_divContextMenu.innerHTML = formHTML;
			_divContextMenu.style.display = "";
	}
	
	function showCopyURLForm(clickedObj, imgURL, photoID, photoTitle)
	{
		showContextMenu(clickedObj);
		
		var imgLinkURL = "http://www.fotoya.net/Common/PhotoViewR.aspx?photoID=" + photoID;
		
		var formHTML
			= "<table width=\"300\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> "
			+ "	<tr> "
			+ "		<td class=\"paddin_5555\"> "
			+ "			<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"59b340\"> "
			+ "				<tr> "
			+ "					<td bgcolor=\"#FFFFFF\" class=\"paddin_10101010\"> "
			+ "						<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\"> "
			+ "							<tr><td height=\"5\"></td></tr> "
			+ "							<tr> "
			+ "								<td align=\"center\" > "
			+ "									<strong>태그입력이 가능한 게시판용</strong> "
			+ "								</td> "
			+ "							</tr> "
			+ "							<tr> "
			+ "								<td align=\"center\"  align=\"center\"> "
			+ "									<textarea id=\"copyImgTag\" style=\"width: 300px; height: 30px;\" readonly class=\"txtbox_03\"><a href=\"" + imgLinkURL + "\" target=\"_blank\"><img src=\"" + imgURL + "\" border=\"0\"></a></textarea> "
			+ "								</td> "
			+ "							</tr> "
			+ "							<tr><td align=\"center\"><a href=\"javascript:window.clipboardData.setData('Text', document.all.copyImgTag.value);alert('복사되었습니다. 필요한 곳에 [Ctrl+V]로 붙여넣으세요');\">[복사]</a></td></tr> "
			+ "							 "
			+ "							<tr><td height=\"5\"></td></tr> "
			+ "							<tr height=\"1\" bgcolor=\"#59b340\"><td></td></tr> "
			+ "							<tr><td height=\"5\"></td></tr> "
			+ "							 "
			+ "							<tr> "
			+ "								<td align=\"center\" > "
			+ "									<strong>멀티미디어 주소 입력창</strong> "
			+ "								</td> "
			+ "							</tr> "
			+ "							<tr> "
			+ "								<td align=\"center\"  align=\"center\"> "
			+ "									<textarea id=\"copyImgURL\" style=\"width: 300px; height: 30px;\" readonly class=\"txtbox_03\">" + imgURL + "</textarea> "
			+ "								</td> "
			+ "							</tr> "
			+ "							<tr><td align=\"center\"><a href=\"javascript:window.clipboardData.setData('Text', document.all.copyImgURL.value);alert('복사되었습니다. 필요한 곳에 [Ctrl+V]로 붙여넣으세요');\">[복사]</a></td></tr> "
			+ "							 "
			+ "							<tr><td height=\"5\"></td></tr> "
			+ "							<tr height=\"1\" bgcolor=\"#59b340\"><td></td></tr> "
			+ "							<tr><td height=\"5\"></td></tr> "
			+ "							 "
			+ "							<tr> "
			+ "								<td align=\"center\" > "
			+ "									<strong>페이지 링크 태그</strong> "
			+ "								</td> "
			+ "							</tr> "
			+ "							<tr> "
			+ "								<td align=\"center\"  align=\"center\"> "
			+ "									<textarea id=\"copyPageURL\" style=\"width: 300px; height: 30px;\" readonly class=\"txtbox_03\"><a href=\"" + imgLinkURL + "\" target=\"_blank\">" + photoTitle + "</a></textarea> "
			+ "								</td> "
			+ "							</tr> "
			+ "							<tr><td align=\"center\"><a href=\"javascript:window.clipboardData.setData('Text', document.all.copyPageURL.value);alert('복사되었습니다. 필요한 곳에 [Ctrl+V]로 붙여넣으세요');\">[복사]</a></td></tr> "
			+ " "
			+ "							<tr><td height=\"5\"></td></tr> "
			+ "							<tr height=\"1\" bgcolor=\"#59b340\"><td></td></tr> "
			+ "							<tr><td height=\"5\"></td></tr> "
			+ "							 "
			+ "							<tr> "
			+ "								<td align=\"center\"> "
			+ "									<a href=\"javascript:hideContextMenu()\">[닫기]</a> "
			+ "								</td> "
			+ "							</tr> "
			+ "							<tr><td height=\"5\"></td></tr> "
			+ "							 "
			+ "						</table> "
			+ "					</td> "
			+ "				</tr> "
			+ "			</table> "
			+ "		</td> "
			+ "	</tr> "
			+ "</table> ";

		
		_divContextMenu.innerHTML = formHTML;
		_divContextMenu.style.display = "";
	}
	
	
	function showLicenseForm(clickedObj, photoID)
	{
		showContextMenu(clickedObj);
		
		var url = "/PhotoShare/AJAX/GetLicenseForm.aspx";
		var pars 
			= "photoID=" + photoID;
			
		getAJAXForm(url, pars);
		
		//getLicenseForm(photoID);
	}	
/*
	function getLicenseForm(photoID)
	{
		var url = "/PhotoShare/AJAX/GetLicenseForm.aspx";
		var pars 
			= "photoID=" + photoID;

		var newAjax = new Ajax.Request(
			url,
			{
				method: "post",
				parameters: pars,
				onComplete : getLicenseFormFinish
			});
			
		startFloatLabel("Loading...");
	}
	
	function getLicenseFormFinish(ajaxRequest)
	{
		stopFloatLabel();
		
		if (ajaxRequest.responseText != null && ajaxRequest.responseText != "")
		{
			_divContextMenu.innerHTML = ajaxRequest.responseText;
			_divContextMenu.style.display = "";
		}
	}
*/

	function isRecommendedPhoto(photoID)
	{
		var isRecommended = false;
		
		var recommendedPhotoList = getCookie("rpt");

		var rpArray = recommendedPhotoList.split(",");
		
		for (i = 0; i < rpArray.length; i++)
		{
			if (rpArray[i] == photoID)
			{
				isRecommended = true;
				break;
			}
		}
		
		return isRecommended;
	}
	
	function showRecomPhotoForm(clickedObj, photoID)
	{
		if (isRecommendedPhoto(photoID))
		{
			alert("이미 추천한 사진입니다.");
		}
		else
		{
			showContextMenu(clickedObj);
		
			var url = "/PhotoShare/AJAX/GetRecomPhotoForm.aspx";
			var pars 
				= "photoID=" + photoID;
			
			getAJAXForm(url, pars);
		}
	}
	
	
	
	function showIssuePhotoForm(clickedObj, photoID)
	{
		showContextMenu(clickedObj);
		
		var url = "/PhotoShare/AJAX/GetIssuePhotoForm.aspx";
		var pars 
			= "photoID=" + photoID;
		
		getAJAXForm(url, pars);
		
//		getIssuePhotoForm(photoID);
	}	
	
	
	function showScrapPhotoForm(clickedObj, photoID, isUser) // 삭제 예정
	{
		photoID = new String(photoID);
		
		if (photoID.length > 0)
		{
			if (isUser)
			{
				showContextMenu(clickedObj);
				
				var url = "/PhotoShare/AJAX/GetScrapPhotoForm.aspx";
				var pars
					= "photoID=" + photoID;
				
				getAJAXForm(url, pars);
			}
			else
			{
				goLoginPageAfterConfirm("로그인 후 스크랩을 할 수 있습니다.\n로그인 페이지로 이동하시겠습니까?", false);
			}
		}
		else
		{
			alert("스크랩할 사진을 먼저 선택하세요.");
		}
	}
	
/*
	function getIssuePhotoForm(photoID)
	{
		var url = "/PhotoShare/AJAX/GetIssuePhotoForm.aspx";
		var pars 
			= "photoID=" + photoID;

		var newAjax = new Ajax.Request(
			url,
			{
				method: "post",
				parameters: pars,
				onComplete : getIssuePhotoFormFinish
			});
			
		startFloatLabel("Loading...");
	}
	
	function getIssuePhotoFormFinish(ajaxRequest)
	{
		stopFloatLabel();
		
		if (ajaxRequest.responseText != null && ajaxRequest.responseText != "")
		{
			_divContextMenu.innerHTML = ajaxRequest.responseText;
			_divContextMenu.style.display = "";
		}
	}
*/
	
	
	function showDenialForm(clickedObj, photoID)
	{
		showContextMenu(clickedObj);
		
		var url = "/PhotoShare/AJAX/GetDenialForm.aspx";
		var pars 
			= "photoID=" + photoID;
			
		getAJAXForm(url, pars);
		
		//getDenialForm(photoID);
	}	
/*
	function getDenialForm(photoID)
	{
		var url = "/PhotoShare/AJAX/GetDenialForm.aspx";
		var pars 
			= "photoID=" + photoID;

		var newAjax = new Ajax.Request(
			url,
			{
				method: "post",
				parameters: pars,
				onComplete : getDenialFormFinish
			});
			
		startFloatLabel("Loading...");
	}
	
	function getDenialFormFinish(ajaxRequest)
	{
		stopFloatLabel();
		
		if (ajaxRequest.responseText != null && ajaxRequest.responseText != "")
		{
			_divContextMenu.innerHTML = ajaxRequest.responseText;
			_divContextMenu.style.display = "";
		}
	}
*/

	function showSetKeywordForm(clickedObj, action, removeAction)
	{
		if (removeAction == null) removeAction = "";
		
		showContextMenu(clickedObj);
		
		var keywordLabel = "";
		
		var formHTML
			= "<form name=\"setKeywordForm\" method=\"post\" action=\"javascript:submitSetKeyword();\">"
			+ "<table width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
			+ "	<tr>"
			+ "		<td>"
			+ "			<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#59b340\">"
			+ "				<tr>"
			+ "					<td bgcolor=\"#FFFFFF\">"
			+ "						<table width=\"130\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		if (action == "i")
		{
			keywordLabel = "추가할 키워드";
		}
		else if (action == "d")
		{
			keywordLabel = "삭제할 키워드";
		}
		else
		{
			formHTML
			+= "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">이 키워드를</td>"
			+ "							</tr>"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">"
			+ "									<input type=\"text\" name=\"oldKeyword\" class=\"txtbox_03\" style=\"width:110px;\">"
			+ "								</td>"
			+ "							</tr>"
			+ "							<tr height=\"1\" bgcolor=\"#59b340\"><td></td></tr>"
			
			keywordLabel = "다음 키워드로 변경";
		}
			
			formHTML
			+= "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">" + keywordLabel + "</td>"
			+ "							</tr>";
		if (action != "u")
		{
			formHTML 
			+= "							<tr height=\"1\" bgcolor=\"#59b340\"><td></td></tr>";
		}
		
			formHTML 
			+= "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">"
			+ "									<input type=\"text\" name=\"keyword\" class=\"txtbox_03\" style=\"width:110px;\">"
			+ "								</td>"
			+ "							</tr>"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">"
			+ "									<input type=\"hidden\" name=\"setKeywordAction\" value=\"" + action + "\" />"
			+ "									<input type=\"hidden\" name=\"setKeywordRemoveAction\" value=\"" + removeAction + "\" />"
			+ "									<a href=\"javascript:;\" onclick=\"javascript:submitSetKeyword();\">확인</a> | "
			+ "									<a href=\"javascript:;\" onclick=\"javascript:hideContextMenu();\">취소</a>"
			+ "								</td>"
			+ "							</tr>"
			+ "						</table>"
			+ "					</td>"
			+ "				</tr>"
			+ "			</table>"
			+ "		</td>"
			+ "	</tr>"
			+ "</table>"
			+ "	</form>";
		
		_divContextMenu.innerHTML = formHTML;
		_divContextMenu.style.display = "";
		document.setKeywordForm.keyword.focus();
	}
	
	
	function submitSetKeyword()
	{
		var keyword = "";
		var oldKeyword = "";
		
		if (document.setKeywordForm.keyword.value.blank())
		{
			alert("키워드를 입력해 주세요.");
			document.setKeywordForm.keyword.focus();
		}
		else if (document.setKeywordForm.oldKeyword != null && document.setKeywordForm.oldKeyword.value.blank())
		{
			alert("변경될 키워드를 입력해 주세요.");
			document.setKeywordForm.oldKeyword.focus();
		}
		else
		{
			var isRemove = true;
			
			if (document.setKeywordForm.setKeywordRemoveAction.value == "all")
			{
				isRemove = confirm("모든 사진에서 입력한 키워드를 삭제하시겠습니까?");
			}
			
			if (isRemove)
			{
				var action = document.setKeywordForm.setKeywordAction.value;
				var removeAction = document.setKeywordForm.setKeywordRemoveAction.value;
				keyword = document.setKeywordForm.keyword.value;
				if (document.setKeywordForm.oldKeyword != null)
				{
					oldKeyword = document.setKeywordForm.oldKeyword.value;
				}
				
				setKeywords(action, removeAction, keyword, oldKeyword);
				
				hideContextMenu();
			}
		}
	}
	
	function setKeywords(action, removeAction, keyword, oldKeyword)
	{
		var photoIDList = getCheckedValueList(document.all.chkList);
		
		if (removeAction == "all" || photoIDList.length > 0)
		{
			var url = "/PhotoShare/AJAX/SetPhotoKeywords.aspx";
			var pars
//				= "action=" + action
//				+ "&removeAction=" + removeAction
//				+ "&photoID=" + photoIDList
//				+ "&keyword=" + keyword
//				+ "&oldKeyword=" + oldKeyword;
				= Object.toQueryString(
					{
					action: action,
					removeAction: removeAction,
					photoID: photoIDList,
					keyword: keyword,
					oldKeyword: oldKeyword
					} );

			var newAjax = new Ajax.Request(
				url,
				{
					method: "post",
					parameters: pars,
					onComplete : setKeywordsFinish
				});
			
			startFloatLabel("키워드를 변경하고 있습니다.");
		}
		else
		{
			alert("선택된 사진이 없습니다.");
		}
	}
	
	function setKeywordsFinish(ajaxRequest)
	{
		stopFloatLabel();

		if (ajaxRequest.responseText == "true")
		{
			alert("선택한 사진의 키워드가 변경되었습니다.");
			reloadPage();
			//location.reload(true);
		}
		else
		{
			alert("선택한 사진의 키워드 변경 중 오류가 발생되었습니다.");
		}
	}
	
	
	function showPrivateFolderPasswordForm(clickedObj, folderID, userID)
	{
		showContextMenu(clickedObj);
		
		_divContextMenu.innerHTML 
			= "<form name=\"privateFolderPasswordForm\" method=\"post\" action=\"javascript:submitPrivateFolderPassword(" + folderID + ");\">"
			+ "<table width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
			+ "	<tr>"
			+ "		<td>"
			+ "			<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#59b340\">"
			+ "				<tr>"
			+ "					<td bgcolor=\"#FFFFFF\">"
			+ "						<table width=\"130\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">패스워드</td>"
			+ "							</tr>"
			+ "							<tr height=\"1\" bgcolor=\"#59b340\"><td></td></tr>"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">"
			+ "									<input type=\"password\" name=\"folderPassword\" class=\"txtbox_03\" style=\"width:110px;\">"
			+ "								</td>"
			+ "							</tr>"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">"
			+ "									<input type=\"hidden\" name=\"folderID\" value=\"" + folderID + "\" />"
			+ "									<input type=\"hidden\" name=\"userID\" value=\"" + userID + "\" />"
			+ "									<a href=\"javascript:;\" onclick=\"javascript:submitPrivateFolderPassword(" + folderID + ");\">확인</a> | "
			+ "									<a href=\"javascript:;\" onclick=\"javascript:hideContextMenu();\">취소</a>"
			+ "								</td>"
			+ "							</tr>"
			+ "						</table>"
			+ "					</td>"
			+ "				</tr>"
			+ "			</table>"
			+ "		</td>"
			+ "	</tr>"
			+ "</table>"
			+ "</form>";
			
		_divContextMenu.style.display = "";
		document.privateFolderPasswordForm.folderPassword.focus();
	}
	
	
	function submitPrivateFolderPassword(folderID)
	{
		if (document.privateFolderPasswordForm.folderPassword.value.blank())
		{
			alert("비밀번호를 입력해 주세요.");
			document.privateFolderPasswordForm.folderPassword.focus();
		}
		else
		{
			document.privateFolderPasswordForm.action = "/PhotoShare/PrivatePhotoView.aspx";
			document.privateFolderPasswordForm.submit();
		}
	}
	
	function showPhotoPostReplyPasswordForm(clickedObj, replyID)
	{
		showContextMenu(clickedObj);
		
		_divContextMenu.innerHTML 
			= "<form name=\"photoPostReplyPasswordForm\" method=\"post\" action=\"javascript:submitPhotoPostReplyPassword(" + replyID + ");\">"
			+ "<table width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
			+ "	<tr>"
			+ "		<td>"
			+ "			<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#59b340\">"
			+ "				<tr>"
			+ "					<td bgcolor=\"#FFFFFF\">"
			+ "						<table width=\"130\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">패스워드</td>"
			+ "							</tr>"
			+ "							<tr height=\"1\" bgcolor=\"#59b340\"><td></td></tr>"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">"
			+ "									<input type=\"password\" name=\"photoPostReplyPassword\" class=\"txtbox_03\" style=\"width:110px;\">"
			+ "								</td>"
			+ "							</tr>"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">"
			+ "									<a href=\"javascript:;\" onclick=\"javascript:submitPhotoPostReplyPassword(" + replyID + ");\">확인</a> | "
			+ "									<a href=\"javascript:;\" onclick=\"javascript:hideContextMenu();\">취소</a>"
			+ "								</td>"
			+ "							</tr>"
			+ "						</table>"
			+ "					</td>"
			+ "				</tr>"
			+ "			</table>"
			+ "		</td>"
			+ "	</tr>"
			+ "</table>"
			+ "</form>";
			
		_divContextMenu.style.display = "";
		document.photoPostReplyPasswordForm.photoPostReplyPassword.focus();
	}
	
	function submitPhotoPostReplyPassword(replyID)
	{
		if (document.photoPostReplyPasswordForm.photoPostReplyPassword.value.blank())
		{
			alert("비밀번호를 입력해 주세요.");
			document.photoPostReplyPasswordForm.photoPostReplyPassword.focus();
		}
		else
		{
			removePhotoPostReply(replyID, document.photoPostReplyPasswordForm.photoPostReplyPassword.value);
			hideContextMenu();
		}
	}
	
	
	function showReplyPasswordForm(clickedObj, replyID)
	{
		showContextMenu(clickedObj);
		
		_divContextMenu.innerHTML 
			= "<form name=\"replyPasswordForm\" method=\"post\" action=\"javascript:submitReplyPassword(" + replyID + ");\">"
			+ "<table width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
			+ "	<tr>"
			+ "		<td>"
			+ "			<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#59b340\">"
			+ "				<tr>"
			+ "					<td bgcolor=\"#FFFFFF\">"
			+ "						<table width=\"130\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">패스워드</td>"
			+ "							</tr>"
			+ "							<tr height=\"1\" bgcolor=\"#59b340\"><td></td></tr>"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">"
			+ "									<input type=\"password\" name=\"replyPassword\" class=\"txtbox_03\" style=\"width:110px;\">"
			+ "								</td>"
			+ "							</tr>"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">"
			+ "									<a href=\"javascript:;\" onclick=\"javascript:submitReplyPassword(" + replyID + ");\">확인</a> | "
			+ "									<a href=\"javascript:;\" onclick=\"javascript:hideContextMenu();\">취소</a>"
			+ "								</td>"
			+ "							</tr>"
			+ "						</table>"
			+ "					</td>"
			+ "				</tr>"
			+ "			</table>"
			+ "		</td>"
			+ "	</tr>"
			+ "</table>"
			+ "</form>";
			
		_divContextMenu.style.display = "";
		document.replyPasswordForm.replyPassword.focus();
	}
	
	function showPostPasswordForm(clickedObj, target)
	{
		showContextMenu(clickedObj);
		
		_divContextMenu.innerHTML 
			= "<form name=\"postPasswordForm\" method=\"post\" action=\"javascript:submitPostPassword('"+target+"');\">"
			+ "<table width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
			+ "	<tr>"
			+ "		<td>"
			+ "			<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#59b340\">"
			+ "				<tr>"
			+ "					<td bgcolor=\"#FFFFFF\">"
			+ "						<table width=\"130\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">패스워드</td>"
			+ "							</tr>"
			+ "							<tr height=\"1\" bgcolor=\"#59b340\"><td></td></tr>"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">"
			+ "									<input type=\"password\" name=\"postPassword\" class=\"txtbox_03\" style=\"width:110px;\">"
			+ "								</td>"
			+ "							</tr>"
			+ "							<tr>"
			+ "								<td align=\"center\" style=\"padding:3px;\">"
			+ "									<a href=\"javascript:;\" onclick=\"javascript:submitPostPassword('"+target+"');\">확인</a> | "
			+ "									<a href=\"javascript:;\" onclick=\"javascript:hideContextMenu();\">취소</a>"
			+ "								</td>"
			+ "							</tr>"
			+ "						</table>"
			+ "					</td>"
			+ "				</tr>"
			+ "			</table>"
			+ "		</td>"
			+ "	</tr>"
			+ "</table>"
			+ "</form>";
			
		_divContextMenu.style.display = "";
		document.postPasswordForm.postPassword.focus();
	}
	
	function submitReplyPassword(replyID)
	{
		if (document.replyPasswordForm.replyPassword.value.blank())
		{
			alert("비밀번호를 입력해 주세요.");
			document.replyPasswordForm.replyPassword.focus();
		}
		else
		{
			removeReply(replyID, document.replyPasswordForm.replyPassword.value);
			hideContextMenu();
		}
	}
	
	function submitPostPassword(target)
	{
		if (document.postPasswordForm.postPassword.value.blank())
		{
			alert("비밀번호를 입력해 주세요.");
			document.postPasswordForm.postPassword.focus();
		}
		else
		{
		    if (target =="remove") { removePost(document.postPasswordForm.postPassword.value); }
		    else if (target == "modify") { modifyPost(document.postPasswordForm.postPassword.value); }
			hideContextMenu();
		}
	}
	
	
	function showWaitCollection(clickedObj, borderColor, width)
	{
		showMessageBox(clickedObj
			, "콜렉팅보드를 만들고 관심있는 포토를 모을 수 있습니다.<br /> 비슷한 관심을 가진 사람들과 함께 할 수도 있고,내 콜렉팅보드를 뽐낼 수도 있습니다.<br /> 8월 1일 베타오픈, 8월 15일 정식오픈합니다."
			, borderColor
			, width);
	}
	
	function showWaitWikiPhoto(clickedObj, borderColor, width)
	{
		showMessageBox(clickedObj
			, "포토로 만들어가는 지식세상...<br>위키포토가 준비하고 있습니다.<br>위키포토는 사진을 기반으로 한 네티즌 참여 백과사전 및 게시판의 결합형태입니다.<br>위키포토는 회원님들의 참여에 의해 데이터가 준비됩니다.<br>공유포토의 \"상세보기\" 페이지에서 태그를 많이 입력해 주세요. 사진도 많이 등록해 주시고요.<br>그리고 회원게시판의 테마별 자유게시판에도 관련 글을 많이 등록해 주세요.<br>위키포토는 10월 초에 오픈할 수 있도록 준비하겠습니다."
			, borderColor
			, width);
	}
	
	
	function showMessageBox(clickedObj, message, borderColor, width)
	{
		if (borderColor == null || borderColor.length < 1)
		{
			borderColor = "#59b340";
		}
		if (width == null || width < 1)
		{
			width = 200;
		}
		
		showContextMenu(clickedObj);
		
		_divContextMenu.innerHTML 
			= "<table width=\"" + width + "\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
			+ "	<tr>"
			+ "		<td align=\"center\">"
			+ "			<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"" + borderColor + "\">"
			+ "				<tr><td align=\"right\" style=\" font-size:8px; color:White;cursor:pointer;\" onclick=\"javascript:hideContextMenu();\">[X]</td></tr>"
			+ "				<tr>"
			+ "					<td bgcolor=\"#FFFFFF\">"
			+ "						<table width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
			+ "							<tr height=\"5\"><td></td></tr>"
			+ "							<tr>"
			+ "								<td align=\"left\">" + message + "</td>"
			+ "							</tr>"
			+ "							<tr height=\"5\"><td></td></tr>"
			+ "						</table>"
			+ "					</td>"
			+ "				</tr>"
			+ "			</table>"
			+ "		</td>"
			+ "	</tr>"
			+ "</table>";
			
		_divContextMenu.style.display = "";
	}
	
	
	
	function getMenuTop(clickedObj)
	{
		var top = 0;
		
		var tmpObj = clickedObj;
		
		while (tmpObj.tagName != "BODY")
		{
			top += tmpObj.offsetTop;
			tmpObj = tmpObj.offsetParent;
		}
		
		top += clickedObj.offsetHeight;
		
		return top;
	}
	
	function getMenuLeft(clickedObj)
	{
		var left = 0;
		
		var tmpObj = clickedObj;
		
		while (tmpObj.tagName != "BODY")
		{
			left += tmpObj.offsetLeft;
			tmpObj = tmpObj.offsetParent;
		}
		
		return left;
	}
	
	
	function addFavoriteUser(userID)
	{
		var url = "/Common/AJAX/AddFavoriteUser.aspx";
		var pars
			= "userID=" + encodeURIComponent(userID)
		
		var newAjax = new Ajax.Request(
			url,
			{
				method: "post",
				parameters: pars,
				onComplete : addFavoriteUserFinish
			});
			
		startFloatLabel("관심회원으로 등록하고 있습니다.");
	}
	
	function addFavoriteUserFinish(ajaxRequest)
	{
		stopFloatLabel();
		
		if (ajaxRequest.responseText == "true")
		{
			alert("관심회원으로 등록되었습니다.");
		}
		else if (ajaxRequest.responseText == "checklogin")
		{
			goLoginPageAfterConfirm("로그인 후 이용할 수 있는 기능입니다.\n로그인 페이지로 이동하시겠습니까?");
		}
		else
		{
			alert("관심회원으로 등록되지 않았습니다.");
		}
	}
	
	
/*
	function writeMessage(receiverID, messageObj)
	{
		if (messageObj.value.replace(/ /g, "").length < 1)
		{
			alert("쪽지 내용이 입력되지 않았습니다.");
			messageObj.focus();
		}
		else
		{
			_messageObj = messageObj;
			
			var url = "/Common/AJAX/WriteMessageToUser.aspx";
			var pars
				= "receiverID=" + receiverID
				+ "&msgDescription=" + messageObj.value;
			
			var newAjax = new Ajax.Request(
				url,
				{
					method: "post",
					parameters: pars,
					onComplete : writeMessageFinish
				});
				
			startFloatLabel("Sending...");
		}
	}
	
	function writeMessageFinish(ajaxRequest)
	{
		stopFloatLabel();
		
		if (ajaxRequest.responseText == "true")
		{
			_messageObj.value = "";
			alert("쪽지가 발송되었습니다.");
		}
		else if (ajaxRequest.responseText == "checklogin")
		{
			goLoginPageAfterConfirm("로그인 후 이용할 수 있는 기능입니다.\n로그인 페이지로 이동하시겠습니까?");
		}
		else
		{
			alert("쪽지 발송에 실패했습니다..");
		}
	}
*/


    function showCollectingForm(clickedObj, photoID, tabMenuType)
	{
	    showContextMenu(clickedObj);
	    
		var url = "/PhotoCollecting/AJAX/GetCollectingForm.aspx";
		var pars 
			= "photoID=" + photoID
			+ "&tabMenuType=" + tabMenuType;
			
		getAJAXForm(url, pars);
	}
	
	function addCollecting()
	{
		if (document.clForm.cid != null && document.clForm.cid.value < -1)
		{
			alert("콜렉팅할 보드를 선택해 주세요.");
			document.clForm.cid.focus();
		}
		else if (document.clForm.collectingTitle.value.blank())
		{
			alert("콜렉팅 주제를 입력해 주세요.");
			document.clForm.collectingTitle.focus();
		}
		else if (document.clForm.collectingDesc.value.blank())
		{
			alert("콜렉팅 내용을 작성해 주세요.");
			document.clForm.collectingDesc.focus();
		}
		else
		{
			var url = "/PhotoCollecting/AJAX/AddCollectingPS.aspx";
			var pars
				= $("clForm").serialize();

           	var newAjax = new Ajax.Request(
				url,
				{
					method: "post",
					parameters: pars,
					onComplete : addCollectingFinish
				});
			
			startFloatLabel("콜렉팅보드에 포토를 추가하고 있습니다.");
		}
	}
	
	function addCollectingFinish(ajaxRequest)
	{
		stopFloatLabel();
		
		if (ajaxRequest.responseText == "true")
		{
			alert("콜렉팅보드에 포토가 추가되었습니다.");
		}
		else
		{
			alert("콜렉팅보드에 추가중 에러가 발생하였습니다.");
		}
		hideContextMenu();
	}