﻿	//-----------------------------------------------------------------------------
	//
	//	이미지 노드의 크기 리사이즈..!
	//
	// @input:
	//		img: 이미지노드
	//		width: 최대 가로사이즈
	//		height: 최대 세로사이즈
	//
	// ex) <img src="이미지경로" onload="resizeImage(this, 40, 20);" />
	//-----------------------------------------------------------------------------
	function resizeImage( img, width, height ){
		img.style.display = "none";

		if( img.width > width ){
			img.height = Math.ceil( img.height * (width / img.width) );
			img.width = width;
		}

		if( img.height > height ){
			img.width = Math.ceil( img.width * (height / img.height) );
			img.height = height;
		}

		img.style.display = "block";

		return img;
	}



	//-----------------------------------------------------------------------------
	//	노드의 페이지 좌표를 얻는다.
	// @return : Object
	//-----------------------------------------------------------------------------
	function getPosition(o){
		var leftPos = 0;
		var topPos = 0;
		
		if(o.offsetParent){
			while(o.offsetParent){
				leftPos += o.offsetLeft;
				topPos += o.offsetTop;
				o = o.offsetParent;
			}
		}else if(o.x){
			leftPos += o.x;
			topPos += o.y;
		}
		
		return {x:leftPos, y:topPos};
	}






	//-----------------------------------------------------------------------------
	// 동영상 Embed 태그 값 반환..
	// @return : String
	// ex) getMovieEmbedTags(플래시경로, 넓이, 높이);
	//-----------------------------------------------------------------------------
	function getMovieEmbedTags(movieSrc, width, height){
		var sMovieTags = "<EMBED pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\" ";
		sMovieTags += " width=\"" + width + "\" height=\"" + height + "\" type=\"application/x-mplayer2\" ";
		sMovieTags += " AutoStart=\"true\" Loop=\"-1\" ShowControls=\"true\" ";
		sMovieTags += " ShowStatusBar=\"true\" ShowPositionControls=\"false\" ";
		sMovieTags += " src=\"" + movieSrc + "\" ></EMBED>";

		return sMovieTags;
	}


	//-----------------------------------------------------------------------------
	// 플래시 태그 값 반환..
	// @return : String
	// ex) getFlashObjectTags(플래시경로, 넓이, 높이, 전달변수, 플래시이름);
	//-----------------------------------------------------------------------------
	function getFlashEmbedTags(flashSrc, objWidth, objHeight, etcParam, flaName){
		var sMovieTags = "<EMBED width=\"" + objWidth + "\" height=\"" + objHeight + "\" type=\"application/x-shockwave-flash\" src=\"" + (flashSrc + "?" + etcParam) + "\" ></EMBED>";

		return sMovieTags;
	}



	//-----------------------------------------------------------------------------
	//	id에 해당하는 노드의 참조를 얻는다.
	// @return : Object
	//-----------------------------------------------------------------------------
	function $(id){
		return document.getElementById(id);
	}




	//-----------------------------------------------------------------------------
	// IE 스타일과 무관하게 Window Resize..
	// @return : null
	// ex) fixedResizeWindow(800, 600);
	//-----------------------------------------------------------------------------
	function fixedResizeWindow(iWidth, iHeight){
		var currentWidth, currentHeight;
		var windowWidth, windowHeight;
		var borderWidth, boderHeight;

		if(document.all){
			currentWidth = document.body.offsetWidth;
			currentHeight = document.body.offsetHeight;

			window.resizeTo(iWidth, iHeight);

			windowWidth = iWidth - document.body.offsetWidth + currentWidth;
			windowHeight = iHeight - document.body.offsetHeight + currentHeight;

			window.resizeTo(windowWidth, windowHeight);
		} else{
			windowWidth = window.outerWidth;
			windowHeight = window.outerHeight;
		}

		borderWidth = windowWidth - document.body.clientWidth;
		borderHeight = windowHeight - document.body.clientHeight;

		window.resizeTo(iWidth + borderWidth, iHeight + borderHeight);
	}




	//-----------------------------------------------------------------------------
	// 화면의 중앙으로 팝업창 띄우기..
	// @return : null
	// ex) PopUp(경로, 팝업창이름, 넓이, 높이);
	//-----------------------------------------------------------------------------
	function PopUp(url, wName, width, height) {//화면의 중앙
		var LeftPosition = (screen.width/2) - (width/2);
		var TopPosition = (screen.height/2) - (height/2);
		var win = window.open(url, wName, "left="+LeftPosition+",top="+TopPosition+",width="+width+",height="+height);

		if(win == null){
			alert("팝업차단을 해제해주세요!");
		} else{
			win.focus();
		}
	}


	//-----------------------------------------------------------------------------
	// 화면의 중앙으로 팝업창 띄우기..(스크롤포함)
	// @return : null
	// ex) PopUp(경로, 팝업창이름, 넓이, 높이);
	//-----------------------------------------------------------------------------
	function PopUpWithScroll(url, wName, width, height) {//화면의 중앙
		var LeftPosition = (screen.width/2) - (width/2);
		var TopPosition = (screen.height/2) - (height/2);
		var win = window.open(url, wName, "left="+LeftPosition+",top="+TopPosition+",width="+width+",height="+height+",scrollbars=yes");

		if(win == null){
			alert("팝업차단을 해제해주세요!");
		} else{
			win.focus();
		}
	}


	//-----------------------------------------------------------------------------
	// 쿠키저장
	// @return : null
	// ex) SetCookie(쿠키이름, 쿠키값, 만료기간);
	//-----------------------------------------------------------------------------
	function SetCookie(name, value, expiredays){//쿠키 설정
		var todayDate = new Date(); 

		todayDate.setDate( todayDate.getDate() + expiredays ); 
		document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
	} 



	//-----------------------------------------------------------------------------
	// 쿠키추출
	// @return : null
	// ex) GetCookie(쿠키이름);
	//-----------------------------------------------------------------------------
	function GetCookie(name){
		var arg = name + "=";
		var alen = arg.length; 
		var clen = document.cookie.length;
		var i = 0;

		while (i < clen) {
			var j = i + alen; 

			if(document.cookie.substring(i, j) == arg){
				var endstr = document.cookie.indexOf (";", j);
				if(endstr == -1) 
					endstr = document.cookie.length; 

				return unescape(document.cookie.substring(j, endstr));
			}

			i = document.cookie.indexOf(" ", i) + 1;
			if (i == 0) break;
		}

		return null;
	} 



	//-----------------------------------------------------------------------------
	// 쿠키삭제
	// @return : null
	// ex) DeleteCookie(쿠키이름);
	//-----------------------------------------------------------------------------
	function DeleteCookie(name){
		var exp = new Date(); 
		var cval = GetCookie(name);

		exp.setTime(exp.getTime() - 1); 
		document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); 
	}






	function URIEncode(href){
		// IE에서 UTF-8로 된 주소를 찾아가지 못하는 버그가 있어서
		if (encodeURI != null)
			return encodeURI(href)
		else
			return escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';');
	}




	//-----------------------------------------------------------------------------
	// 클립보드에 복사..
	// @return : boolean
	// ex) textToClip(이미지파일경로);
	//-----------------------------------------------------------------------------
	function textToClip(strClipData){
		if (window.clipboardData){
			window.clipboardData.setData("Text", strClipData);

		} else if (window.netscape){
			try{
				netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
				
				var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
				if(!clip)	return false;
			
				var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
				if(!trans)	return false;
			
				trans.addDataFlavor('text/unicode');

				var str = new Object();
				var len = new Object();
				var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);

				var copytext = strClipData;

				str.data=copytext;
				trans.setTransferData("text/unicode",str,copytext.length*2);
				
				var clipid=Components.interfaces.nsIClipboard;

				if(!clipid)	return false;

				clip.setData(trans,null,clipid.kGlobalClipboard);

			} catch(e){
				alert('파이어폭스 보안 설정으로 클립보드로 복사할 수 없습니다.\n\n주소 창에 about:config 라고 입력해 설정 페이지로 이동한 후 Signed.applets.codebase_principal_support 항목을 true로 변경하시면, 클립보드를 정상적으로 이용하실 수 있습니다.');
				return false;
			}
		}

		return true;
	}




	//-----------------------------------------------------------------------------
	// 이미지 사이즈에 맞게 크기조절된 팝업창띄우기
	// @return : null
	// ex) showPicture(이미지파일경로);
	//-----------------------------------------------------------------------------
	function showPicture(src) {
		var oImage = new Image();
		oImage.src = src;

		var strWindowOption = "";
		strWindowOption += "scrollbars=no,status=no,resizable=no";
		strWindowOption += ",width=" + oImage.width;
		strWindowOption += ",height=" + oImage.height;

		var wbody = "";
		wbody += "<head><title>사진 보기</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 += "  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","",strWindowOption);
		winResult.document.open("text/html", "replace");
		winResult.document.write(wbody);
		winResult.document.close();
		return;
	}





	//-----------------------------------------------------------------------------
	// 플래시 점선없이 띄우기..
	// @return : null
	// ex) getFlashObject(플래시경로, 넓이, 높이, 전달변수, 플래시이름);
	//-----------------------------------------------------------------------------
	function getFlashObject(flashSrc, objWidth, objHeight, etcParam, flaName) {
		var tag = "";
		var baseFlashDir="";
		flashSrc = baseFlashDir + flashSrc;

		if ( etcParam != "" || etcParam != null ) {
			if ( etcParam.substr(0, 1) == "?" )
				flashSrc += etcParam;
			else
				flashSrc += "?" + etcParam;
		}

		tag += "<object id=\"" + flaName + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";
		tag += "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" ";
		tag += "width=\"" + objWidth + "\" height=\"" + objHeight + "\">";
		tag += "<param name=\"movie\" value=\"" + flashSrc + "\">";
		tag += "<param name=\"menu\" value=\"true\">";
		tag += "<param name=\"quality\" value=\"high\">";
		tag += "<param name=\"wmode\" value=\"transparent\">";
		tag += "<embed name=\"" + flaName +"\" src=\"" + flashSrc + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" ";
		tag += "type=\"application/x-shockwave-flash\" width=\"" + objWidth + "\" height=\"" + objHeight + "\" ";
		tag += "wmode=\"transparent\"></embed>";
		tag += "</object>";

		document.write(tag);
	}


	function getFlashObject2(flashSrc, objWidth, objHeight, etcParam, flaName) {
		var tag = "";
		var baseFlashDir="";
		flashSrc = baseFlashDir + flashSrc;

		if ( etcParam != "" || etcParam != null ) {
			if ( etcParam.substr(0, 1) == "?" )
				flashSrc += etcParam;
			else
				flashSrc += "?" + etcParam;
		}

		tag += "<object id=\"" + flaName + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";
		tag += "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" ";
		tag += "width=\"" + objWidth + "\" height=\"" + objHeight + "\">";
		tag += "<param name=\"movie\" value=\"" + flashSrc + "\">";
		tag += "<param name=\"menu\" value=\"true\">";
		tag += "<param name=\"quality\" value=\"high\">";
		//tag += "<param name=\"align\" value=\"middle\">";
		tag += "<param name=\"salign\" value=\"\">";
		tag += "<param name=\"play\" value=\"true\">";
		//tag += "<param name=\"loop\" value=\"true\">";
		tag += "<param name=\"allowFullScreen\" value=\"true\">";
		//tag += "<param name=\"allowScriptAccess\" value=\"always\">";
		tag += "<param name=\"devicefont\" value=\"false\">";
		//tag += "<param name=\"scale\" value=\"showall\">";
		tag += "<param name=\"wmode\" value=\"transparent\">";
		tag += "<param name=\"bgcolor\" value=\"#FFFFFF\">";
		tag += "<embed name=\"" + flaName + "\" src=\"" + flashSrc + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" ";
		tag += "type=\"application/x-shockwave-flash\" width=\"" + objWidth + "\" height=\"" + objHeight + "\" ";
		tag += "wmode=\"transparent\"></embed>";
		tag += "</object>";


		document.write(tag);
	}




	//-----------------------------------------------------------------------------
	// 플래시 태그 값 반환..
	// @return : String
	// ex) getFlashObjectTags(플래시경로, 넓이, 높이, 전달변수, 플래시이름);
	//-----------------------------------------------------------------------------
	function getFlashObjectTags(flashSrc, objWidth, objHeight, etcParam, flaName) {
		var tag = "";
		var baseFlashDir="";
		flashSrc = baseFlashDir + flashSrc;

		if ( etcParam != "" || etcParam != null ) {
			if ( etcParam.substr(0, 1) == "?" )
				flashSrc += etcParam;
			else
				flashSrc += "?" + etcParam;
		}

		tag += "<object id=\"" + flaName + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";
		tag += "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" ";
		tag += "width=\"" + objWidth + "\" height=\"" + objHeight + "\">";
		tag += "<param name=\"movie\" value=\"" + flashSrc + "\">";
		tag += "<param name=\"menu\" value=\"true\">";
		tag += "<param name=\"quality\" value=\"high\">";
		tag += "<param name=\"wmode\" value=\"transparent\">";
		tag += "<embed name=\"" + flaName + "\" src=\"" + flashSrc + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" ";
		tag += "type=\"application/x-shockwave-flash\" width=\"" + objWidth + "\" height=\"" + objHeight + "\" ";
		tag += "wmode=\"transparent\"></embed>";
		tag += "</object>";


		return tag;
	}






	//-----------------------------------------------------------------------------
	// 동영상 
	// @return : null
	// ex) getMovieObject(동영상경로, 넓이, 높이, 동영상ID);
	//-----------------------------------------------------------------------------
	function getMovieObject(sPath, iWidth, iHeight, sMovieID){
		document.writeln( getMovieObjectTags(sPath, iWidth, iHeight, sMovieID) );
	}




	//-----------------------------------------------------------------------------
	// 동영상 태그 반환
	// @return : null
	// ex) getMovieObjectTags(동영상경로, 넓이, 높이, 동영상ID);
	//-----------------------------------------------------------------------------
	function getMovieObjectTags(sPath, iWidth, iHeight, sMovieID){
		var strMovieID = (sMovieID) ? sMovieID : Math.random();
		var strMovie = "";
		
		strMovie += "<object classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" id=\"" + strMovieID + "\" width=\"" + iWidth + "\" height=\"" + iHeight + "\" style=\"margin:0px; padding:0px;\">\n";
		strMovie += "	<param name=\"AutoStart\" value=\"true\">\n";
		strMovie += "	<param name=\"Loop\" value=\"-1\">\n";
		strMovie += "	<param name=\"ShowControls\" value=\"true\">\n";
		strMovie += "	<param name=\"ShowStatusBar\" value=\"true\">\n";
		strMovie += "	<param name=\"ShowPositionControls\" value=\"false\">\n";
		strMovie += "	<param name=\"Filename\" value=\"" + sPath + "\">\n";
		strMovie += "</object>\n";

		return strMovie;
	}





	//-----------------------------------------------------------------------------
	// 모든 툴바를 제거한 동영상 태그 반환
	// @return : null
	// ex) getMovieObjectTagsWithoutToolbars(동영상경로, 넓이, 높이, 동영상ID);
	//-----------------------------------------------------------------------------
	function getMovieObjectTagsWithoutToolbars(sPath, iWidth, iHeight, sMovieID){
		var strMovieID = (sMovieID) ? sMovieID : Math.random();
		var strMovie = "";

		strMovie += "<object classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" id=\"" + strMovieID + "\" width=\"" + iWidth + "\" height=\"" + iHeight + "\" style=\"margin:0px; padding:0px;\">";
		strMovie += "	<param name=\"AutoSize\" value=\"true\">";
		strMovie += "	<param name=\"AutoStart\" value=\"true\">";
		strMovie += "	<param name=\"AutoRewind\" value=\"true\">";
		strMovie += "	<param name=\"Balance\" value=\"0\">";
		strMovie += "	<param name=\"CurrentPosition\" value=\"0\">";
		strMovie += "	<param name=\"DisplayBackColor\" value=\"#FFFFFF\">";
		strMovie += "	<param name=\"DisplayForeColor\" value=\"16777215\">";
		strMovie += "	<param name=\"DisplayMode\" value=\"0\">";
		strMovie += "	<param name=\"DisplaySize\" value=\"0\">";
		strMovie += "	<param name=\"PlayCount\" value=\"99\">";
		strMovie += "	<param name=\"ShowControls\" value=\"false\">";
		strMovie += "	<param name=\"ShowAudioControls\" value=\"false\">";
		strMovie += "	<param name=\"ShowPositionControls\" value=\"true\">";4
		strMovie += "	<param name=\"ShowStatusBar\" value=\"false\">";
		strMovie += "	<param name=\"ShowTracker\" value=\"false\">";
		strMovie += "	<param name=\"TransparentAtStart\" value=\"1\">";
		strMovie += "	<param name=\"windowlessVideo\" value=\"1\">";		
		strMovie += "	<param name=\"Volume\" value=\"-600\">";
		strMovie += "	<param name=\"Filename\" value=\"" + sPath + "\">";
		strMovie += "</object>";

		return strMovie;
	}


	//-----------------------------------------------------------------------------
	// 해당 객체의 투명도를 설정한다.
	// @return : null
	// ex) setOpacity(40);
	//-----------------------------------------------------------------------------
	function setOpacity(obj, value){
		if( typeof obj == "string")
			obj = $(obj);

		obj.style.opacity = (value / 100);
		obj.style.MozOpacity = (value / 100);
		obj.style.KhtmlOpacity = (value / 100);
		obj.style.filter = "alpha(opacity=" + value + ")";
	}



	//-----------------------------------------------------------------------------
	// 해당 객체에 드래그 이벤트를 설정한다.
	// @return : null
	// ex) attachDragEvent(document.getElementById("divLayer"));
	//-----------------------------------------------------------------------------
	function attachDragEvent(oElement){
		oElement.style.position = "absolute";

		oElement.onmousedown = function(){
			oElement.style.cursor = "move";

			this.oldPosX = window.event.x;
			this.oldPosY = window.event.y;
						
			this.onmousemove = function(){
				this.newPosX = this.offsetLeft + (window.event.x - this.oldPosX);
				this.newPosY = this.offsetTop + (window.event.y - this.oldPosY);

				this.style.left = this.newPosX;
				this.style.top = this.newPosY;
							
				this.oldPosX = window.event.x;
				this.oldPosY = window.event.y;
			}
		}
					
		oElement.onmouseup = oElement.onmouseleave = oElement.onmouseout = function(){
			this.onmousemove = "";
			this.style.cursor = "default";
		}
	}



/*
	F11, F5, 소스보기 막기.

	document.onkeydown = function(){
		if(window.Event)	// 넷스케이프에서는 대문자 Event
			document.captureEvents(Event.MOUSEUP);

		if(event.ctrlKey == true && (event.keyCode == 78 || event.keyCode == 82) || (event.keyCode >= 112 && event.keyCode <= 123) || event.keyCode == 8){
			event.keyCode = 0;
			event.cancelBubble = true;
			event.returnValue = false;
		}
	}

	// IE 전용
	document.oncontextmenu = function(){
		event.cancelBubble = true;
		event.returnValue = false;
		return false;
	}

	document.onmousedown = function(){
		if(window.Event){
			if(e.which == 2 || e.which == 3)
				return false;
		} else{
			if(event.button == 2 || event.button == 3){
				event.cancelBubble = true;
				event.returnValue = false;
				return false;
			}
		}
	}
	document.onselectstart = new Function("return false");
	document.ondragstart = new Function("return false");
*/



/*****************************************************************************************
		※ String 객체 확장..
*****************************************************************************************/

	//-----------------------------------------------------------------------------
	// 문자의 좌, 우 공백 제거
	// @return : String
	// ex) 문자열.trim();
	//-----------------------------------------------------------------------------
	String.prototype.trim = function() {
		return this.replace(/(^\s*)|(\s*$)/g, "");
	};


	String.prototype.Trim = function() {
		return this.replace(/(^\s*)|(\s*$)/g, "");
	};


	//-----------------------------------------------------------------------------
	// 문자의 좌 공백 제거
	// @return : String
	// ex) 문자열.ltrim();
	//-----------------------------------------------------------------------------
	String.prototype.ltrim = function() {
		return this.replace(/(^\s*)/, "");
	};



	//-----------------------------------------------------------------------------
	// 문자의 우 공백 제거
	// @return : String
	// ex) 문자열.rtrim();
	//-----------------------------------------------------------------------------
	String.prototype.rtrim = function() {
		return this.replace(/(\s*$)/, "");    
	};


	//-----------------------------------------------------------------------------
	// 문자열의 바이트수 리턴
	// @return : int
	// ex) 문자열.bytes();
	//-----------------------------------------------------------------------------
	String.prototype.bytes = function() {
		var cnt = 0;

		for (var i = 0; i < this.length; i++) {
			if (this.charCodeAt(i) > 127)
				cnt += 2;
			else
				cnt++;
		}

		return cnt;
	};




	//-----------------------------------------------------------------------------
	// 정수형으로 변환
	// @return : int
	// ex) 문자열.int();
	//-----------------------------------------------------------------------------
	String.prototype.int = function() {
		if(!isNaN(this)) {
			return parseInt(this, 10);
		}
		else {
			return null;    
		}
	};



	//-----------------------------------------------------------------------------
	// 숫자에 3자리마다 , 를 찍어서 반환
	// @return : 변환된 String ( ex) 12,345,678 )
	// ex) 문자열.money();
	//-----------------------------------------------------------------------------
	String.prototype.money = function() {
		var num = this.trim();

		while((/(-?[0-9]+)([0-9]{3})/).test(num)) {
			num = num.replace((/(-?[0-9]+)([0-9]{3})/), "$1,$2");
		}

		return num;
	};




	//-----------------------------------------------------------------------------
	// 숫자의 자리수(cnt)에 맞도록 반환
	// @return : 변환된 String			ex) 33.digits(4) => "0033";
	// ex) 숫자.digits(자리수);
	//-----------------------------------------------------------------------------
	Number.prototype.digits = function(cnt) {
		var sThis = this.toString();
		var digit = "";

		if (sThis.length < cnt) {
			for(var i = 0; i < cnt - sThis.length; i++) {
				digit += "0";
			}
		}

		return digit + sThis;
	};



	Number.prototype.money = function(){
		return this.toString().money();
	};



	//-----------------------------------------------------------------------------
	// 문자열에 포함된 숫자만 가져 오기
	// @return : String					ex) "-123$asdf456".num() => "123456";
	// ex) 문자열.num();
	//-----------------------------------------------------------------------------
	String.prototype.num = function() {
		return (this.trim().replace(/[^0-9]/g, ""));
	};



	//-----------------------------------------------------------------------------
	// 문자열을 원하는 바이트만큼 자르기..
	// @return : String					ex) "abcdefghijklmn".cut(5) => "abcde";
	// ex) 문자열.cut(바이트);
	//-----------------------------------------------------------------------------
	String.prototype.cut = function(iCount) {
		var strReturn = this;
		var intLength = 0;

		for (var i=0; i<strReturn.length; i++) {
			intLength += (strReturn.charCodeAt(i) > 128) ? 2 : 1;

			if (intLength > iCount)
				return strReturn.substring(0,i) + "..";
		}

		return strReturn;
	};




	//-----------------------------------------------------------------------------
	// 문자열에 포함된 특정문자를 모두 바꾸기..
	// @return : String					ex) "asdflkj&&&qwerpio".replaceAll("&", "-") => "asdflkj---qwerpio";
	// ex) 문자열.replaceAll(원본문자, 바꿀문자);
	//-----------------------------------------------------------------------------
	String.prototype.replaceAll = function(source, target) {
		source = source.replace(new RegExp("(\\W)", "g"), "\\$1");
		target = target.replace(new RegExp("\\$", "g"), "$$$$");

		return this.replace(new RegExp(source, "gm"), target);
	};



	//-----------------------------------------------------------------------------
	// 문자열에 포함된 특정문자의 갯수 반환
	// @return : int					ex) "abczzzkk".count("z") => 3;
	// ex) 문자열.count(문자);
	//-----------------------------------------------------------------------------
	String.prototype.count = function(str) {
		var matches = this.match(new RegExp(str.replace(new RegExp("(\\W)", "g"), "\\$1"), "g"));

		return matches ? matches.length : 0;
	}



	String.prototype.htmlspecialchars = function()	{ 
		return this.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll("<", "&gt;"); 
	}

	String.prototype.unhtmlspecialchars = function() {
		return this.replaceAll("&amp;", "&").replaceAll("&lt;", "<").replaceAll("&gt;", ">"); 
	}

	String.prototype.stripquote = function() {	
		return this.replaceAll("'", "").replaceAll('"', '').replaceAll("&#39;", "").replaceAll("&#039;", "").replaceAll("&quote;", ""); 
	}


	//------------------------------------------------------------------------------
	//
	// png파일 투명하게 보이게하기위한 함수
	//
	//------------------------------------------------------------------------------

	function setPng24(obj) { 
		obj.width=obj.height=1; 
		obj.className=obj.className.replace(/\bpng24\b/i,''); 
		obj.style.filter = 
		"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
		obj.src='';  
		return ''; 
	} 

