// ?? ??? ?? ?? ??
var upload_status = 0;
var MAX_LENGTH_MHTITLE = 30;
var MAX_LENGTH_MEMO_CONT = 1000;
var MAX_LENGTH_FRIEND_NOTE = 40;

function openMHPopup(strUrl, WinWidth, WinHeight, mh_id){
	// ?? ?? ???? ?? ??? ??
	var strUrlTmp = strUrl + "?mh_id=" + mh_id;
	var strTargetName = "mhPop";
	var ScrollBar = "no";
	var Resize = "no";
	var WinGubun = "";
	var strProperty = "";
	WinOpen(strUrlTmp,strTargetName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
}
function openMHPopup2(strUrl, WinWidth, WinHeight) {
	var str_domain = document.location.href;		// 2005-05-14 : by KHS
	var arr_domain = str_domain.split("/");			// 2005-05-14 : by KHS
	var strTargetName = "mhUploadImage";
	//var ScrollBar = "yes";
	var ScrollBar = "no";
	var Resize = "no";
	var WinGubun = "";
	var strProperty = "Center";
	strUrl = strUrl+"&base_domain="+arr_domain[2];		// 2005-05-14 : by KHS
	WinOpen(strUrl,strTargetName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
}
function openMHPopup3(strUrl, WinName, WinWidth, WinHeight) {
	// openMHPopup2? ?? ??? ?? popup?? ??? ???? ??? ??? ?? ??? ??
	var ScrollBar = "no";
	var Resize = "no";
	var WinGubun = "";
	var strProperty = "";
	
	WinOpen(strUrl,WinName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
}
function openMHPopup4(fn) {
	var str_domain = document.location.href;		// 2005-05-14 : by KHS
	var arr_domain = str_domain.split("/");			// 2005-05-14 : by KHS
	var strTargetName = "mhUploadImage";
	var ScrollBar = "yes";
	var Resize = "no";
	var WinGubun = "";
	var strProperty = "Center";
	strUrl = fn.strUrl.value+"&base_domain="+arr_domain[2];		// 2005-05-14 : by KHS
	WinWidth = fn.WinWidth.value;
	WinHeight = fn.WinHeight.value;
	WinOpen(strUrl,strTargetName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
}
function openMHPopup5(strUrl, WinWidth, WinHeight, Scrollbar) {
	var str_domain = document.location.href;		// 2005-05-14 : by KHS
	var arr_domain = str_domain.split("/");			// 2005-05-14 : by KHS
	var strTargetName = "mhUploadImage";
	var ScrollBar = Scrollbar;
	var Resize = "no";
	var WinGubun = "";
	var strProperty = "Center";
	strUrl = strUrl+"&base_domain="+arr_domain[2];		// 2005-05-14 : by KHS
	// alert(strUrl);
	// alert(strTargetName);
	WinOpen(strUrl,strTargetName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
}
function closeMHPopup() {
	// ???? cancel ??? ???? ? ?? ?? ???? ?? ??? ??
	opener.location.reload();
	self.close();
}
function checkMHTitle() {
	// 2005-05-03 adou
	if (trim(document.cgifrm.title.value) == "") {
		alert(str_msg_no_mh_title);
		document.cgifrm.title.focus();
		return false;
	}
	//--lcs-2005.08.05----
	if (checkKoreaChar(document.cgifrm.title.value)) 
	{ 
		alert("" + FOUND_DENY_WORDS + "");
		document.cgifrm.title.focus(); 
		return false;
	}
	//--lcs---------------
	if(!checkStringLength(document.cgifrm.title.value, MAX_LENGTH_MHTITLE)) {
		return false;
	}
	
	return true;
}
function SelectColorT(str) {
	// ?? ?? ??? ?? ???
	document.cgifrm.title.style.color=str;
	document.cgifrm.fontcolor.value=str.substring(1,7);
}
function colorpick()    {
	// ?? ??? ???
        window.open('/common/include/editor_colorpick.php?type=0', 'Editcolorpicker', 'width=330,height=270,resizable=no,menubar=no');
}
function submitModifyFolder(mode, cyid, menuid, folderid, cnt) {
	switch(mode) {
		case "del":
			if(cnt <= 1){
				alert(str_msg_at_least_one_folder);
			} else {
				if(confirm(str_msg_delete_folder_confirm))
				{
					go_url('','/ps/ps_tab_setting_board_delete_proc.php?mh_id='+cyid+'&menuid='+menuid+'&folderid='+folderid+'&tabid=3');
				}
			}
			break;
		default:
			// ? ???? ?? ??
			//document.frmList.submit();
			if(checkFolderName()) { document.frmList.submit(); }
			break;
	}
}

function submitModifyFolderN(mode, cyid, menuid, folderid, cnt) {
	switch(mode) {
		case "del":
			if(cnt <= 1){
				alert(str_msg_at_least_one_folder);
			} else {
				if(confirm(str_msg_delete_folder_confirm))
				{
					go_url('','/ps/ps_setting_folder_delete_proc.php?mh_id='+cyid+'&menuid='+menuid+'&folderid='+folderid+'&tabid=3');
				}
			}
			break;
		default:
			// ? ???? ?? ??
			//document.frmList.submit();
			if(checkFolderName()) { document.frmList.submit(); }
			break;
	}
}

function setModifyFolder(mode, cyid, menuid, folderid, cnt) {
	switch(mode) {
		case "del":
			if(cnt <= 1){
				alert(str_msg_at_least_one_folder);
			} else {
				if(confirm(str_msg_delete_folder_confirm))
				{
					go_url('','/ps/ps_bbs_board_setting_delete.php?mh_id='+cyid+'&menuid='+menuid+'&folderid='+folderid);
				}
			}
			break;
		default:
			// ? ???? ?? ??
			if(checkFolderName()) { document.frmList.submit(); }
			break;
	}
}

function setModifyFolderMultiple(mode, cyid, menuid, folderids) {
	var folderid = folderids.split(",");
	var cnt = folderid.length;//str.length;
	switch(mode) {
		case "del":
			if(cnt <= 1){
				alert(str_msg_at_least_one_folder);
			} else {
				if(confirm(str_msg_delete_folder_confirm))
				{
					for(i = 0; i < cnt ; i++){
						//alert(folderid[i]);
						go_url('','/ps/ps_bbs_board_setting_delete.php?mh_id='+cyid+'&menuid='+menuid+'&folderid='+folderid[i]);
					}
				}
			}
			break;
		default:
			// ? ???? ?? ??
			if(checkFolderName()) { document.frmList.submit(); }
			break;
	}
}


function checkTabNameLength(frmName) {
	var str = frmName.value;
	var len = cnLength(str);//str.length;
	if(len > 10) {
		alert(str_msg_limit_tab_name);
		frmName.value = str.substr(0, 10);
	}
	/*
	if(wordFilter(str,'U')){
		return false;
	}
	*/
}
function cnLength(Str) {
	var escStr = escape(Str);
	var numI = 0;
	var escStrlen = escStr.length;
	for (i = 0;  i < escStrlen;  i++) 
	if(escStr.charAt(i) == '%') 
	if(escStr.charAt(++i) == 'u')  numI ++;
	return Str.length+numI;
}
function checkFolderName() {

	var fn = document.frmList;
	var ele_chk=0;
	var arr_elements = new Array();
	var elements_num = fn.elements.length;
	for(i = 0; i < elements_num ; i++){
		if(fn.elements[i].name == "arr_folder_name[]"){
			arr_elements[ele_chk] = fn.elements[i];
			ele_chk++;
		}
	}
	//alert(ele_chk);
	for(i = 0; i < ele_chk; i++) {
		//alert(arr_elements[i].value);
		if (arr_elements[i].value.split(" ").join("")=="") {
			alert(str_msg_no_folder_name);
			return false;
		}
		if(wordFilter(arr_elements[i].value, 'I')){
			arr_elements[i].focus();
			return false;
		}
		if(FilterPattern('HAN',arr_elements[i].value)){
			return false;
		}		
	
		if (filterCharacter(1,arr_elements[i].value) == false ) {
			alert(str_msg_valid_display_name);
			return false;
		}
	}
	
	return true;
}
function submitModifyMenu(mode, cyid, menuid, cnt) {
	switch(mode)
	{
		case "add":
			if(cnt > 7)
			{
				alert(str_msg_limit_creating_tab);
			} else {
				go_url('','/ps/ps_tab_setting_view_added.php?mh_id='+cyid+'&tabid=3');
			}
			break;
		case "del":
			if(cnt <= 1) {
				alert(str_msg_at_least_one_tab);
			} else {
				if(confirm(str_msg_delete_tab_confirm))
				{
					go_url('','/ps/ps_tab_setting_menu_delete_proc.php?mh_id='+cyid+'&menuid='+menuid+'&tabid=3');
				}
			}
			break;
		default:
			// ? ???? ?? ??
			//document.frmList.submit();
			/*
			var eleObj=document.all["arr_display_order[]"];
			
			total=0;
			nlimit=0;
			for(i=1;i <= eleObj.length;i++) {
				total=parseInt(eleObj[i].value) + parseInt(total);
				nlimit=parseInt(nlimit) + parseInt(i+1);
			}
			if ( nlimit != total ) {
				alert('order is not available');
				//break;
			}
			}*/
			if(checkMenuName()) { document.frmList.submit(); }
			break;
	}
}
function submitModifyMenuN(mode, cyid, menuid, cnt) {
	switch(mode)
	{
		case "add":
			if(cnt > 7)
			{
				alert(str_msg_limit_creating_tab);
			} else {
				go_url('','/ps/ps_setting_tab_added.php?mh_id='+cyid+'&tabid=3');
			}
			break;
		case "del":
			if(cnt <= 1) {
				alert(str_msg_at_least_one_tab);
			} else {
				if(confirm(str_msg_delete_tab_confirm))
				{
					go_url('','/ps/ps_setting_tab_delete_proc.php?mh_id='+cyid+'&menuid='+menuid+'&tabid=3');
				}
			}
			break;
		default:
			// ? ???? ?? ??
			//document.frmList.submit();
			/*
			var eleObj=document.all["arr_display_order[]"];
			
			total=0;
			nlimit=0;
			for(i=1;i <= eleObj.length;i++) {
				total=parseInt(eleObj[i].value) + parseInt(total);
				nlimit=parseInt(nlimit) + parseInt(i+1);
			}
			if ( nlimit != total ) {
				alert('order is not available');
				//break;
			}
			}*/
			if(checkMenuName()) { document.frmList.submit(); }
			break;
	}
}
function checkMenuName() {
	// ?? ??? ???? ??? ??
	var fn = document.frmList;
	var ele_chk=0;
	var arr_elements = new Array();
	var elements_num = fn.elements.length;
	for(i = 0; i < elements_num ; i++){
		if(fn.elements[i].name == "arr_menu_name[]"){
			arr_elements[ele_chk] = fn.elements[i];
			ele_chk++;
		}
	}
	//alert(ele_chk);
	for(i = 0; i < ele_chk; i++) {
		//alert(arr_elements[i].value);
		if (arr_elements[i].value.split(" ").join("")=="") {
			alert(str_msg_no_menu_name);
			return false;
		}
		/*
		if(wordFilter(arr_elements[i].value,'U')){
			return false;
		}
		*/
	}
	return true;
}
function DeletePost(fn, mode) {
	if(!ChkSelValues(fn)) { alert(str_msg_no_selected_del_post); }else{
	if(confirm(str_msg_confirm_delete)) {
		switch(mode){
			case "0":				// delete post of diary type
				fn.action = "/ps/ps_diary_delete.php";
				break;
			case "1":				// delete post of alumb type
				fn.action = "/ps/ps_album_delete.php";
				break;
			case "2":				// delete post of board type
				fn.action = "/ps/ps_board_delete.php";
				break;
			case "3":				// delete post of memo type
				fn.action = "/ps/ps_memo_delete.php";
				break;
			case "5":				// delete post of gallery type
				fn.action = "/ps/ps_gallery_delete.php";
				break;
			case "7":
				fn.action = "/ps/ps_video_delete.php";
				break;			
			case "note":			// delete post of Friend Note History
				fn.action = "/ps/ps_profile3_C_delete.php";
				break;
			}
		fn.submit();
		}
	}
}
//20050805 by yt
function TopCoverStory(fn,  pid)
{
	fn.ChkValues.value = pid;
	fn.action = "/ps/ps_profile2_display_proc.php";
	fn.submit();
}
function DeletePostOne(fn, mode, pid, folderid) {
	
	fn.ChkValues.value = pid;
	if(confirm(str_msg_confirm_delete)) {
	
	fn.folderid.value = folderid;
		switch(mode) {
			case "0":
				//fn.action = "/ps/ps_diary_delete.php";
				break;
			case "1":
				fn.action = "/ps/ps_album_delete.php";
				break;
			case "2":
				fn.action = "/ps/ps_board_delete.php";
				break;
			case "3":
				fn.action = "/ps/ps_memo_delete.php";
				break;
			case "5":
				fn.action = "/ps/ps_gallery_delete.php";
				break;
			case "7":
				fn.action = "/ps/ps_video_delete.php";
				break;
			case "cover":
				fn.action = "/ps/ps_profile2_delete.php";
				break;
		}
		fn.submit();
	}
}
function validateMiniroom(fn, mh_id, mode) {
	switch(mode) {
		case "del":
			fn = eval(fn);
			if(confirm(str_msg_confirm_delete)) {
				fn.action = "/ps/ps_miniroom_delete.php?mh_id=" +mh_id;
				if(fn.action) { fn.submit(); }
			}
			break;
	}
}
function validateComment(fn, mode, pid, seq, wid) {

	switch(mode) {
		case "write":
			if ( restrictAccessCheck() == false ) {
				return false;
			}

			if(trim(fn.comment.value) == "") {
				alert(str_msg_no_comment);
				return false;
			}
			if(FilterPattern('HAN',fn.comment.value)){
				return false;
			}
			if(wordFilter(fn.comment.value, 'B')){
				fn.comment.focus();
				return false;
			}			
			return true;
			break;
		case "del":
			if(confirm(str_msg_confirm_delete)) {
				fn.postid.value = pid;
				fn.seq.value = seq;
				fn.writer_cyid.value = wid;
				fn.action = "/ps/ps_bbs_comment_delete_proc.php";
				if(fn.action) { fn.submit(); }
			}
			break;
	}
}
//2005-05-30 adou
function validateSearch(fn) {
	if(trim(fn.search_value.value) == "") {
		alert("" + str_msg_search_input + "");
		fn.search_value.focus();
		return false;
	}
	if(wordFilter(fn.search_value.value,'I')){
		return false;
	}
	return true;
}
//	??? ??? ??(????)


function validateJournal(where)
{
	document.frmWrite.enctype="multipart/form-data" ;
	document.frmWrite.target = "_self";

	if ( navigator.vendor != "Apple Computer, Inc.") {
		// Get the Editor Area DOM (Document object).
		var oEditor = FCKeditorAPI.GetInstance('content') ;
		var oDOM = oEditor.EditorDocument ;
		var iLength ;
	
		if ( document.all )		// If Internet Explorer.
		{
			iLength = oDOM.body.innerText.length ;
		}
		else					// If Gecko.
		{
			var r = oDOM.createRange() ;
			r.selectNodeContents( oDOM.body ) ;
			iLength = r.toString().length ;
		}

		if (edittype=='1')
		{ 
					
				if (iLength == 0)
				{
					alert(''+str_msg_none_concent+'');
					return false;
				}
				if ( document.all )		// If Internet Explorer.
				{
						tmp=oEditor.EditorDocument.body.innerText;
				}
				else					// If Gecko.
				{
					var r = oDOM.createRange() ;
					r.selectNodeContents( oDOM.body ) ;
					tmp = r.toString() ;
				}
				//if(FilterPattern('HAN',tmp)){
				//	return false;
				//}			
				tmp_title=tmp.substr(0,50);
				document.frmWrite.title.value=tmp_title;
		} 
	} else {
		tmp = document.frmWrite.content.value;
		//if(FilterPattern('HAN',tmp)){
		//	return false;
		//}
        tmp_title=tmp.substr(0,50);
        document.frmWrite.title.value=tmp_title;		
	}
	
				
	if (document.frmWrite.emoticonid.value == '')
	{
		alert(str_msg_diary_no_emoticon);
		document.frmWrite.emoticonid.focus();
		return false;
	}

	if (document.frmWrite.weatherid.value == '')
	{
		alert(str_msg_diary_no_weather);
		document.frmWrite.weatherid.focus();
		return false;
	}

	if(wordFilter(document.frmWrite.title.value, 'I')){
		return false;
	}
	
	// 
	if(wordFilter(tmp, 'I')){
		return false;
	}	

	if (where == 'submit')
	{
		return true;
	}

}

function validateJournalSafari(where)
{
	document.frmWrite.enctype="multipart/form-data" ;
	document.frmWrite.target = "_self";
		
	if (document.frmWrite.emoticonid.value == '')
	{
		alert(str_msg_diary_no_emoticon);
		document.frmWrite.emoticonid.focus();
		return false;
	}

	if (document.frmWrite.weatherid.value == '')
	{
		alert(str_msg_diary_no_weather);
		document.frmWrite.weatherid.focus();
		return false;
	}

	//if(wordFilter(oEditor.EditorDocument.body.innerHTML, 'B')){
	//		return false;
	//}		

	if (where == 'submit')
	{

		return true;
	}

}

function validateBookmark(fn, mode) {
	switch(mode) {
		case "write":		//	???? ??? ??(favorite/bookmark)
			if(fn.title.value.split(" ").join("") == "") {
				alert(str_msg_bookmark_no_title);
				return false;
			}
			if(fn.url.value.split(" ").join("") == "") {
				alert(str_msg_no_url);
				return false;
			}
			
			if(fn.url.value.split(" ").join(""). indexOf(".") == -1) {
				alert(str_msg_invalid_url);
				return false;
			}
			if(FilterPattern('HAN',fn.title.value)){
				return false;
			}
			if(FilterPattern('HAN',fn.content.value)){
				return false;
			}
			if(wordFilter(fn.title.value, 'T')){
				fn.title.focus();
				return false;
			}
			if(wordFilter(fn.content.value, 'B')){
				fn.content.focus();
				return false;
			}				
			return true;
			//break;
		case "mod":		//	???? ??? ??(favorite/bookmark)
			var cnt = 0;
			var i;
			var ChkObj = document.all["ChkBox"];
			var ChkBoxCnt = ChkObj.length;
			if(!ChkBoxCnt) {
				if (document.all["ChkBox"].checked == true) { cnt++; } 
				else{ alert(str_msg_select_just_one); break;}
			}else{
				for(var i=0; i < ChkBoxCnt; i++) { if(ChkObj[i].checked == true) { cnt++; } }
			}
			
			if(cnt > 1 || cnt < 1) { alert(str_msg_select_just_one); break; }
			else {
				ChkSelValues(fn);
				fn.action = '/ps/ps_bookmark_Mview.php';
				fn.submit();
			}
			break;
		case "move":		//	???? ??? ??(favorite/bookmark)
			if(!ChkSelValues(fn)) { alert(str_msg_no_selected_move_post); return false; }
			MM_openBrWindow('./popup_post_move_sel_folder.php?login_id='+fn.login_id.value+'&mh_id='+fn.mh_id.value+'&menuid='+fn.menuid.value+'&folderid='+fn.folderid.value+'&postid='+fn.postid.value+'&folder_type='+fn.folder_type.value+'&menu_name='+fn.menu_name.value, 'mh_popup', 'width=400, height=300');
			//fn.action = './favorite_move.php';
			//fn.submit();
			break;
		case "del":		//	???? ??? ??(favorite/bookmark)
			if(!ChkSelValues(fn)) { alert(str_msg_no_selected_del_post); break; }
			if(!confirm(str_msg_confirm_delete)) { break; }
			fn.action = '/ps/ps_bookmark_delete.php';
			fn.submit();
			break;
		case "set":		// ???? ????
			submitModifyFolder();
			return false;
			break;
	}
}
function SetFolder(mh_id, menuid){
	// ?? ?? ??? ?? ?? ?? ??? ?? ?? ?
	// ??? ?? ??? ??
	var strURL;
		
	switch(menuid){
		case "2":				// ???? ?? ??
			strURL = "/ps/ps_bookmark_set.php?mh_id="+mh_id+"&menuid="+menuid;
			break;
		case "3":				// miniroom
			strURL = "/ps/ps_miniroom_set.php?mh_id="+mh_id+"&menuid="+menuid;
			break;
		case "13":				// guestbook
			strURL = "/ps/ps_memo_set.php?mh_id="+mh_id+"&menuid="+menuid;
			break;
		default:
			strURL = "/ps/ps_tab_setting_board_normal.php?mh_id="+mh_id+"&menuid="+menuid+"&tabid=3";
			break;
	}
	
	
	go_url('', strURL);
}

	var ImgChk = false;
	function ImgChkBoxAll() {
		ImgChk = !ImgChk;
		var ChkObj = document.frmList.ChkBox;
		var ChkBoxCnt = ChkObj.length;
		if(!ChkBoxCnt) { if(ImgChk == true) { ChkObj.checked = true; } else { ChkObj.checked = false; } }
		else { for(var i=0; i < ChkBoxCnt; i++) { if(ImgChk == true) { ChkObj[i].checked = true; } else { ChkObj[i].checked = false; } } }
	}


	// minivault write
	function validateBoard(where) {
		document.frmWrite.target = "_self"; 	
		
		var att_fileinfo = document.getElementById("attach_fileinfo[]");
		var att_filename = document.getElementById("attach_filesize[]");
		var att_filetype = document.getElementById("attach_filetype[]");
		if(att_filename.length > 0 && att_filetype.length > 0) {
			for(i=0; i<att_fileinfo.length; i++) {
				att_fileinfo.options[i].selected = true;
				att_filename.options[i].selected = true;
				att_filetype.options[i].selected = true;
			}
		}
		if (document.frmWrite.title.value == '') {
			alert(str_msg_insert_title);
			cleanBox();
			document.frmWrite.title.focus();
			return false;
		}
		if(wordFilter(document.frmWrite.title.value, 'T')){
			return;
		}		
		if(FilterPattern('HAN',document.frmWrite.title.value)){
			return false;
		}
		if (navigator.vendor != "Apple Computer, Inc.") {        
			var oEditor = FCKeditorAPI.GetInstance('content');
			var oDOM = oEditor.EditorDocument;
			var iLength;
			
			if (document.all) {
				iLength = oDOM.body.innerText.length;
			} else {
				var r = oDOM.createRange() ;
				r.selectNodeContents(oDOM.body) ;
				iLength = r.toString().length ;
			}
			if (edittype=='1') { 
				if (iLength == 0) {
					alert(''+str_msg_none_concent+'');
					return false;
				}
				if (document.all) {
					tmp=oEditor.EditorDocument.body.innerHTML;
				} else {
					var r = oDOM.createRange() ;
					r.selectNodeContents( oDOM.body ) ;
					tmp = r.toString() ;
				}
			} 
			
		} else {
			tmp = document.frmWrite.content.value;
		}

		if(wordFilter(tmp, 'B')){
			return false;
		}
		if(FilterPattern('HAN',tmp)){
			return false;
		}
		if (!chkObj(document.frmWrite.folderid, chkNull(document.frmWrite.folderid), 'Please select the folder.')) return false;
		
		if(wordFilter(document.frmWrite.title.value, 'T')){
			document.frmWrite.title.focus();
			return false;
		}
		return true;
	}	

//	??? ??? ??(????? ???)
function validateDiary(fn, mode, cyid, userName, menuid, folderid, folder_type) {
	switch(mode) {
		case "write":		//	????? ??? ??
		
		fn.content.value = GetSource();
			if(fn.title.value == "") {
				alert(str_msg_diary_no_title);
				return false;
			}
			if(fn.emoticonid.value == "") {
				alert(str_msg_diary_no_emoticon);
				return false;
			}
			if(fn.weatherid.value == "") {
				alert(str_msg_diary_no_weather);
				return false;
			}
			if(trim(fn.content.value) == "") {
				alert(str_msg_no_content);
				return false;
			}

			return true;
			//break;
		case "mod":		//	????? ??? ??
			var cnt = 0;
			var i, index;
			var ChkObj = document.all["ChkBox"];
			var ChkBoxCnt = ChkObj.length;
			if(!ChkBoxCnt) {
				if (document.all["ChkBox"].checked == true) { cnt++; index = i; } 
				else{ cnt=0; }
			}else{
				for(var i=0; i < ChkBoxCnt; i++) { if(ChkObj[i].checked == true) { cnt++; } }
			}
		
			if(cnt > 1 || cnt < 1) {
				alert(str_msg_select_just_one);
				break;
			}
			ChkSelValues(fn);
			fn.action = "/ps/ps_diary_Mview.php";
			fn.submit();
			break;			
		case "tellme":
			var cnt = 0;
			var i;
			var ChkObj = document.getElementById("ChkBox");
			var ChkBoxCnt = ChkObj.length;
			var ChkValue;
			if(!ChkBoxCnt) {alert('zz');
				if(ChkObj.checked == true) { cnt++; ChkValue = ChkObj.value; }
			} else {alert('zzz');
				for(var i = 0; i < ChkBoxCnt; i++) {
					if(ChkObj[i].checked == true) { cnt++; ChkValue = ChkObj[i].value; }
				}
			}
			if(cnt > 1 || cnt < 1) {
				alert(str_msg_select_just_one);
				break;
			}
			hidUrl = "/ps/ps_bbs_divide_proc.php?mh_id=" + cyid + "&menuid=" + menuid + "&folderid=" + folderid + "&folder_type=" + folder_type + "&postid=" + ChkValue;
			//alert(hidUrl.search);
			//window.open('/main/memo_writeC_Wview.php?send_cyid='+cyid+'&hidSendName='+userName+'&hidMode=Post&hidUrl='+hidUrl);
			//strUrl = '/main/memo_writeC_Wview.php?send_cyid='+cyid+'&hidSendName='+userName+'&hidMode=Post&hidUrl='+hidUrl;
			//alert(strUrl+'\n'+strUrl.search);
			openMHPopup2('/main/memo_writeC_Wview.php?send_cyid='+cyid+'&hidSendName='+userName+'&hidMode=Post&hidUrl='+hidUrl,'','');
			break;
	}
}

// set var to insure form only submitted once
var memo_form_submitted = false;

function validateMemo(fn, mode) {
	switch(mode) {
		case "write":		//	????? ??? ??
			if (memo_form_submitted == true || restrictAccessCheck() == false) {
				return false;
			}
		
			if(fn.content.value.split(" ").join("") == "") {
				alert(str_msg_no_content);
				return false;
			}
			if(!checkStringLength(fn.content.value, MAX_LENGTH_MEMO_CONT)) {
				return false;
			}
			if(FilterPattern('HAN',fn.content.value)){
				return false;
			}
			if(wordFilter(fn.title.value, 'T')){
				fn.title.focus();
				return false;
			}
			if(wordFilter(fn.content.value, 'B')){
				fn.content.focus();
				return false;
			}			
			memo_form_submitted = true;
			return true;
	}
	return false;
}

// validation for photo upload (minihome)
function validateAlbum(where) {

	fn = document.frmWrite;

	if (navigator.vendor != "Apple Computer, Inc.") {  
		var multi_upload = fn.upload_method.value;
		var oEditor = FCKeditorAPI.GetInstance('content') ;
		var oDOM = oEditor.EditorDocument ;
		var iLength ;


		if ( document.all ) {
			iLength = oDOM.body.innerText.length ;
		} else {
			var r = oDOM.createRange() ;
			r.selectNodeContents( oDOM.body ) ;
			iLength = r.toString().length ;
		}

		if(multi_upload == '0'){
			if ((fn.title.value == 'title') || (trim(fn.title.value) == "")) {
				alert("Enter the title");
				cleanBox();
				fn.title.focus();
				return false;
			}
			if(!fn.img_name.value){
				alert(str_msg_submit_with_file);
				return false;
			}
			if (!chkObj(fn.folderid, chkNull(fn.folderid), 'Please select the folder.') ) return false;
	
			if (edittype=='1') {
				if (iLength == 0 ) {
					alert(''+str_msg_none_concent+'');
					return false;
				}
			} else {
				if(multi_upload == '0'){
					if (!chkObj(fn.content, chkNull(fn.content), ''+str_msg_none_concent+'')) return false;
				}
			}
			if(wordFilter(fn.title.value, 'T')){
				fn.title.focus();
				return false;
			}
			if(FilterPattern('HAN',fn.title.value)){
				return false;
			}
			
			if(wordFilter(oEditor.EditorDocument.body.innerHTML, 'B')){
				return false;
			}
			if(FilterPattern('HAN',oEditor.EditorDocument.body.innerHTML)){
				return false;
			}			
		
		} else {

			var imgcount = fn.img_count.value;

			if (!chkObj(fn.folderid_multi, chkNull(fn.folderid_multi), 'Please select the folder.') ) return false;

			for( var i=0;i < imgcount; i++){
				if (eval('fn.title'+i+'.value') == 'title' || eval('fn.title'+i+'.value') == '') {
					alert("Enter the title");
					cleanBox();
					eval('fn.title'+i).focus();
					return false;
				}
				if(wordFilter(eval('fn.title'+i+'.value'), 'T')){
					return false;
				}
				if (FilterPattern('HAN',eval('fn.title'+i+'.value'))){
					return false;
				}
				if (eval('fn.content'+i+'.value') == 'description' || eval('fn.content'+i+'.value') == '') {
					alert(str_msg_none_concent);
					eval('fn.content'+i).focus();
					return false;
				}
				if(wordFilter(eval('fn.content'+i+'.value'), 'B')){
					return false;
				}
				if (FilterPattern('HAN',eval('fn.content'+i+'.value'))){
					return false;
				}
			}
		}
	} 
	
	// if safari
	else {
	
		if ((fn.title.value == 'title') || (trim(fn.title.value) == "")) {
			alert("Enter the title");
			cleanBox();
			fn.title.focus();
			return false;
		}
		if(!fn.img_name.value){
			alert(str_msg_submit_with_file);
			return false;
		}
		if (!chkObj(fn.folderid, chkNull(fn.folderid), 'Please select the folder.') ) return false;
	
		if (edittype=='1') {
			if (iLength == 0 ) {
				alert(''+str_msg_none_concent+'');
				return false;
			}
		} else {
			if(multi_upload == '0'){
				if (!chkObj(fn.content, chkNull(fn.content), ''+str_msg_none_concent+'')) return false;
			}
		}
		if(wordFilter(fn.title.value, 'T')){
			fn.title.focus();
			return false;
		}
		if(wordFilter(fn.content.value, 'B')){
			return false;
		}		
	}


	return true;

	/*
	if (where == 'submit') {
		fn.target = "_self";
		return true;
	} else if(where == 'preview') {
			
		publish_preview();
		return false;
	}
	*/
}

function publish_preview(url)  {
	fn = document.frmWrite;	

	fn.action= url;
	strUrl = "about:blank";
	strName = "winBbsPreview";
	WinWidth = 442;
	WinHeight = 420;
	ScrollBar = "no";
	Resize = "no";
	WinGubun = "Center";
	strProperty = "";
	item_win = WinOpen(strUrl,strName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
	fn.target=strName;
	fn.submit();
}

function validateFriendNote(fn, mode) {
	// 1?? ?? ??? ??
	switch(mode) {
		case "write":		//	1?? ??
			if(trim(fn.comment.value) == "") {
				alert(str_msg_no_friends_note);
				return false;
			}
			if(!checkStringLength(fn.comment.value, MAX_LENGTH_FRIEND_NOTE)) {
				return false;
			}
			if(wordFilter(fn.comment.value,'I')){
				return false;
			}
			if(FilterPattern('HAN',fn.comment.value)){
				return false;
			}
			return true;
	}
	return false;
}
function validateScrap(fn, mode) {
	// ??? ??? ?? ?? ??
	switch(mode) {
		case "scrap":
			var strData = "";
			strData = fn.AddUrl.options[fn.AddUrl.selectedIndex].value;
			
			if (strData.length > 0)
			{
				fn.action = fn.action + "?" + strData;
				return true;
			}
			alert(str_msg_no_select_folder);
			return false;
		case "newfolder":
			if(fn.folder_name.value == "Enter new folder name" || fn.folder_name.value.split(" ").join("") == "") {
				alert(str_msg_no_folder_name);
				return false;
			} else {
				return true;
			}
			return true;
	}
}



function validateMovePost(fn, mode) {
	// ??? ??? ?? ?? ??
	switch(mode) {
		case "move":
			var strData = "";
			if (fn.AddUrl.options.length)
				strData = fn.AddUrl.options[fn.AddUrl.selectedIndex].value;

			if (strData.length > 0) {
				fn.action = fn.action + "?" + strData;
				return true;
			}
			else {
				alert(str_msg_no_select_folder);
				return false;
			}
		case "newfolder":
			if(fn.folder_name.value == "Enter new folder name" || fn.folder_name.value.split(" ").join("") == "") {
				alert(str_msg_no_folder_name);
				return false;
			} else {
				if(FilterPattern('HAN',fn.folder_name.value)){
					return false;
				}
				if(wordFilter(fn.folder_name.value, 'I')){
					return false;
				}				
				if (filterCharacter(1,fn.folder_name.value) == false ) {
					alert(str_msg_valid_display_name);
					return false;
				}
				return true;											
			}
	
			return true;
	}
}
function MovePost(fn, cyid, fid, ftype) {
	if(!ChkSelValues(fn)) { alert(str_msg_no_selected_move_post); }
	else {
		var strUrl = "/ps/ps_movepost_C_view.php?mh_id=" + cyid + "&folderid=" + fid + "&folder_type=" + ftype + "&ChkValues=" + fn.ChkValues.value;
		openMHPopup2(strUrl, '398', '260');
	}
}

function MovePost1_5(fn, cyid, fid, ftype, mh_name) {
	if(!ChkSelValues(fn)) { alert(str_msg_no_selected_move_post); }
	else {
		var strUrl = "/ps/ps_movepost_C_view.php?mh_id=" + cyid + "&folderid=" + fid + "&folder_type=" + ftype + "&ChkValues=" + fn.ChkValues.value + "&mh_name=" + mh_name;
		openMHPopup2(strUrl, '398', '260');
	}
}

function MovePhoto(fn) {
	var selectValue = document.getElementById('selfrmMove').value;
	var selectValue_arr = selectValue.split("|");
	var targetFolderid = selectValue_arr[0];
	//var target_folderid = selectValue.options[selectValue.selectedIndex].value;
	var targetFolderName = selectValue_arr[1];
	//var target_foldername = selectValue.options[selectValue.selectedIndex].text;

	if(!ChkSelValues(fn))  
		alert(str_msg_no_selected_move_post);
	else if(!targetFolderid || targetFolderid < 1)  
		alert(str_msg_no_album_selected);
	else {
		//confirm box here
		$jq.dialog.show('<span class="text">Selected photos will be moved to<br><b>&quot;'+targetFolderName+'&quot;</b> album</span><div class="buttons"><button type="button" id="btn-ok">OK</button><button type="button" id="btn-cancel">Cancel</button></div>');
		$jq('#dialog-content #btn-ok').click(function() {
			fn.targetFolderid.value = targetFolderid;
			fn.targetFolderName.value = targetFolderName;
			fn.postid.value = fn.ChkValues.value;
			fn.currentUrl.value = location.href;
			fn.submit();
			$jq.dialog.hide();
		});
		$jq('#dialog-content #btn-cancel').click(function() {
			$jq.dialog.hide();
		});		
	}
}


function MovePostOne(fn, cyid, pid, fid, ftype) {
	var strUrl = "/ps/ps_movepost_C_view.php?mh_id=" + cyid + "&folderid=" + fid + "&folder_type=" + ftype + "&ChkValues=" + pid;
	openMHPopup2(strUrl, '398', '260');
}

function ReportSpam(cyid, pid, mid, fid, ftype) {
		
	var strUrl = "/profile/abuse_report.php?mh_id=" + cyid + "&menuid=" + mid + "&folderid=" + fid + "&postid=" + pid + "&folder_type=" + ftype;

	go_url('xxx',strUrl);
}

function ReportTalkSpam(cyid, reporter,postid,commentid) {
		
	var strUrl = "/profile/abuse_report.php?mh_id=" + cyid +"&reporterid=" + reporter + "&postid=" + postid + "&commentid=" + commentid+"&type=TALK";
	alert(strUrl);
	go_url('xxx',strUrl);
}

function ScrapPost(cyid, pid, mid, fid, ftype, mname, fname, user_name) {
	var strUrl = "/ps/ps_scrap_C_view.php?mh_id=" + cyid + "&menuid=" + mid + "&folderid=" + fid + "&postid=" + pid + "&menu_name=" + mname + "&folder_name=" + fname + "&folder_type=" + ftype + "&post_writer_name=" + user_name;
	openMHPopup2(strUrl,'398','290');
}
function ScrapPostOne(fn, cyid, mid, fid, ftype, mname, fname) {
	var cnt = 0;
	var i, index;
	var ChkObj = document.all["ChkBox"];
	var ChkBoxCnt = ChkObj.length;
	var ChkValues;
	if(!ChkBoxCnt) {
		if (ChkObj.checked == true) { cnt++; index = 0; ChkValues = ChkObj.value; } 
		else{ cnt=0; }
	} else {
		for(var i=0; i < ChkBoxCnt; i++) { if(ChkObj[i].checked == true) { cnt++; ChkValues = ChkObj[i].value; } }
	}
	if(cnt > 1 || cnt < 1) {
		alert(str_msg_select_just_one);
	} else {
		var strUrl = "/ps/ps_scrap_C_view.php?mh_id=" + cyid + "&menuid=" + mid + "&folderid=" + fid + "&postid=" + ChkValues + "&menu_name=" + mname + "&folder_name=" + fname + "&folder_type=" + ftype;
		openMHPopup2(strUrl,'398','260');
	}
}

function onCancelBack(url) {
	document.location.replace(url);
}

function goWrite(fn, strURL) {
	// back_url ?? ?? ??
	//var theform = eval('document.'+fn);

	fn.action = strURL;
	fn.submit();
}

function goWrite3(fn, strURL) {
	// back_url ?? ?? ??
	var theform = eval('document.'+fn);

	theform.action = strURL;
	theform.submit();
}


function goWrite2(fn, strURL_IE, strURL_NET) {
	if(navigator.appName == "Netscape") {
		fn.action = strURL_NET;
	} else {
		fn.action = strURL_IE;
	}
	fn.submit();
}
// ???? ? ? ?? ??? ??? ??? ???.....
function open_minihompy2(mh_id, login_id, postUrl){
	var strUrl = "/ps/ps_gate.php?mh_id=" + mh_id + "&redirect_url=" + postUrl;
	var strUrlTmp = "about:blank";
	var WinWidth = "932";
	var WinHeight = "572";
	var ScrollBar = "no";
	var Resize = "no";
	var WinGubun = "Center";
	var strProperty = "";
	if(mh_id == login_id){
		var strName = "MyHompy_GSP";
		MyHompy_GSP = WinOpen(strUrlTmp,strName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
		MyHompy_GSP.location.replace(strUrl);
	}
	else{
		var strName = "YourHompy_GSP";
		YourHompy_GSP = WinOpen(strUrlTmp,strName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
		YourHompy_GSP.location.replace(strUrl);	
	}
	self.close();
}
function showImage() {
	if(document.all.imgFile.value) {
		document.all.imgsrc.src = document.all.imgFile.value;
		document.all.imgview.style.display = '';
	}
	if(document.all.img_name.value) {
		opener.document.all.imgsrc.src = document.imgForm.value;
		opener.document.all.imgview.style.display = '';
	}
}
function selEmoticon(imgName){
	// ???? ??? ?? ?
	// main_only.js? imgSelect(imgName) ??
	var fn = document.frmWrite;
	objTextArea = fn.content;
	if (objTextArea.currentPos != null){ objTextArea.currentPos.text += imgName; }
	else{ objTextArea.value += imgName; }
	objTextArea.focus();
}
function validateGallery(fn, mode) {
	switch(mode) {
		case "write":
			if(fn.title.value.split(" ").join("") == "") { alert(str_msg_no_title); return false }
			if(fn.content.value.split(" ").join("") == "") { alert(str_msg_no_content); return false }

			return true;
	}
}
function preview_onclick() {
	// ??? ???? ????
	imgForm.CyGlobal.preview();
}
function upload_onclick() {
	// imagetool upload
/*
	if (chkThumbnail.checked)
		imgForm.CyGlobal.Thumbnail = "use=true;width=113;height=84;bgcolor=7f7f7f;";   
	else
		imgForm.CyGlobal.Thumbnail = "use=false;"; 
*/
	if(upload_status == 0){
//		if(imgForm.CyGlobal.Thumbnail == ""){
//			imgForm.CyGlobal.Thumbnail = "use=true;width=113;height=84;bgcolor=7f7f7f;"; 
//		}
		if (imgForm.CyGlobal.upload(imgForm) == true){ upload_status = 1}
		//upload.disabled = true;
		//else
		//upload.disabled = false;
	}
}
function upload_onclick2() {
	// direct upload
	if (imgForm2.CyGlobal.addImage(openFileForm.openFile.value) == false)
	{
		alert(str_msg_cant_upload);
		return;
	}
/*
	if (chkThumbnail.checked)
		imgForm.CyGlobal.Thumbnail = "use=true;width=113;height=84;bgcolor=7f7f7f;";   
	else
		imgForm.CyGlobal.Thumbnail = "use=false;"; 
*/
	if(upload_status == 0){
		imgForm2.CyGlobal.Thumbnail = "use=true;width=113;height=84;bgcolor=7f7f7f;";
		
		if (imgForm2.CyGlobal.upload(imgForm2) == true){ upload_status = 1}
		//upload.disabled = true;
		//else
		//upload.disabled = false;
	}
}
function uplaodImage() {
		if(document.all.imgFile.value) {
			document.all.img_name.value = document.all.imgFile.value;
			document.all.file_size.value = document.all.imgFile.size;
			document.all.file_cnt.value = eval(document.all.file_cnt.value) + 1;
			document.all.imgview.style.display = '';
			document.all.fileview.style.display = '';
		}
}
function uploadFile() {
	if(document.all.attachFile.value){
		document.all.attach_name.value = document.all.attachFile.value;
		document.all.attach_size.value = document.all.attachFile.size;
		document.all.file_cnt.value = eval(document.all.file_cnt.value) + 1;
		document.all.attview.style.display = '';
		document.all.fileview.style.display = '';
	}
}
function ChkFileSize() {
	if(document.all.file_size.value){
		if(document.all.total_size.value > 2000) {
			document.all.dstfile.value = '';
			document.all.img_name.value = '';
			document.all.file_size.value = '0';
			document.all.file_cnt.value = eval(document.all.file_cnt.value) - 1;
			alert(str_msg_over_file_size);
			document.all.imgview.style.display = 'none';
			if(document.all.attview.style.display == 'none') {
				document.all.fileview.style.display = 'none';
			}
		}
	}
	if(document.all.attach_size.value) {
		if(document.all.total_size.value > 2000) {
			document.all.attfile.value = '';
			document.all.attach_name.value = '';
			document.all.attach_size.value = 0;
			document.all.file_cnt.value = eval(document.all.file_cnt.value) - 1;
			alert(str_msg_over_file_size);
			document.all.attview.style.display = 'none';
			if(document.all.imgview.style.display == 'none') {
				document.all.fileview.style.display = 'none';
			}
		}
	}
}
function chkTotalSize() {
	if(document.all.file_size.value)
	{
		//alert('change file_size');
	}
	if(document.all.attach_size.value)
	{
		//alert('change attach_size');
	}
}
function delAttachFile() {
	if(document.all.delimg.checked == true) {
		document.all.dstfile.value = '';
		document.all.img_name.value = '';
		document.all.total_size.value = eval(document.all.total_size.value) - eval(document.all.file_size.value);
		document.all.file_cnt.value = eval(document.all.file_cnt.value) - 1;
		document.all.file_size.value = 0;
		document.all.delimg.checked = false;
		document.all.imgview.style.display = 'none';
	}
	if(document.all.delattach.checked == true) {
		document.all.attfile.value = '';
		document.all.attach_name.value = '';
		document.all.total_size.value = eval(document.all.total_size.value) - eval(document.all.attach_size.value);
		document.all.file_cnt.value = eval(document.all.file_cnt.value) - 1;
		document.all.attach_size.value = 0;
		document.all.delattach.checked = false;
		document.all.attview.style.display = 'none';
	}
	if(document.all.imgview.style.display == 'none' && document.all.attview.style.display == 'none') {
		document.all.total_size.value = 0;
		document.all.file_cnt.value = 0;
		document.all.fileview.style.display = 'none';
	}
}
/*
function showPersonacon(persona_view_id) {
	var span_name = "persona"+persona_view_id;
	var open = document.getElementById(span_name).style.display;
	if(open == "none") {
		document.getElementById(span_name).style.display = '';
	}
	else {
		document.getElementById(span_name).style.display = 'none';
	}
}


function setPersona(frmName, cid, rid, pid, pimg) {
	var srcName = "personasrc" + cid;
	var span_name = "persona" + cid;
	document.getElementById(srcName).src = pimg;
	document.forms[frmName].personaconid.value = pid;
	if(document.getElementById(span_name).style.display == "") {
		document.getElementById(span_name).style.display = 'none';
	}
}
 */

function addBookmark(fn, loginid) {
	if(loginid == null || loginid <= 0) {
		alert(str_msg_no_member);
	} else {
		var strUrl = "/ps/ps_bookmark_C_add.php?target_cyid=" + fn.target_cyid.value + "&mh_domain=" + fn.mh_domain.value + "&mh_title=" + fn.mh_title.value;
		openMHPopup2(strUrl, '398', '310');
	}
}
function addImageFile() {
	if(document.frmWrite.imgFile.value) {
		document.frmWrite.file_cnt.value = 1;
	} else if(document.frmWrite.imgFile.value.split(" ").join("") == "") {
		document.frmWrite.file_cnt.value = 0;
	}
}
function ImageResize(objName) {
	myImage = new Image();
	myImage.src = document.getElementById(objName).src;
	if(myImage.width > 380) {
		document.getElementById(objName).style.width = 380;
		//alert(objName + ' : ' + document.getElementById(objName).style.width);
	} else {
		document.getElementById(objName).style.width = myImage.width;
	}
}

function ImageResize2(objName) {
	myImage = new Image(); 
	myImage.src = document.getElementById(objName).src;
	
	if(myImage.width > 380) {
		document.getElementById(objName).style.width = 380;	
	}
	/*
	if(myImage.height < 300 && myImage.width > 380) {
		document.getElementById(objName).style.width = 380;	
	} if(myImage.height >= 300 && myImage.width > 380) {
		document.getElementById(objName).style.width = 380;	
	} else if(myImage.height >= 300 && myImage.width <= 380)){
		document.getElementById(objName).style.height = 300;
	}
	*/

}

function ImageResize3(objName, size) {

	myImage = new Image(); 
	myImage.src = document.getElementById(objName).src;
	
	if ( myImage.width > size ) {
		document.getElementById(objName).style.width = size + "px";
		height = myImage.height * (size / myImage.width);
		height = parseInt(height);
		document.getElementById(objName).style.height = height + "px";
	}	

}


// added 2006.07.26
function ImageResize4(objName, origX, origY , sizeX, sizeY) {

	aX = 0;
	aY = 0;

	
	// first filter
	if ( origX >= origY ) {
		aX = sizeX;
		height = origY * (aX / origX);
		aY = parseInt(height);
	} else if ( origX < origY ) {
		aY = sizeY;
		width = origX * (aY / origY);
		aX = parseInt(width);
	}

	// second filter
	if ( aX > sizeX ) {
		height = aY * (sizeX / aX);
		aY = parseInt(height);
		aX = sizeX;
	}
	if ( aY > sizeY ) {
		width = aX * (sizeY / aY);
		aX = parseInt(width);
		aY = sizeY;
	}

	try {
		docObj = document.getElementById(objName);
		docObj.style.width = aX + "px";
		docObj.style.height = aY + "px";
	} catch (e) {}

}



function ImageResizePreview(objImg,intWidth) {
	var myImage = new Image();
	myImage.src = objImg.src;
	
	if(myImage.width > intWidth) {
		objImg.style.width = intWidth;
	}
}
function ImageResizeThumb(objName) {
	myImage = new Image();
	myImage.src = document.getElementById(objName).src;
	if(myImage.width > myImage.height && myImage.width > 113) {
		document.getElementById(objName).style.width = 113;
		document.getElementById(objName).style.height = 84 * myImage.height / myImage.width;
	} else if(myImage.height > myImage.width && myImage.height > 84) {
		document.getElementById(objName).style.height = 84;
	}
}
function chkFolderAuthor(strUrl, author) {
	// ?? ?? ??
	if(!author)
	{
		alert(str_msg_no_authority);
		history.go(-1);
	}
	else {
		go_url('', strUrl);
	}
}
function sendTellme(mode, cyid, userName, hidUrl) { 
	var strUrl = ""; 
	if(mode == "album") { 
		strUrl = "/main/memo_writeC_Wview.php?hidMode=Picture&hidUrl=" + hidUrl; 
	} else if(mode == "video") { 
		strUrl = "/main/memo_writeC_Wview.php?hidMode=Video&hidUrl=" + hidUrl; 
	} else { 
		strUrl = "/main/memo_writeC_Wview.php?hidMode=Post&hidUrl=" + hidUrl; 
	}
	switch(mode) {
		case "diary":
			var cnt = 0;
			var i;
			var ChkObj = document.getElementsByName("ChkBox");
			var ChkBoxCnt = ChkObj.length;
			var ChkValue;
			if(!ChkBoxCnt) {
				if(ChkObj.checked == true) { cnt++; ChkValue = ChkObj.value; }
			} else {
				for(var i = 0; i < ChkBoxCnt; i++) {
					if(ChkObj[i].checked == true) { cnt++; ChkValue = ChkObj[i].value; }
				}
			}
			strUrl = strUrl + ChkValue;
			openMHPopup5(strUrl, '400', '500', 'No');
			break;
		default:
			openMHPopup5(strUrl, '400', '500', 'No');
			break;
	}
}
function registerCover(fn, cyid, postid, menuName, folderName) {
	if(confirm(str_msg_confirm_register_coverstory))
	{
		var strUrl = "/ps/ps_bbs_write_cover.php?mh_id=" + cyid + "&postid=" + postid + "&menu_name=" + menuName + "&folder_name=" + folderName;
		goWrite(fn, strUrl);
	}
}
	function setTabFolder(mode, menuid, folderid, folder_type) {
		switch(mode) {
			case ("submit"):
				if(!checkName()) 
					return false;
				else 
					return true;
		}
	}
	function checkName() {
		var fn = document.frmList;
		if(document.getElementById('menu_name').value.split(" ").join("") == "") {
			alert(str_msg_no_menu_name);
			return false;
		}
		var ele_chk=0;
		var arr_elements = new Array();
		var elements_num = fn.elements.length;
		for(i = 0; i < elements_num ; i++){
			if(fn.elements[i].name == "arr_folder_name[]"){
				arr_elements[ele_chk] = fn.elements[i];
				ele_chk++;
			}
		}
		//alert(ele_chk);
		for(i = 0; i < ele_chk; i++) {
			//alert(arr_elements[i].value);
			if (arr_elements[i].value.split(" ").join("")=="") {
				alert(str_msg_no_folder_name);
				return false;
			}
			if(wordFilter(arr_elements[i].value,'I')){
				return false;
			}
			if(FilterPattern('HAN',arr_elements[i].value)){
				return false;
			}
			// 2005-05-17 adou
			var bad_char = /#/;
			if(bad_char.test(arr_elements[i].value)){
				alert(str_msg_bad_folder_name);
				return false;
			}
		}		
		return true;
	}
var sRepeat=null; 
function doScrollerIE(dir, src, amount) { 
	if (amount==null) amount=10; 
	if (dir=="up") 
	document.getElementById(src).scrollTop-=amount; 
	else 
	document.getElementById(src).scrollTop+=amount; 
	if (sRepeat==null) 
	sRepeat = setInterval("doScrollerIE('" + dir + "','" + src + "'," + amount + ")",100); 
	return false 
} 
window.document.onmouseout = new Function("clearInterval(sRepeat);sRepeat=null"); 
window.document.ondragstart = new Function("return false"); 
function selAuthChange()
{
	var rObj = document.getElementById('read_open_type');
	var rIndex = rObj.options.selectedIndex;
	var rValue = eval(rObj.options[rIndex].value);
	var i, wIndex = 0;
	var wObj = document.getElementById('write_open_type');
	var wLength = 0;
	var wSelValue = eval(wObj.options[wObj.options.selectedIndex].value);
	if(rValue == null) {
	} else if(rValue == 2) {
		wObj.length = 1;
		wObj[0].value = rObj.options[rIndex].value;
		wObj[0].text = rObj.options[rIndex].text;
		wObj[0].selected = true;
	} else {
		for(i = 0; i < rObj.length; i++)
		{
			if(rValue <= eval(rObj[i].value) || rObj[i].value == "-1" || rObj[i].value == 2) wLength++;
		}
		wObj.length = wLength;
		wLength = 0;
		for(i = 0; i < rObj.length; i++)
		{
			if(rValue <= eval(rObj[i].value) || rObj[i].value == "-1" || rObj[i].value == 2)
			{
				wObj[wLength].text = rObj[i].text;
				wObj[wLength].value = rObj[i].value;
				if(wObj[wLength].value == wSelValue) {
					wObj[wLength].selected = true;
					wIndex = wLength;
				}
				wLength++;
			}
		}
		if(wObj[wIndex].value == "-1") {
			wObj[wIndex+1].selected = true;
		} else {
			wObj[wIndex].selected = true;
		}
	}
}
function setSelectedValue(str)
{
	var selObj = document.getElementById('folderid');
	var i;alert(selObj.length);
	for(i = 0; i < selObj.length; i++)
	{
		if(selObj.options[i].text == str) {selObj.options[i].selected = true;}
	}
}
function checkStringLength(strValue, MaxLen) {
	if(strValue.length > MaxLen) {
		alert('Maximum characters for guest entries is ' + MaxLen);
		return false;
	}
	return true;
}
function checkDeactive(fnCnt) {
	var str_msg_min_one_active_folder = "?ÔøΩÂ∞ëÔø???????ÔøΩÔøΩÔø??????ÔøΩÔøΩ?ÔøΩ‰ª∂Ôø??????";
	var ChkObj = document.getElementById("active_type");
	var i;
	
	if(fnCnt <= 1) {
		alert(str_msg_min_one_active_folder);
		document.location.reload();
	}
}
//=============== HTML EDITOR ================
// 2005-05-01 Add by Kim, HyunSoo
var color_mode = 0;

	
function Editinit() 
{	
	if(document.HTMLEDITOR){
		var Mysource = "<style>P {margin-top:2px;margin-bottom:2px;}</style>"
		document.HTMLEDITOR.document.designMode="On"
		HTMLEDITOR.document.open("text/html");
		HTMLEDITOR.document.write(Mysource);
		HTMLEDITOR.document.close();
		HTMLEDITOR.document.body.style.fontSize = "9pt";
		//HTMLEDITOR.document.body.style.fontFamily = "???";
		HTMLEDITOR.document.oncontextmenu = new Function("return false;");
	}
}
function Editorinit()		// 2005-05-14 : by KHS
{
	//alert(document.frmWrite.content.value);
	if(document.HTMLEDITOR){
		//alert("111");
		HTMLEDITOR.document.body.innerHTML = replace_str(document.frmWrite.content.value);
	}
}

function ShowHideMenu(menunm)
{
	//alert(menunm);
	if (document.getElementById(menunm).style.display == 'none')
	{
		document.getElementById(menunm).style.display = '';
		return;
	}
	if (document.getElementById(menunm).style.display == '')
	{
		document.getElementById(menunm).style.display = 'none';
		return;
	}
}

function SetFont(ch)
{		
	HTMLEDITOR.document.body.style.fontFamily = ch;
	ShowHideMenu('editorFontFamily');
}

function SetFontSize(ch)
{
	HTMLEDITOR.document.body.style.fontSize = ch;
	ShowHideMenu('editorFontSize');
}

function GetSource()
{	
	
	//alert("appName:"+navigator.appName);
	if (navigator.appName == "Microsoft Internet Explorer") {
	var backcolor = HTMLEDITOR.document.body.style.backgroundColor;
	var obj = HTMLEDITOR.document.getElementById("backcolor");
	var HTMLSOURCE = "";
	
	if(HTMLEDITOR.document.body.innerHTML == "") return HTMLSOURCE;
		if (backcolor.length == 0 || obj != null) {		
			//alert('asdfa');
			HTMLSOURCE = HTMLEDITOR.document.body.innerHTML;
			//HTMLSOURCE = HTMLEDITOR.document.body.innerHTML ;
		} else {
			HTMLSOURCE = "<div id='backcolor' style='background-color:" + backcolor + "'>" + HTMLEDITOR.document.body.innerHTML + "\n</div>";
		}
		return HTMLSOURCE;
	}
}


function menu_click(obj)
{
	HTMLEDITOR_Focus(document.getElementById('HTMLEDITOR'));
	if (obj.id == "id_Bold"){
		HTMLEDITOR.document.execCommand("Bold");
	}else if (obj.id == "id_Italic"){
		HTMLEDITOR.document.execCommand("Italic");
	}else if (obj.id == "id_Underline"){
		HTMLEDITOR.document.execCommand("Underline");
	}else if (obj.id == "id_StrikeThrough"){
		HTMLEDITOR.document.execCommand("StrikeThrough");
	}else if (obj.id == "id_fontcolor") {
		Preview_Color('1');
	}
	else if (obj.id == "id_bgcolor") {
		Preview_Color('2');
	}
	else if (obj.id == "id_backcolor") {
		Preview_Color('3');
	}
	else if (obj.id == "id_alignLeft") {
		HTMLEDITOR.document.execCommand("JustifyLeft");
	}
	else if (obj.id == "id_alignCenter") {
		HTMLEDITOR.document.execCommand("JustifyCenter");
	}
	else if (obj.id == "id_alignRight")   {
		HTMLEDITOR.document.execCommand("JustifyRight");
	}
	else if (obj.id == "id_imgup")   {
		Preview_Img();
	}
	else if (obj.id == "id_link")   {
		Set_link();
	}
	else if (obj.id == "id_hr")  {
		HTMLEDITOR.document.execCommand("InsertHorizontalRule");
	}
	if(obj.id != "id_imgup")		HTMLEDITOR.focus();
}
function HTMLEDITOR_Focus(obj){
	// XXX
	if(obj.tagName.toLowerCase()=="iframe"){
		var objDoc		= obj.contentWindow.document;			//**	?? ???? ?? ??
		var objRange	= objDoc.body.createTextRange();		//**	??? Range
		var objcurRange	= objDoc.selection.createRange();		//**	?? Range
		if(objcurRange.length == null && !objRange.inRange(objcurRange)){
			objRange.collapse();
			objRange.select();
			objcurRange	= objRange;
		}
	}
}
function Preview_Color(type)
{
    window.open('/common/include/editor_colorpick.php?type=' + type, 'Editcolorpicker', 'width=330,height=270,resizable=no,menubar=no');
}
function colorpick_cover(mode){
	
	if( mode!=""){
		//alert('color_mode'+color_mode);
		color_mode = mode;
	}
	// ?? ??? ???
	//alert('/common/include/editor_colorpick.php?type=' + color_mode);
    window.open('/common/include/editor_colorpick.php?type=' + color_mode, 'Editcolorpicker', 'width=330,height=270,resizable=no,menubar=no');
}
function colorpickT(mode){
	
	if( mode!=""){
		//alert('color_mode'+color_mode);
		//color_mode = mode;
	}
	window.open('/common/include/editor_colorpick.php?type=' + color_mode, 'Editcolorpicker', 'width=330,height=270,resizable=no,menubar=no');
}
function add_fontcolor(color_type)
{
	
	if(color_mode == color_type)
	{
		document.getElementById("fontcolor_select").style.display = 'none';
		color_mode = 0;
	}
	else
	{
		select_str = HTMLEDITOR.document.selection.createRange();	
		document.frmWrite.fontcolor_code.value = '';    // ???? ??? ???
				
		document.frmWrite.color_type.value = color_type;
		document.getElementById("fontcolor_select").style.display = '';
		
		color_mode = color_type; 
		
	}
}
function coverstorySetFont(str){

	select_str = HTMLEDITOR.document.selection.createRange();
	if(select_str!=""){
		HTMLEDITOR.document.execCommand("forecolor", null, str);
	}
	
}
function SelectColor(str) 
{
	if (document.frmWrite.color_type.value == "2")
	{
		Set_bgcolor(str);			
	}
	else if (document.frmWrite.color_type.value == "3")
	{
		Set_backcolor(str);
	}
	else 
	{
		Set_fontcolor(str);
	}		
	document.getElementById('fontcolor_select').style.display = 'none';
	color_mode = 0;
}
function Set_bgcolor(color)
{
	HTMLEDITOR.document.body.style.backgroundColor = color;
}
function Set_fontcolor(color)
{ 
    HTMLEDITOR.document.body.style.color = color;
}
function Set_backcolor(color)
{
	HTMLEDITOR.document.body.style.backgroundColor = color;
}
function Set_link()
{
	var mylink = prompt("insert link","http://");
	
	Myselect = HTMLEDITOR.document.selection.createRange();
	if (Myselect!=null)
	{
	    Myselect.pasteHTML("<a href=\"" + mylink + "\" target=\"_blank\">" + Myselect.text + "</a> ");
	}
}

function ShowEmoticon(em)
{
	var ImgSrc="";
	var emNum="";
	switch(em)
	{
		case "/aa/":
			emNum = "0001";
			break;
		case "/bb/":
			emNum = "0002";
			break;
		case "/cc/":
		emNum = "0003";
		break;
		case "/dd/":
			emNum = "0004";
			break;
		case "/ee/":
			emNum = "0005";
			break;
		case "/ff/":
			emNum = "0006";
			break;
		case "/gg/":
			emNum = "0007";
			break;
		case "/hh/":
			emNum = "0008";
			break;
		case "/ii/":
			emNum = "0009";
			break;
		case "/jj/":
			emNum = "0010";
			break;
		case "/kk/":
			emNum = "0011";
			break;
		case "/ll/":
			emNum = "0012";
			break;
		case "/mm/":
			emNum = "0013";
			break;
		case "/nn/":
			emNum = "0014";
			break;
		case "/oo/":
			emNum = "0015";
			break;
		case "/pp/":
			emNum = "0016";
			break;
		case "/qq/":
			emNum = "0017";
			break;
		case "/rr/":
			emNum = "0018";
			break;
		case "/ss/":
			emNum = "0019";
			break;
	}
	
	ImgSrc = "<img src='http://img.us.cyworld.com/image/main/ico_em_" + emNum + ".gif'/>";
	
	var sText = HTMLEDITOR.document.selection.createRange();

		var sText = HTMLEDITOR.document.selection.createRange();
		if (sText.parentElement().all.HTMLEDITOR == null){
				  sText.pasteHTML(ImgSrc);
				  sText.select();
		} else {
			HTMLEDITOR.document.body.innerHTML =  HTMLEDITOR.document.body.innerHTML+ImgSrc;
			HTMLEDITOR.focus();
		}	
			
	if(document.getElementById('editorEmoticonFamily')){
		document.getElementById('editorEmoticonFamily').style.display = 'none';	
	}	
		
	/* 
	sText.select();
	sText.pasteHTML(ImgSrc);
	sText.select();	
	if (sText.parentElement().all.HTMLEDITOR == null)
	{
		
		sText.pasteHTML(ImgSrc);
		sText.select();
	}
	else
	{
		
		HTMLEDITOR.document.body.innerHTML =  ImgSrc + HTMLEDITOR.document.body.innerHTML
		HTMLEDITOR.focus();
	}
	*/
}
//===============// HTML EDITOR ==============
//===============  ??  =====================
function GoToAction(strMode, fn, strUrl){
	// action?? ???? submit??
	// ?? POST? ???
	switch(strMode){
		case "AlbumWrite":
			fn.action = strUrl;
			break;
		case "AlbumDelete":
			break;
	}
	fn.submit();
}
function SearchImageFile(){
	alert("Search Image File");
	document.all['imgfile'].click();
}
function goBookmark(redirectUrl, cyid, cyfid, postid) {
	var strUrl = '/ps/ps_bookmark_click.php?cyid=' + cyid + '&cyfid=' + cyfid + '&postid=' + postid + '&redirect_url=' + redirectUrl;
	window.open(strUrl, '_blank');
}
//===============  //??  =====================
	function aaa() {}
	function MM_openBrWindow(theURL,winName,features)
	{
		//alert(winName);
		window.open(theURL,winName,features);
		//eval(winName +".document.location='"+ theURL +"'");
	}
	function delVisitLog(code, del_id)
	{
		var fn = document.frmList;
		if(code == "del_visit")
		{
			fn.method = "POST";
			//alert(code + ' - ' + del_id);
			fn.action = "./cover_index.php?mode="+code+"&del_id="+del_id;
			fn.submit();
		}
	}
	function goPSHome(login_id, mh_id)
	{
		//document.write(login_id);
		window.open('./cover_index.php?login_id='+login_id+'&mh_id='+mh_id, 'mh_window');
		window.close();
	}
	function addMenuList(mode)
	{
		var fn = document.frmMenu;
		fn.flag.value = mode;
		fn.action = "./menu_list.php";
		//alert('?? ?? ??');
		if(fn.action && fn.flag.value)
		{
			fn.submit();
		}
		else
		{
			alert('?? ?? ?? Error!!!');
		}
	}
	function modifyMenu()
	{
		var fn = document.frmMenu;
		fn.action = "./menu_modify_proc.php";
		//alert('???? ??');
		if(fn.action)
		{
			fn.submit();
		}
		else
		{
			alert('?? ???? ?? Error!!!');
		}	
	}
	function delMenuList(mode)
	{
		var fn = document.frmMenu;
		fn.menuid.value = mode;
		fn.action = "./menu_del_proc.php";
		//alert(mode + ' ?? ??');
		alert(fn.action);
		if(fn.action && fn.menuid.value)
		{
			fn.submit();
		}
		else
		{
			alert(mode + ' ?? ?? ?? Error!!!');
		}
	}
	function addFolderList(mode)
	{
		var fn = document.frmFolder;
		fn.flag.value = mode;
		fn.action = "./menu_subfolder_list.php";
		//alert('??? ?? ??');
		if(fn.action && fn.flag.value)
		{
			fn.submit();
		}
		else
		{
			alert('??? ?? ?? Error!!!');
		}
	}
	function modifyFolder(mode)
	{
		var fn = document.frmFolder;
		fn.flag.value = mode;
		fn.action = "./menu_subfolder_modify_proc.php";
		//alert('???? ??');
		if(fn.action)
		{
			fn.submit();
		}
		else
		{
			alert('?? ???? ?? Error!!!');
		}	
	}
	function viewFolderDetail(mode)
	{
		var fn = document.frmFolder;
		fn.folderid.value = mode;
		fn.action = "./menu_subfolder_modify_detail.php";
		//alert(<?=$menuid;?>+'??? '+fn.folderid.value+' ?? : ???? ??');
		if(fn.action && fn.folderid.value)
		{
			fn.submit();
		}
		else
		{
			alert('?? ???? ?? Error!!!');
		}
	}
	function delFolder(mode)
	{
		var fn = document.frmFolder;
		fn.folderid.value = mode;
		fn.action = "./menu_subfolder_del_proc.php";
		//alert(<?=$menuid;?>+'??? '+fn.folderid.value+' ?? : ?? ??');
		if(fn.action && fn.folderid.value)
		{
			if(confirm(str_msg_delete_album_confirm))
				{
					fn.submit();
				}
		}
		else
		{
			alert('?? ?? ?? Error!!!');
		}
	}
	function newDelFolder(fn)
	{
		//var fn = document.frmFolder;
		//fn.folderid.value = mode;
		if(!ChkSelValues(fn)) { alert(str_msg_no_selected_del_post); }else{
		//alert(fn.ChkValues.value);
		fn.action = "http://us.cyworld.com/profile/photos/album_folder_delete_proc.php";
		//alert(<?=$menuid;?>+'??? '+fn.folderid.value+' ?? : ?? ??');
		if(fn.action && fn.ChkValues.value)
		{
			if(confirm("Are you sure you want to delete this album? All photos in this album will be deleted once you do."))
				{
					fn.submit();
				}
		}
		else
		{
			alert('?? ?? ?? Error!!!');
		}
		}
	}
	function moveWindow(url)
	{
		var fn = document.frmFolder;
		fn.action = url;
		//alert('???? ??');
		if(fn.action)
		{
			fn.submit();
		}
		else
		{
			alert('?? ???? ?? ?? Error!!!');
		}	
	}
	function goBBSList()
	{
		var fn = document.frmWrite;
		fn.action = "./bbs_main.php";
		//alert(' login_id : '+fn.login_id.value+'\n mh_id : '+fn.mh_id.value+'\n menuid : '+fn.menuid.value+'\n folderid : '+fn.folderid.value);
		if(fn.action)
		{
			fn.submit();
		}
		else
		{
			alert('?? ?? ??!!!');
		}
	}
	function addPost(_actionURL)
	{
		var fn = document.frmWrite;
		fn.action = _actionURL;
		if(fn.action)
		{
			fn.submit();
		}
		else
		{
			alert('??? ??? ?????? ??!!!');
		}
	}
	function goWindow(fn, _URL)
	{
		// ??? ?? function
		fn.action = _URL;
		//alert(fn.action);
		if(fn.action)
		{
			fn.submit();
		}
		else
		{
			alert('??? ?? ??!!!');
		}
	}
	function goViewBoard(fn, _URL, post_id)
	{
		fn.postid.value = post_id;
		fn.action = _URL;
		fn.submit();
	}
//-->
// ??? ??(??) - ????
/*
function ChkSelValues(fn)					
	{
	var ChkValues = ""; 
	var ChkObj = document.frmList.ChkBox;
	var ChkBoxCnt = ChkObj.length;
	var ChkNum = 0;
	if(!ChkBoxCnt) {
		if(ChkObj.checked == true) {
			ChkValues = ChkObj.value ;
		}
	}
	else {
		for(var i = 0; i < ChkBoxCnt; i++) {
			if(ChkObj[i].checked == true) {
				if(ChkNum == 0) {
					ChkValues += ChkObj[i].value ; ChkNum = 1;
				}
				else {
					ChkValues += "," + ChkObj[i].value;
				}
			}
		}
	}
	alert(ChkValues);
	fn.folderid.value = ChkValues;	// ??? ??? ( ??? : ',')
	if (ChkValues == "") { return false; } else { return true; }
	}*/

//----------- 2005-04-26 adou
function chkProfile2(fn, mode){
	if (chk_broswer() ) { //iframe HTMLEDITOR modification is only possible in IE
		fn.content.value = GetSource();
	}
	switch(mode){
		case 'modify':
			//if(wordFilter(fn.content.value,'B')){
				//return false;
			//}
			if(FilterPattern('HAN',fn.content.value)){
				return false;
			}
			return true;
			break;
		default:
			if(fn.img_name.value == ""){
				alert(str_msg_no_img);
				return false;
			}
			if(FilterPattern('HAN',fn.content.value)){
				return false;
			}
			//if(wordFilter(fn.content.value,'B')){
				//return false;
			//}
			return true; 
			break;
	}
}
//------------


//----------- 2006-06-19 Alex
function validateCSMini(fn, mode){

	if (navigator.vendor != "Apple Computer, Inc.") {
		var oEditor = FCKeditorAPI.GetInstance('cContent') ;
		fn.csContent.value = oEditor.EditorDocument.body.innerHTML;
	} else {
		fn.csContent.value = fn.cContent.value;
	}

	switch(mode){
		case 'modify':
			if(wordFilter(fn.csContent.value,'I')){
				return false;
			}
			if(FilterPattern('HAN',fn.csContent.value)){
				return false;
			}
			return true;
			break;
		default:
			if(wordFilter(fn.csContent.value,'I')){
				return false;
			}
			if(FilterPattern('HAN',fn.csContent.value)){
				return false;
			}
			return true; 
			break;
	}

}

// when editing your info in minihome > profile
function ProfileModifyPro(){
	var fn = document.frmMember;

	if(wordFilter(fn.txtComment.value, 'B')){
		fn.txtComment.focus();
		return false;
	}
	
	if(FilterPattern('HAN',fn.txtComment.value)){
		return false;
	}	
	
	// cell phone
	if (fn.txtCP.value != "") {
		if (PNumberCheck(fn.txtCP.value)) {
			alert("Please enter a valid mobile phone number.");
			return false;
		}
	}
	// home phone
	if (fn.txtHome_Phone.value != "") {
		if (PNumberCheck(fn.txtHome_Phone.value)) {
			alert("Please enter a valid home phone number.");
			return false;
		}
	}
	// home phone
	/*
	if (fn.txtCompanyPhone.value != "") {
		if (PNumberCheck(fn.txtCompanyPhone.value)) {
			alert("Please enter a valid office phone number.");
			return ;
		}
	}
	
	if(wordFilter(fn.txtAnniversary1.value, 'I')){
		fn.txtAnniversary1.focus();
		return ;
	}
	
	if(FilterPattern('HAN',fn.txtAnniversary1.value)){
		return;
	}
	
	if(wordFilter(fn.txtAnniversary2.value, 'I')){
		fn.txtAnniversary2.focus();
		return ;
	}
	
	if(FilterPattern('HAN',fn.txtAnniversary2.value)){
		return;
	}	
	
	if(wordFilter(fn.txtAnniversary3.value, 'I')){
		fn.txtAnniversary3.focus();
		return ;
	}
	
	if(FilterPattern('HAN',fn.txtAnniversary3.value)){
		return;
	}				
*/	
	// Anniversay Date and description validation
	/*
	if ( (fn.selAnniversary1Month.selectedIndex != 0 && fn.selAnniversary1Day.selectedIndex == 0) || (fn.selAnniversary1Month.selectedIndex == 0 && fn.selAnniversary1Day.selectedIndex != 0) ) { 
		alert("Please select a month and day of Date 1");
		return;
	}
	if ( trim(fn.txtAnniversary1.value) != "" && fn.selAnniversary1Month.selectedIndex == 0 ) {
		alert("Please select a month and day of Date 1");
		return;
	}
	if ( trim(fn.txtAnniversary1.value) == "" && fn.selAnniversary1Month.selectedIndex != 0 ) {
		alert("Please enter a description of Date 1");
		return;
	}
	
	if ( (fn.selAnniversary2Month.selectedIndex != 0 && fn.selAnniversary2Day.selectedIndex == 0) || (fn.selAnniversary2Month.selectedIndex == 0 && fn.selAnniversary2Day.selectedIndex != 0) ) { 
		alert("Please select a month and day of Date 2");
		return;
	}
	if ( trim(fn.txtAnniversary2.value) != "" && fn.selAnniversary2Month.selectedIndex == 0 ) {
		alert("Please select a month and day of Date 2");
		return;
	}
	if ( trim(fn.txtAnniversary2.value) == "" && fn.selAnniversary2Month.selectedIndex != 0 ) {
		alert("Please enter a description of Date 2");
		return;
	}

	if ( (fn.selAnniversary3Month.selectedIndex != 0 && fn.selAnniversary3Day.selectedIndex == 0) || (fn.selAnniversary3Month.selectedIndex == 0 && fn.selAnniversary3Day.selectedIndex != 0) ) { 
		alert("Please select a month and day of Date 3");
		return;
	}
	if ( trim(fn.txtAnniversary3.value) != "" && fn.selAnniversary3Month.selectedIndex == 0 ) {
		alert("Please select a month and day of Date 3");
		return;
	}
	if ( trim(fn.txtAnniversary3.value) == "" && fn.selAnniversary3Month.selectedIndex != 0 ) {
		alert("Please enter a description of Date 3");
		return;
	}		
*/
//Add for zip code validation by Wendy Zhang	

	if (fn.nation_id.value == "US" && !isZipCode(fn.zipcode) && fn.zipcode.value=='') {
		return;
	}

	//fn.action = "/ps/ps_profile_modify.php";
	//fn.action = "/profile/settings/profile/general_proc.php";
	//fn.submit();
}

function ExtendProfileModifyPro(){
	var fn = document.frmMember;
/*	
	if(wordFilter(fn.txtComment.value, 'B')){
		fn.txtComment.focus();
		return ;
	}
	if(FilterPattern('HAN',fn.txtComment.value)){
		return;
	}
*/
	if(wordFilter(fn.school_name.value, 'B')){
		fn.school_name.focus();
		return ;
	}
	if(FilterPattern('HAN',fn.school_name.value)){
		return;
	}
/*	
	if(wordFilter(fn.school_location.value, 'B')){
		fn.school_location.focus();
		return ;
	}
	if(FilterPattern('HAN',fn.school_location.value)){
		return;
	}
*/
	if(wordFilter(fn.favorite_sports.value, 'B')){
		fn.favorite_sports.focus();
		return ;
	}
	if(FilterPattern('HAN',fn.favorite_sports.value)){
		return;
	}
	if(wordFilter(fn.favorite_movies.value, 'B')){
		fn.favorite_movies.focus();
		return ;
	}
	if(FilterPattern('HAN',fn.favorite_movies.value)){
		return;
	}

	if(wordFilter(fn.favorite_bands.value, 'B')){
		fn.favorite_bands.focus();
		return ;
	}
	if(FilterPattern('HAN',fn.favorite_bands.value)){
		return;
	}
	if(wordFilter(fn.other_interests.value, 'B')){
		fn.other_interests.focus();
		return ;
	}
	if(FilterPattern('HAN',fn.other_interests.value)){
		return;
	}
	//fn.action = "/ps/extend_profile_modify.php";
	//fn.action = "/profile/settings/profile/aboutme_proc.php";
	fn.action = "/profile/settings/profile/general_proc.php";
	fn.submit();
}

function PersonInfoPro(strMode){
	var fn = document.frmMember;
	fn.hidMode.value = strMode;	// ??? ????.
	if (strMode == "Email")		//??? ?? ??
		{
		if (!IsEmail(fn.txtEmail1.value)) { alert("Enter email."); fn.txtEmail1.value = ""; fn.txtEmail1.focus(); return; }
		if (fn.hidEmail.value == fn.txtEmail1.value)
			{ alert("Enter email"); fn.txtEmail1.value = ""; fn.txtEmail1.focus(); return; }
		if (fn.txtEmail1.value != fn.txtEmail2.value)
			{ alert("Enter email."); fn.txtEmail2.value = ""; fn.txtEmail2.focus(); return; }
		}
	else if (strMode == "Password")		//???? ??
		{
		if (fn.txtPassword.value == "")
			{ alert("Enter Password"); fn.txtPassword.focus(); return; }
		if (fn.txtUPPassword1.value == "")
			{ alert("Enter Password Confirm"); fn.txtUPPassword1.focus(); return; }
		if (fn.txtUPPassword2.value == "")
			{ alert("Enter Password Confirm"); fn.txtUPPassword2.focus(); return; }
		if (fn.txtUPPassword1.value != fn.txtUPPassword2.value)
			{ alert("Enter Password Confirm."); fn.txtUPPassword2.value = ""; fn.txtUPPassword2.focus(); return; }
		}
	fn.action = "profile_info_pro.php"; fn.submit();
}
/* ????? ?? ??? ?? ???? ????
*/
function diary_move(folderid){
	fn = document.frm_Diary_folder_list;
	fn.folderid.value=folderid;
	fn.submit();
}
/* ???????? ?? ???
*/
function diary_submit(submit_mode,diary_id){
	fn = document.frmBBSDiary;
	switch(submit_mode){
		case("delete"):
			fn.target = "fraDiaryHidden";
			fn.action = "./ps_diary_delete.php";
		break;
		case("write"):
			fn.target = "_self";
			fn.action = "./ps_diary_Wview.php";
		break;
	}
	fn.diary_id.value=diary_id;
	if(fn.action){
		fn.submit();
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////
// ?? : ???
// ??? ??, ??? ?? ??? ?? ??
function fncDisplayIcon(strGubun, intIcon){
	var fn = document.frmWrite;
	
	if(intIcon == "") { 
		if(strGubun == "em"){ alert("" + str_msg_select_em_none + "");  fn.emoticonid.focus(); return; }
		else { alert("" + str_msg_select_wea_none + "");  fn.weatherid.focus(); return; }
	}else{
		if(strGubun == "em"){ 
			document.getElementById("div_emoticon").innerHTML = "<img src='http://img.us.cyworld.com/image/common/icon/ico_em_" + intIcon + ".gif' align='absmiddle'>";
		}else{
			document.getElementById("div_weather").innerHTML = "<img src='http://img.us.cyworld.com/image/common/icon/ico_wea_" + intIcon + ".gif' align='absmiddle'>";
		}
	}
}
function fncDisplayIconN(strGubun, intIcon){
	var fn = document.frmWrite;
	
	if(intIcon == "") { 
		//if(strGubun == "em"){ alert("" + str_msg_select_em_none + "");  fn.emoticonid.focus(); return; }
		//else { alert("" + str_msg_select_wea_none + "");  fn.weatherid.focus(); return; }
	}else{
		if(strGubun == "em"){ 
			document.getElementById("div_emoticon").innerHTML = "<img src='http://img.us.cyworld.com/image/ps/feeling/ic_today" + intIcon + ".gif' align='absmiddle'>";
		}else{
			document.getElementById("div_weather").innerHTML = "<img src='http://img.us.cyworld.com/image/common/icon/ico_wea_" + intIcon + ".gif' align='absmiddle'>";
		}
	}
}
// ??? ????? ??
function fncPhotoUpCheck(){
	var fn = document.frmProfileImg;
	if (fn.userfile.value == "") { alert("" + str_msg_img_none + ""); fn.userfile.focus(); return false; }
	else { return true; }
}
//2005-06-07 adou ‰Ωø�?î®?ÔøΩ�?º©?ÔøΩ�?âá?ÔøΩ‰ª∂?ÔøΩ‰�?™‰∫∫ÂΩ¢Ë±°�?Öß‰�?ä‰º†
function fncProfilePhotoUpCheck(fn){
	
	if(wordFilter(fn.txtComment.value, 'B')){
		fn.txtComment.focus();
		return false;
	}		
			
	if(FilterPattern('HAN',fn.txtComment.value)){
		return false;
	}
	
	//if (fn.dstfile.value == "") { alert("" + str_msg_img_none + ""); return false; }
	//else { return true; }
	
}
function music_title_view(){
	try{
		if(top.frmBGM && window.name == "ps_main"){
			if(top.frmBGM.str_music_title.value){
				top.ps_main.music_title.innerText = top.frmBGM.str_music_title.value;
			}
			//2005-06-28 adou
			if(top.frmBGM.str_music_play_list.value){
				top.ps_main.music_play_list.innerHTML = top.frmBGM.str_music_play_list.value;
			}
		}
	}
	catch(e){
//		alert(e);
	}
}
function chk_album_form_submit(fn){
	if(!fn.img_name.value){
		alert(str_msg_submit_with_file);
		fn.img_name.focus();
		return false;
	}	
	if(trim(fn.title.value) == "") {
		alert(str_msg_no_title);
		fn.title.focus();
		return false;
	}
	//20050804 by yt
	if(fn.content.value.length > 1000){
		alert("Mximum content length is 1000 letters");
		return false;
	}

	return true;
}
//20050804 by yt
function chk_album_form_submit_m(fn){
	if(fn.content.value.length > 1000){
		alert("Mximum content length is 1000 letters");
		return false;
	}
	return true;
}
//20050804 by yt
function chk_gallery_form_submit(fn){
	
	if(wordFilter(fn.title.value, 'T')){
		fn.title.focus();
		return false;
	}
	if(wordFilter(fn.content.value, 'B')){
		fn.content.focus();
		return false;
	}
	if(FilterPattern('HAN',fn.title.value)){
		return false;
	}
	if(FilterPattern('HAN',fn.content.value)){
		return false;
	}	
	//if(fn.content.value.length > 1000){
	//	alert("Mximum content length is 1000 letters");
	//	return false;
	//}
	return true;
}
// ???? ??? ?? - by zmania
function used_item_win_open(mh_id){
	strUrl = "ps_item_used.php?mh_id="+mh_id;
	strName = "UsedItemViewwindow";
	WinWidth = 438;
	WinHeight = 285;
	ScrollBar = 0;
	Resize = "no";
	WinGubun = "Center";
	strProperty = "";
	used_item_win = WinOpen(strUrl,strName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
}
// Joung-Won 2005-05-03
function fncPSStarSign(intMonth, intDay){
	var fn = document.frmMember;
	var intDateVal = 0;
	var strStarName = "";
	if (fn.selBirthYear.value == ""){ alert("" + str_msg_year_select + ""); fn.selBirthYear.focus(); return; }
	if (fn.selBirthMonth.value == ""){ alert("" + str_msg_month_select + ""); fn.selBirthMonth.focus(); return; }
	if (fn.selBirthDay.value == ""){
		alert("" + str_msg_day_select + ""); fn.selBirthDay.focus(); return;
	}else{
		if(intDay.length == 1){	intDateVal = intMonth + "0" + intDay; }
		else { intDateVal = intMonth + intDay; }
		for(i = 1; i < int_star_sign_cnt; i++){
			if(str_my_star_chk[i][0] <= intDateVal && str_my_star_chk[i][1] >= intDateVal){
				strStarName = str_my_star_name[i][1];
				intStarType = i;
			}
		}
		
		if(strStarName == ""){ strStarName = str_my_star_name[12][1]; intStarType = 12; }
		star_sign_text.innerHTML = strStarName;
		document.frmMember.hidConstellationType.value = intStarType;
	}
}
function fncPSSetDay(intYear, intMonth, strDay){
	var fn = document.frmMember;
	var intDayCnt;
	var objDay= eval("document.frmMember." + strDay);	
	
	if (fn.selBirthYear.value == ""){ alert("" + str_msg_year_select + ""); fn.selBirthYear.focus(); return; }
	if (fn.selBirthMonth.value == ""){ 
		alert("" + str_msg_month_select + ""); fn.selBirthMonth.focus(); return;
	}else{
		fncSelectClear(objDay);		// ??(select box)? ??? ??.
		intDayCnt = fncChangeMonth(intYear, intMonth);	// ?, ?? ???? ?? ??? ?? ??? ?? ???.
		
		if(intDayCnt > 0) { for(i=1; i <= intDayCnt; i++) { objDay.options[i-1] = new Option(i,i); } }
	}
}
//?ÔøΩÂà∂ËæìÂÖ•Â≠óÊï∞
//2005-05-17 adou
function checkMaxText(ctl_input) {
	if(ctl_input.maxlength){
		if (ctl_input.value.length > ctl_input.maxlength)
		{
			ctl_input.value = ctl_input.value.substr(0, ctl_input.maxlength);  
			//ctl_input.blur();
		}
	}
}

// 2006.07.18
function frmWriteSubmit(me, action) {
	if ( validateComment(me, action) == true ) {
		me.submit();
	}
}


// ============================================================================
// Alex
// 2006-06-13
// functions for ps_miniroom_view
//=============================================================================
g_persona_div_0_over = false;
g_persona_div_1_over = false;
g_persona_div_2_over = false;
g_persona_div_3_over = false;
g_persona_div_4_over = false;


function set_persona_div_0_mouse_over()
{	
	g_persona_div_0_over = true;
}

function set_persona_div_1_mouse_over()
{	
	g_persona_div_1_over = true;
}

function set_persona_div_2_mouse_over()
{	
	g_persona_div_2_over = true;
}

function set_persona_div_3_mouse_over()
{	
	g_persona_div_3_over = true;
}

function set_persona_div_4_mouse_over()
{	
	g_persona_div_4_over = true;
}

	
function set_persona_div_0_mouse_out()
{
	g_persona_div_0_over = false;
}

function set_persona_div_1_mouse_out()
{
	g_persona_div_1_over = false;
}

function set_persona_div_2_mouse_out()
{
	g_persona_div_2_over = false;
}

function set_persona_div_3_mouse_out()
{
	g_persona_div_3_over = false;
}

function set_persona_div_4_mouse_out()
{
	g_persona_div_4_over = false;
}

function addToFavorites(URL, NAME) { 
	if (window.external) { 
		window.external.AddFavorite(URL, NAME) 
	} else { 
		alert("Sorry! Your browser doesn't support this function."); 
	} 
}

function Edit_Title(num) {
	if (num=="1") {
		document.getElementById("title_view").style.display="none";
		document.getElementById("title_edit").style.display="block";
	}else if (num=="2") {
		document.getElementById("title_view").style.display="block";
		document.getElementById("title_edit").style.display="none";
	}
}

function Title_Color(colorcode) {
	ffcolorcode = '#' + colorcode;
	document.getElementById("pstitlefrm").title.style.color = ffcolorcode;	
	document.getElementById("pstitlefrm").fontcolor.value = colorcode;		
}

function colorpick()    {
        window.open('/common/include/editor_colorpick.php?type=5', 'Editcolorpicker', 'width=330,height=270,resizable=no,menubar=no');
}

String.prototype.trim = function()
{
  return this.replace(/(^\s*)|(\s*$)/gi, "");
}

function colorSubmit()    
{
	if(document.pstitlefrm.title.value == ''){
		alert('Enter your Profile title.');
		document.pstitlefrm.title.value='';
		document.pstitlefrm.title.focus();
	} else {
		if(wordFilter(document.pstitlefrm.title.value, 'I')){
			alert("filter");
			return;
		}
		//filtering 
		if( FilterPattern('HAN',document.pstitlefrm.title.value) ) {
			document.pstitlefrm.title.focus();
	       	return;
	    } 
		document.getElementById("pstitle").innerHTML = document.pstitlefrm.title.value ;
		document.getElementById("title_view").style.display="block";
	    document.getElementById("title_edit").style.display="none";
	    document.pstitlefrm.submit();           
	}
} 

function colorSubmit_old()    {
	if(document.pstitlefrm.title.value.trim() == ''){
		alert('Enter your Profile title.');
		document.pstitlefrm.title.value='';
		document.pstitlefrm.title.focus();
	} else {
		//filtering 
		if(FilterPattern('HAN',document.pstitlefrm.title.value)) {
			document.pstitlefrm.title.focus();
	               	return;
	               } 
		pstitle.innerHTML = document.pstitlefrm.title.value ;
		pstitle.style.color = document.pstitlefrm.fontcolor.value;	
		title_view.style.display="block";
	               title_edit.style.display="none";

	               document.pstitlefrm.submit();
	               
	}
}

function chkOS() {
	var os_type;
	if (navigator.platform == "MacPPC") {
		os_type = 1;
	} else {
		os_type = 0;
	}
	return(os_type);
}

// format the content to meet it uniform
// 2007.07.28
function formatContent(content, act) {

	if ( act == "add") {
		s = content;		
		s = s.replace(/\n/g, "&nbsp;</p>\n<p>");
		s = "<p>" + s + "</p>";
		return s;
	} else if ( act == "remove" ) {
		s = content;
		s = s.replace(/<\/[p|P]>/g, "");
		s = s.replace(/<[p|P]>/g, "");
		return s;
	}
	return content;

}

function showPicture(src) {
		var imgObj = new Image();
		imgObj.src = src;
		/*
		if ( imgObj.width > document.body.clientWidth ) 
			var wopt = "scrollbars=yes,status=no,resizable=yes";
		else
		*/ 
			var wopt = "scrollbars=yes,status=no,resizable=yes";

		wopt += ",width=" + imgObj.width;
		wopt += ",height=" + imgObj.height;
	
		var wbody = "<head><title>Photo Gallery</title>";
		wbody += "<script language='javascript'>";
		wbody += "function finalResize(){";
		wbody += "  var oBody=document.body;";
		wbody += "  var oImg=document.images[0];";
		wbody += "  var xdiff=oImg.width-oBody.clientWidth;";
		wbody += "  var ydiff=oImg.height-oBody.clientHeight;";
		//wbody += "  alert(oImg.width);";
		wbody += "  window.resizeBy(xdiff,ydiff);";
		wbody += "}";
		wbody += "</"+"script>";
		wbody += "</head>";
		wbody += "<body onLoad='finalResize()' style='margin:0'>";
		wbody += "<a href='javascript:window.close()'><img src='" + src + "' border=0></a>";
		wbody += "</body>";
		winResult = window.open("about:blank","",wopt);
		winResult.document.open("text/html", "replace");
		winResult.document.write(wbody);
		winResult.document.close();
		return;
	}

// ============================================================================
// 2006-12-13
// functions for ps_video_display
//=============================================================================
function editTitleVideo(mode, id, postid) {

	switch(mode) {
		case "edit":
			titleTxt  = document.getElementById('title'+id);
			titleSet  = document.getElementById('titleset'+id);
			titleFld  = document.getElementById('titlefld'+id);
			editBtn   = document.getElementById('btnedittitle'+id);
			
			titleSet.style.display = 'inline';
			titleFld.value = strip_htmltag('decode', titleTxt.innerHTML);	
			titleTxt.style.display = 'none';
			editBtn.style.display = 'none';		
			break;
		
		case "cancel":
			titleTxt  = document.getElementById('title'+id);
			titleSet  = document.getElementById('titleset'+id);
			editBtn   = document.getElementById('btnedittitle'+id);
			
			titleSet.style.display = 'none';
			titleTxt.style.display = 'inline';
			editBtn.style.display = 'inline';
			break;
			
		case "save":
			titleFld  = document.getElementById('titlefld'+id);
			titleTxt  = document.getElementById('title'+id);
			
			fn = document.frmEdit;
			fn.postid.value = postid;
			fn.updateFld.value = 'title';
			fn.updateVal.value = titleFld.value;
			
			if ( trim(fn.updateVal.value) == "" ) {
				alert(str_msg_no_title);
				return;
			}
			
			if(wordFilter(titleFld.value, 'T')){
				return;
			}
			
			if(FilterPattern('HAN',titleFld.value)){
				return;
			}

			fn.submit();			
			editTitleVideo('cancel',id, 0);
			titleTxt.innerHTML = strip_htmltag('encode', fn.updateVal.value);
			break;
	}
	
}


function editContentVideo(mode, id, postid) {

	switch(mode) {
		case "edit":
			contentTxt  = document.getElementById('content'+id);
			contentSet  = document.getElementById('contentset'+id);
			contentFld  = document.getElementById('contentfld'+id);
			editBtn     = document.getElementById('btneditcontent'+id);
			
			contenttext = contentTxt.innerHTML;
			
			contentSet.style.display = 'inline';
			contentFld.value = strip_htmltag('decode', contenttext);
			editBtn.style.display = 'none';	
			tmp = contentTxt.style.color;
			if ( tmp.length > 0) {
				contentFld.style.color = tmp;
			} else {
				contentFld.style.color = '';
			}
			contentTxt.style.display = 'none';
			break;
		
		case "cancel":
			contentTxt  = document.getElementById('content'+id);
			contentSet  = document.getElementById('contentset'+id);
			editBtn     = document.getElementById('btneditcontent'+id);
			colorPicker = document.getElementById('ColorPicker'+id);
			
			contentSet.style.display = 'none';
			contentTxt.style.display = 'inline';
			editBtn.style.display = 'inline';
			
			if ( colorPicker.style.display == 'block') {
				colorPicker.style.display = 'none';
			}
			
			break;
			
		case "save":
			contentFld  = document.getElementById('contentfld'+id);
			contentTxt  = document.getElementById('content'+id);
			contentColor = document.getElementById('content_fontcolor'+id);
			
			fn = document.frmEdit;
			fn.postid.value = postid;
			fn.updateFld.value = 'content';
			fn.updateVal.value = contentFld.value;

			if ( trim(fn.updateVal.value) == "" ) {
				alert(str_msg_no_content);
				return;
			}

			if(wordFilter(contentFld.value, 'B')){
				return;
			}
			
			if(FilterPattern('HAN',contentFld.value)){
				return;
			}

			if ( contentColor.value != "" ) {
				fn.updateVal2.value = contentColor.value;
				contentTxt.style.color = contentFld.style.color;
			} else {
				fn.updateVal2.value = '';
			}

			fn.submit();			
			editContentVideo('cancel',id, 0);
			contentTxt.innerHTML = strip_htmltag('encode', fn.updateVal.value);
			break;
			
			
		case "colorPicker":
			colorPicker = document.getElementById('ColorPicker'+id);

			if ( colorPicker.style.display == 'block') {
				colorPicker.style.display = 'none';
			} else {
				colorPicker.style.display = 'block';
			}
			break;	
		
		case "colorPickerExtend":
			window.open('/common/include/editor_colorpick.php?type=7&id='+id, 'Editcolorpicker', 'width=330,height=270,resizable=no,menubar=no');
			break;
			
		case "setcolor":
			colorPicker = document.getElementById('ColorPicker'+id);
			contentColor = document.getElementById('content_fontcolor'+id);
			content_fontcolor = postid;
			
			ffcolorcode = '#' + content_fontcolor;
			document.getElementById('contentfld'+id).style.color = ffcolorcode;

			contentColor.value = content_fontcolor;
			colorPicker.style.display="none";
			break;
	}
	return;
}	

function editScrapVideo(id, postid) {
	
	scrap  = document.getElementById('scrap_yn'+id);
	
	if ( scrap.value == "Y" ) {
		scrap.value = "N";
	} else {
		scrap.value = "Y";
	}
	
	fn = document.frmEdit;
	fn.postid.value = postid;
	fn.updateFld.value = 'scrap';
	fn.updateVal.value = scrap.value;
			
	fn.submit();			

	
}

function editScrapImage(id, postid) {
	
	scrap  = document.getElementById('scrap_yn'+id);
	
	if ( scrap.value == "Y" ) {
		scrap.value = "N";
	} else {
		scrap.value = "Y";
	}
	
	fn = document.frmEdit;
	fn.postid.value = postid;
	fn.updateFld.value = 'scrap';
	fn.updateVal.value = scrap.value;
			
	fn.submit();			

	
}

function editScrapSketch(id, postid) {
	scrap  = document.getElementById('scrap_yn'+id);
	
	if ( scrap.value == "Y" ) {
		scrap.value = "N";
	} else {
		scrap.value = "Y";
	}
	
	fn = document.frmEdit;
	fn.postid.value = postid;
	fn.updateFld.value = 'scrap';
	fn.updateVal.value = scrap.value;

	fn.submit();			
}

function strip_htmltag(mode, val) {
	
	var tmp = val;
	
	switch(mode) {
		
		case "encode":
			// Be careful! Replace order is matter.
			tmp = tmp.replace(/>/g, "&gt;");
			tmp = tmp.replace(/</g, "&lt;");
			tmp = tmp.replace(/\n/g, "<br>");
			tmp = tmp.replace(/\s\s/g, " &nbsp;");
			break;
			
		case "decode":
			tmp = tmp.replace(/\s&nbsp;/g, "  ");
			tmp = tmp.replace(/<br>\n|<br>|<BR>/g, "\n");
			tmp = tmp.replace(/&gt;/g, ">");
			tmp = tmp.replace(/&lt;/g, "<");
			break;
		
	}

	
	return tmp;
	
}		

//Add for zip code validation by Wendy Zhang
function isZipCode(obj)
{
	var re = /([0-9]){5}/g;

	if (re.test(obj.value) == false && obj.value!='')
	{
		alert('The format of the Zip Code you entered appears to be incorrect.  The proper format is: 94111');
		obj.value = '';
		obj.select();
		return false;
	}	
	
	return true;
}

//check when adding a new neighbor comment
function addCommentMemberValidation() {
	if (restrictAccessCheck()) {
		toggleDiv('visitoraddcomment');
		return true;
	} else {
		return false;
	}
	
}


// ============================================================================
// 2008-3-25
// functions for text fields
// -- if the text field has a default value, then call these to show or remove
// -- the default value by just one click
// -- example call to clearDefault is as follows:
//		onfocus="clearDefault(this,'NewAlbum')"
// -- example call to enterDefault is as follows:
//		onblur="enterDefault(this,'NewAlbum')"
//=============================================================================

function clearDefault (obj, defaultValue) {
	if (obj.value == defaultValue) {
		obj.value = '';
	}
}

function enterDefault (obj, defaultValue) {
	if (obj.value == '') {
		obj.value = defaultValue;
	}
}




/* Photo upload page */

function showCreateFolderForm(show) {
	if (show == true) {
		document.getElementById("create_folder_form").style.display="block";
		document.getElementById("create_folder_link").style.display="none";
		document.getElementById("hide_folder_link").style.display="inline";
		document.getElementById("folder_name").focus();
	} else if (show == false) {
		document.getElementById("create_folder_form").style.display="none";
		document.getElementById("create_folder_link").style.display="inline";
		document.getElementById("hide_folder_link").style.display="none";
	}
}

function createNewFolder(form) {
	var folder_name  = form.folder_name.value;
	var open_type    = form.folder_read_open_type.value; 
	var mh_id        = form.folder_mh_id.value; 

	if (!folder_name) {
		alert('Please enter a folder name.');
		return false;
	}
	if (open_type < 0) {
		alert('Please select a folder group.');
		return false;
	}

	$jq.ajax({
		type: "POST",
		url:  "/profile/photos/album_folder_create_proc.php", 
		data: "mh_id=" + mh_id + "&folder_name=" + folder_name + "&read_open_type=" + open_type,
		cache: false,
		async: false,
		success: function(body, status) {
			document.getElementById('upload_folder_list_wrapper').innerHTML = body;
		},
		error: function() {}
	});

	document.getElementById("create_folder_form").style.display="none";
	document.getElementById("create_folder_link").style.display="inline";
	document.getElementById("hide_folder_link").style.display="none";
	return false;
}
