
	/*************************************
	 * 문자열의 길이를 return (한글:2자)
	 *
	 * param : sVal 입력문자열
	 *
	 * return : int 입력문자열의 길이
	 *************************************/
	function strLength(sVal) {
		var sBit = '';	// 문자열의 문자(Char)
		var iLen = 0;	// 문자열 길이

		for ( i = 0 ; i < sVal.length ; i++ ) {
			sBit = sVal.charAt(i);
			if ( escape( sBit ).length > 4 ) {
				iLen = iLen + 2;
			} else {
				iLen = iLen + 1;
			}
		}
		return iLen;
	}

	/**********************************
	 * 입력값이 null인지 체크
	 * param : sVal 입력스트링
	 * return : Boolean True이면 null
	 **********************************/
	function isNull(val) {
		if( typeof(val) == 'undefined' ) {
			return true;
		} else if( val == null ) {
			return true;
		}

		if( typeof(val) != 'string' ) {
			val = String(val);
		}

		if( val.trim() == '' ) {
			return true;
		} else {
			return false;
		}
	}

	/**************************************************
	 * 이미지 싸이즈를 구한다.
	 *
	 * imgSrc	: 이미지 경로
	 * maxSize	: 최대 싸이즈
	 *
	 * return : img엘리먼트 가로 세로를 구할수 있게.
	 **************************************************/
	function imageResizeFun(imgSrc, maxSize) {
		var tempImg = document.createElement('img');
		tempImg.src = imgSrc;
		var tempWidth	= tempImg.width;
		var tempHeight	= tempImg.height;

		var width = 0, height = 0;
		if( tempWidth > maxSize || tempHeight > maxSize ) {

			var perCnt = 0;
			if( tempHeight > tempWidth ) {
				/*****************
				 * 세로가 더 큰경우
				 *****************/
				perCnt = (maxSize / tempHeight);
			} else {
				/*****************
				 * 가로가 더 큰경우
				 *****************/
				perCnt = (maxSize / tempWidth);
			}

			tempImg.width	= tempImg.width * perCnt;
			tempImg.height	= tempImg.height * perCnt;
		}
		return tempImg;
	}

	/**
	 * 가로 싸이즈를 구해 675가 넘으면 줄인다.
	 * @param imgSrc
	 * @param maxSize
	 * @return
	 */
	function contentImageResizeFun(imgSrc) {
		var maxSize = 675;

		var tempImg		= document.createElement('img');
		tempImg.src		= imgSrc;
		var tempWidth	= tempImg.width;

		if( tempWidth > maxSize ) {
			var perCnt = (maxSize / tempWidth);

			tempImg.width	= tempImg.width * perCnt;
			tempImg.height	= tempImg.height * perCnt;
		}
		return tempImg;
	}

	/**
	 * 숫자 체크
	 * @param checkStr
	 * @return
	 */
	function isNumber(checkStr) {
		var checkOK = '0123456789';
		for (i = 0;  i < checkStr.length;  i++) {
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++) {
				if (ch == checkOK.charAt(j)) {
					break;
				}
			}
			if (j == checkOK.length) {
				return (false);
				break;
			}
		}
		if(checkStr == null || checkStr.length == 0) {
			return (false);
		}
		return (true);
	}

	/**
	 * 공통 엔터 체크 이벤트
	 * @param event
	 * @param funName
	 * @return
	 */
	function commonEnterFun(event, funName) {
		if( $J.browser.msie ) {
			if( event.keyCode == '13' ) {
				eval(funName);
			}
		} else {
			if( event.keyCode == '13' ) {
				eval(funName);
			}
		}
	}


	/****************************
	 * 현재 날짜와 시간을 가져오는 함수
	 * type
	 * 	YYYY
	 * 	YYYYMM
	 * 	YYYYMMDD
	 * 	YYYYMMDDHH
	 * 	YYYYMMDDHHMI
	 * 	YYYYMMDDHHMISS
	 * 	LOGDATE
	 ****************************/
	function getDate(type, section) {
		var nowDate		= new Date();
		var nowYear		= nowDate.getFullYear();
		var nowMonth	= Number(nowDate.getMonth()) +1;
		var nowDay		= Number(nowDate.getDate());
		var nowHour		= Number(nowDate.getHours());
		var nowMin		= Number(nowDate.getMinutes());
		var nowSec		= Number(nowDate.getSeconds());

		if( Number(nowMonth) < 10 ) {
			nowMonth = '0'+nowMonth;
		}
		if( Number(nowDay) < 10 ) {
			nowDay = '0'+nowDay;
		}
		if( Number(nowHour) < 10 ) {
			nowHour = '0'+nowHour;
		}
		if( Number(nowMin) < 10 ) {
			nowMin = '0'+nowMin;
		}
		if( Number(nowSec) < 10 ) {
			nowSec = '0'+nowSec;
		}

		if( (typeof(section) == 'undefined') || isNull(section) ) {
			section = '';
		}

		var now = '';

		type = type.toUpperCase();
		if( type == 'YYYY' ) {
			now = nowYear;
		} else if( type == 'YYYYMM' ) {
			now = nowYear+section+nowMonth;
		} else if( type == 'YYYYMMDD' ) {
			now = nowYear+section+nowMonth+section+nowDay;
		} else if( type == 'YYYYMMDDHH' ) {
			now = nowYear+section+nowMonth+section+nowDay+section+nowHour;
		} else if( type == 'YYYYMMDDHHMI' ) {
			now = nowYear+section+nowMonth+section+nowDay+section+nowHour+':'+nowMin;
		} else if( type == 'YYYYMMDDHHMISS' ) {
			now = nowYear+section+nowMonth+section+nowDay+' '+nowHour+':'+nowMin+':'+nowSec;
		} else if( type == 'LOGDATE' ) {
			now = nowYear+''+nowMonth+nowDay+' '+nowHour+':'+nowMin+':'+nowSec;
		} else {
			now = nowYear+section+nowMonth+section+nowDay;
		}

		return now;
	}

	/*****************************
	 * 플래시 보여준다.
	 *****************************/
	function showFlashFun(flashURL) {

		var layerWidth = 500;
		var layerHeight = 350;

		var flashDIV = document.createElement("div");
		flashDIV.setAttribute("id",		"flashPlayerLayer");
		flashDIV.setAttribute("title",	"flashPlayerLayer");
		flashDIV.style.width	= layerWidth;
		flashDIV.style.height	= layerHeight;
		document.body.appendChild(flashDIV);

		var flashURLLarger = flashURL.toUpperCase();

		var writeHTML = '';

		flashURL.lastIndexOf()

		if( flashURLLarger.lastIndexOf(".JPG") >= 0 || flashURLLarger.lastIndexOf(".GIF") >= 0
				 || flashURLLarger.lastIndexOf(".JPEG") >= 0 || flashURLLarger.lastIndexOf(".PNG") >= 0 ) {
			writeHTML += '<img src="'+flashURL+'" width="'+layerWidth+'" height="'+layerHeight+'" />';
		} else if( flashURL.indexOf("www.youtube.com") >= 0 ) {
			layerWidth	= 450;
			layerHeight	= 400;

			flashDIV.style.width	= layerWidth;
			flashDIV.style.height	= layerHeight;
			writeHTML = youtubeScript(flashURL);
		} else if( flashURL.indexOf("tvpot.daum.net") >= 0 ) {
			layerWidth	= 530;
			layerHeight	= 450;

			flashDIV.style.width	= layerWidth;
			flashDIV.style.height	= layerHeight;

			writeHTML = tvpotScript(flashURL);
		} else if( flashURLLarger.lastIndexOf(".FLV") >= 0 || flashURLLarger.lastIndexOf(".MP3") >= 0 ) {
			$J("#flashPlayerLayer").dialog({
				width : layerWidth
				, height : layerHeight
				, modal : true
				, close : function(event, ui) {
					$J("#flashPlayerLayer").remove();
				}
			});
			$J('#flashPlayerLayer').html(writeHTML);

			$f("flashPlayerLayer", {src: "/flash/flowplayer-3.1.5.swf"}, {
				plugins: {
					audio: {
						url: '/flash/flowplayer.audio-3.1.2.swf'
					}
					, controls: {
						url: '/flash/flowplayer.controls-3.1.5.swf'
					}
				}
				, clip: {
					url: flashURL
					, autoPlay: true
					, onStart: function(clip) {
//						alert("Clip "+ clip.url);
					}
				}
				, play: {
					label: null
					, replayLabel: "다시?~~~ㅋㅋ"
				}
			});
			return ;
		} else if( flashURL.substr(0, 1) == '<' || flashURL.substr(0, 1) == '<' ) {
			$J("#flashPlayerLayer").remove();
			return ;
		} else {
			writeHTML += "<object type='application/x-shockwave-flash' width='470px' height='290px' align='middle' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'>";
			writeHTML += "	<param name='movie' value='"+flashURL+"' />";
			writeHTML += "	<param name='allowScriptAccess' value='always' />";
			writeHTML += "	<param name='allowFullScreen' value='true' />";
			writeHTML += "	<param name='bgcolor' value='#000000' />";
			writeHTML += "	<embed src='"+flashURL+"' width='470px' height='290px' allowScriptAccess='always' type='application/x-shockwave-flash' allowFullScreen='true' bgcolor='#000000' ></embed>";
			writeHTML += "</object>";
		}

		$J("#flashPlayerLayer").dialog({
			width : layerWidth
			, height : layerHeight
			, modal : true
			, close : function(event, ui) {
				$J("#flashPlayerLayer").remove();
			}
		});
		$J('#flashPlayerLayer').html(writeHTML);
	}

	function youtubeScript(movieUrl) {
		var qmark = movieUrl.indexOf("?");
		if (qmark < 0) return;
		movieUrl = movieUrl.substring(qmark+1);
		var params = movieUrl.split("&");
		var youtubecode = "";
		for (i = 0; i < params.length; i++) {
			if (/^v=/.test(params[i])) {
				youtubecode = params[i].substring(2);
			}
		}
		if (youtubecode == "") return;

		var returnHTML = "";
		returnHTML += "<object width='425' height='344'>";
		returnHTML += "	<param name='movie' value='http://www.youtube.com/v/"+youtubecode+"&hl=en&fs=1&'></param>";
		returnHTML += "	<param name='allowFullScreen' value='true'></param>";
		returnHTML += "	<param name='allowscriptaccess' value='always'></param>";
		returnHTML += "	<embed src='http://www.youtube.com/v/"+youtubecode+"&hl=en&fs=1&' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='425' height='344'></embed>";
		returnHTML += "</object>";

		return returnHTML;
	}

	function tvpotScript(movieUrl) {
		var qmark = movieUrl.indexOf("?");
		if (qmark < 0) return;
		movieUrl = movieUrl.substring(qmark+1);
		var returnHTML = "";
		returnHTML += "<object type='application/x-shockwave-flash' width='500px' height='400px' align='middle' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'>";
		returnHTML += "	<param name='movie' value='http://flvs.daum.net/flvPlayer.swf?"+movieUrl+"' />";
		returnHTML += "	<param name='allowScriptAccess' value='always' />";
		returnHTML += "	<param name='allowFullScreen' value='true' />";
		returnHTML += "	<param name='bgcolor' value='#000000' />";
		returnHTML += "	<embed src='http://flvs.daum.net/flvPlayer.swf?"+movieUrl+"' width='502px' height='399px' allowScriptAccess='always' type='application/x-shockwave-flash' allowFullScreen='true' bgcolor='#000000' ></embed>";
		returnHTML += "</object>";

		return returnHTML;
	}


	/*********************
	 * 댓글에 첨부된 이미지 보여준다.
	 *********************/
	function replyImgViewFun(fileNo) {
		if( isNull(fileNo) || Number(fileNo) < 1 ) {
			return ;
		}
		$J('#replyImgView_'+fileNo).toggle('blind', '', 500
			, function() {
				if( $J('#replyImgView_'+fileNo).is(":hidden") ) {
					if( isNull($J('#replyImgView_'+fileNo).html()) ) {
						$J.post(
							contextPath+'/common/photoExif.do'
							, 'fileNo='+fileNo
							, photoExifAfterFun
							, 'json'
						);
					}
				}
			}
		);
	}

	function photoExifAfterFun(data, textStatus) {
		if( textStatus != 'success' ) {
			alert('사진 정보 가져오기를 실패 했습니다.');
			return ;
		}

		var FILE_NO			= data.FILE_NO;
		var FILE_EXT		= data.FILE_EXT;
		FILE_EXT = FILE_EXT.toUpperCase();
		var MAKE			= data.MAKE;
		var MODEL			= data.MODEL;
		var PICTURE_DATE	= data.PICTURE_DATE;
		var USER_COMMENT	= data.USER_COMMENT;
		var SHUTTER_SPEED	= data.SHUTTER_SPEED;
		var ISO_SPEED		= data.ISO_SPEED;
		var APERTURE		= data.APERTURE;
		var VIRTUAL_PATH	= data.VIRTUAL_PATH;
		var FLICKR_URL		= data.FLICKR_URL;
		var imgPath			= VIRTUAL_PATH;

		if( "GIF" != FILE_EXT && isNull(FLICKR_URL) == false ) {
			imgPath = FLICKR_URL;
		}
		if( isNull(imgPath) ) {
			return ;
		}

		$J('#replyImgView_'+FILE_NO).html('<img src="'+commonImgPath+'/common/bigWaiting.gif" alt="pplsmell" title="pplsmell" />');

		var loader = new ImageLoader(imgPath);
		loader.loadEvent = function(url, image) {
			var viewHtml = '';
			viewHtml += '<img src="'+imgPath+'" id="viewImg_'+FILE_NO+'" alt="pplsmell" title="pplsmell" longdesc="'+imgPath+'" />';
			viewHtml += '<p>';
			viewHtml += '촬영일자 : '+PICTURE_DATE;
			viewHtml += '</p>';

			$J('#replyImgView_'+FILE_NO).html(viewHtml);
			$J("img").fullsize();

			var imgEle = imageResizeFun(imgPath, 390);
			$J('#replyImgView_'+FILE_NO).width(imgEle.width);
			$J('#viewImg_'+FILE_NO).width(imgEle.width);
			$J('#viewImg_'+FILE_NO).height(imgEle.height);
		};
		loader.load();
	}

	/**
	 *  게시글 추천 업데이트
	 * @param detailNo
	 * @return
	 */
	function boardGoodCountUpdateFun(detailNo) {
		 var queryString = 'detailNo='+detailNo;
		$J.post(
			contextPath+'/board/goodCountUpdate.do'
			, queryString
			, function(data, textStatus) {
				if( (textStatus != 'success') ) {
					alert('추천을 실패 했습니다.');
					return ;
				}

				if( data.flag == 'success' ) {
					alert('추천 하였습니다.');
				} else if( data.flag == 'dup' ) {
					alert('이미 추천 하셨습니다.');
				} else if( data.flag == 'logout' ) {
					alert('로그인을 해주세요.');
				} else {
					alert('추천을 실패 했습니다.');
				}
			}
			, 'json'
		);
	}

	/**
	 * 홈으로 이동
	 * @param userid
	 * @return
	 */
	function goHomeFun(userid) {
		window.location = '/home/'+userid;
	}

	/**
	 * 닉네임으로 홈이동
	 * @param nickName
	 * @return
	 */
	function nickNameHome(nickName) {
		window.location = '/nickNameHome.do?nickName='+nickName;
	}

