/* 이곳의 함수는 jquery 라이브러리가 필요한 함수 */
// dialog 리스트 목록 (뎁스 수정등에 사용)
var hDialogList = new Array();
jQuery.extend({ 
	/*** 
	<div id='ID+wrap'><div id='ID'><div id='ID+title'></div><div id='i+ID'></div></div></div>
	ie 6에서는 배경으로 iframe 을 생성한다.
	<div id='ID+wrap'><div id='ID'><div id='ID+title'></div><div id='i+ID'></div></div><iframe id='bg+ID'></iframe></div>
	2010-02-20 오후 11:06:44 브라우저의 높이가 팝업레이어보다 작을 경우 제일 상단에 위치하도록 수정함. (top=0)
	2010-07-28 4:23오후 기능추가 overlay
	***/
	h_Dialog : function(r) {
		var op = {
			'id' : '',		// 생성될 div id 값
			'url' : '',	// url 링크시 주소
			'width' : 250,		// 전체 넓이
			'height' : 250,		// 전체 높이
			
			'title' : '',		// 타이틀명
			'titleColor' : '#000000',		// 타이틀 폰트 색상
			'titleBgColor' : '#ffffff',		// 타이틀 배경 색상
			'titleHeight' : 17,	// 타이틀 높이설정
			'titlePadding' : 3,		// 타이틀 패딩값 기본적으로 타이틀과 탑메뉴에 둘다 적용된다.
			
			'bgColor' : '#ffffff',		// 본문 배경색상
			
			'refresh' : false,		// 새로고침 버튼 생성 여부 url 이 있어야 생성됨
			'contentId' : '',		// 이 값이 있을 경우 해당 엘리먼트를 content 에 추가한다.
			'content' : '',		// 출력할 본문 내용 url 이 있으면 무시한다.
			'contentPadding' : 3,		// 본문 기본 패딩값
			'contentStyle' : {'border-top' : '1px dotted #ccc'},
			'closeContent' : 'X',		// close에 들어갈 값
			
			'remove' : true,		// 기존 생성된 id 엘리먼트가 있다면 제거 후 생성
			'border' : '1px solid #A7A7A7', 		// 기본 테두리 스타일
			'el' : '',		// 이벤트 실행 객체의 아이디값 함수에서 실행되어질 때 이벤트 실행객체를 찾을 수가 없다 으, 오브젝트도 넘겨보자
			'elPosition' : 0,		// el 객체를 기준으로 가로 위치 기준 left 값에 + 된다. center 일경우 가운데에 위치 시킨다.
			
			'topMenu' : '',		// 탑메뉴로 들어갈 메뉴 close 옆으로 들어간다. (소스 그대로 적용)
			'bindings' : {},		// 이벤트 바인딩 (이걸 왜 넣었지?)
			'moveHandle' : true,		// 상단 이동 핸들러 적용여부 (드래그적용)
			'autoHeight' : false,		// true 시 안의 내용물에 따라 크기가 세로크기가 조절된다. minHeight 는 30px 로 일단 고정하겠다. max는 height 를 사용한다.
			'wrapper':'body',		// 어느 dom 안에 생성할 것인가
			'dragDisplay':true,		// true 시 드래그시 본문내용 엘리먼트를 숨긴다.
			'dblclickClose':true,		// handle 더블 클릭시 창 닫음
			'overlay':false,		// true 시 회색 배경을 깔고 가운데 띄운다. 배경 클릭 시 닫힘, 드래그 적용 안됨
			'overColor':'#D8D8D8',
			'overOpacity':0.7
		};
		
		var config = $.extend(op, r);

		if (!config.id) return false;
		if (config.remove && $('#'+ config.id +'wrap').length) $('#'+ config.id +'wrap').remove();
				
		// remove 가 false 이고 기존 엘리먼트가 존재한다면 위치값만 조정한다.
		if ($('#'+ config.id +'wrap').length) {
			
			// 클릭 시 레이어가 최상위로 올라오도록 한다.
			$(hDialogList).each(function(){
				if('#'+ config.id != String(this)) $('#'+ String(this) +'wrap').css({'zIndex':495});
				else $('#'+ String(this) +'wrap').css({'zIndex':(500 + hDialogList.length)});
			});
			$('#'+ config.id +'wrap').show();
			if(config.overlay) $('#hOverlay').data('currentBox',config.id).show();
			
			if (config.elPosition == 'center') o_left = (($(window).width()/2)-($('#'+ config.id).width()/2)) +"px";
			o_top = '10px';
	
			if (config.el) {
				if (typeof config.el == 'object') {
					var offset = $(config.el).offset();
					o_top = offset.top + $(config.el).height();
				}else{
					var offset = $('#'+ config.el).offset();
					o_top = offset.top + $('#'+ config.el).height();
				}
				if (config.elPosition != 'center') o_left = (parseInt(offset.left) + parseInt(config.elPosition));
			}else{
				if ((($(document).height()/2) - (parseInt(config.height)/2)) > 0) o_top = ((($(window).height()/2) - (parseInt(config.height)/2)) + $(document).scrollTop()) +"px";
				if (config.elPosition != 'center') o_left = ((($(window).width()/2)-($('#'+ config.id).width()/2)) + parseInt(config.elPosition)) +'px';
			}

			// 브라우저 높이가 팝업레이어보다 작다면 상단은 맨 위에 맞춘다. (드래그핸들러가 위에 있기때문에도)
			if ($(window).height() < $('#'+ config.id).height()) o_top = 0;
			
			$('#'+ config.id +'wrap').css({'left':o_left, 'top':o_top});
			return true;
		}
		
		if(config.overlay && !$('#hOverlay').length){
			config.moveHandle = false;
			$(config.wrapper).append($('<div></div>')
				.attr({'id': 'hOverlay'})
				.css({
					'border':0,
					'top':0,
					'left':0,
					'width':'100%',
					'height':$(document).height(),
					'position':'absolute',
					'zIndex':450,
					'background-color': config.overColor
				}).animate({'opacity':config.overOpacity},1)
				.data('currentBox',config.id)
				.click(function(){
					$('#'+ $(this).data('currentBox') +'wrap').hide();
					$(this).hide();
				})
			);
		}else if(config.overlay) $('#hOverlay').data('currentBox',config.id).show();
		
		if ($.browser.msie && $.browser.version == '6.0'){
			$(config.wrapper).append('<div id="'+ config.id +'wrap"><div id="'+ config.id +'"></div><iframe id="bg'+ config.id +'" frameborder="0" src="about:blank" scrolling="no"></iframe></div>');
		}else{
			$(config.wrapper).append('<div id="'+ config.id +'wrap"><div id="'+ config.id +'"></div></div>');
		}
		$('#'+ config.id +'wrap').hide();		// 모든 내용 생성전엔 숨긴다.
		
		$('#'+ config.id).css({
			'width': config.width +"px", 
			'border': config.border,
			'background-color': config.bgColor,
			'position': 'absolute'
		});
	
		$('#'+ config.id +'wrap').css({
			'border': 0,
			'position': 'absolute',
			'zIndex': (500 + hDialogList.length)
		});
			
		$('#'+ config.id).append("<div id='"+ config.id +"Title'><div></div><div id='"+ config.id +"TopMenu'></div><div style='clear:both;'></div></div>");
		$('#'+ config.id +'Title').css({
			'width': '97%',
			'color': config.titleColor,
			'background-color': config.titleBgColor,
			'text-align': 'left',
			'font-weight': 'bold', 
			'cursor' : 'move',
			'padding' : config.titlePadding +'px',
			'margin' : 0
		}).click(function(){
			// 클릭 시 레이어가 최상위로 올라오도록 한다.
			$this = $(this);
			$(hDialogList).each(function(){
				if($this.attr('id') != (String(this)+'Title')) $('#'+ String(this) +'wrap').css({'zIndex':495});
				else $('#'+ String(this) +'wrap').css({'zIndex':(500 + hDialogList.length)});
			});
		});
	
		$('#'+ config.id +'Title div:first').css({
			'float' : 'left',
			'width' : '83%',
			'margin' : 0
		}).append(config.title);
		
		if (config.dblclickClose){
			if(config.overlay){
				$('#'+ config.id +'Title').dblclick(function() { $('#'+ config.id +'wrap, #hOverlay').hide(); });
			}else{
				$('#'+ config.id +'Title').dblclick(function() { $('#'+ config.id +'wrap').hide(); });
			}
		}
		
		$('#'+ config.id +'TopMenu').css({
			'text-align': 'right',
			'font-weight': 'bold',
			'margin' : 0
		})
		.append(config.topMenu)
		.append("<span id='"+ config.id +"Close'>"+ config.closeContent +"</span>");
		
		// content 높이값
		he = ((parseInt(config.height) - parseInt($('#'+ config.id +'Title div:first').height())) - (4 * parseInt(config.titlePadding))) - 15;
		
		tmp = new Array();
		
		// 스크롤바가 생길시 대비
		w = parseInt(config.width) - 5;
		if (config.url) {
			tmp.push("<iframe id='i"+ config.id +"' src='"+ config.url +"' frameBorder='0'></iframe>");
			$('#'+ config.id).append(tmp.join(""));
			$('#i'+ config.id).css({'width': (w - 1) +'px', 'padding': config.contentPadding}).css(config.contentStyle);
		}else{
			tmp.push("<div id='i"+ config.id +"'>"+ config.content +"</div>");
			$('#'+ config.id).append(tmp.join(""));
			$('#i'+ config.id).css({'width': w, 'padding': config.contentPadding, 'overflow' : 'auto'}).css(config.contentStyle);
		}
		
		if(config.overlay){
			$('#'+ config.id +"Close").click( function() { $('#'+ config.id +'wrap, #hOverlay').hide(); }).css({'cursor': 'pointer'});
		}else{
			$('#'+ config.id +"Close").click( function() { $('#'+ config.id +'wrap').hide(); }).css({'cursor': 'pointer'});
		}
		
		if (config.contentId.length) $('#i'+ config.id).append($('#'+ config.contentId).show());
		
		$.each(config.bindings, function(id, func) {
			$('#'+id).bind('click', function() {
				func;
			});
		});
	
		// show 를 해주어야 제대로 height 값을 추출할 수 있다.	
		$('#'+ config.id +'wrap').show();
	
		// 세로크기 조절
		if (config.autoHeight) {
			if ($('#'+ config.id).height() >= he) $('#i'+ config.id).css({'height': he});
			else if ($('#'+ config.id).height() < 30) $('#i'+ config.id).css({'height': 30});
		}else{
			$('#i'+ config.id).css({'height': he});
		}
		
		if (config.elPosition == 'center') o_left = (($(window).width()/2)-(parseInt(config.width)/2)) +"px";
		o_top = '10px';
		
		// 위치 지정
		if (config.el) {
			if (typeof config.el == 'object') {
				var offset = $(config.el).offset();
				o_top = offset.top + $(config.el).height();
			}else{
				var offset = $('#'+ config.el).offset();
				o_top = offset.top + $('#'+ config.el).height();
			}
			if (config.elPosition != 'center') o_left = (parseInt(offset.left) + parseInt(config.elPosition));
			
		}else{
			if ((($(document).height()/2) - (parseInt(config.height)/2)) > 0) o_top = ((($(window).height()/2) - (parseInt(config.height)/2)) + $(document).scrollTop()) +"px";
			if (config.elPosition != 'center') o_left = ((($(window).width()/2)-($('#'+ config.id).width()/2)) + parseInt(config.elPosition)) +'px';
		}
		
		// 브라우저 높이가 팝업레이어보다 작다면 상단은 맨 위에 맞춘다. (드래그핸들러가 위에 있기때문에도)
		if ($(window).height() < $('#'+ config.id).height()) o_top = 0;
		$('#'+ config.id +'wrap').css({'left':o_left, 'top':o_top});
		
		if (config.moveHandle) {
			$('#'+ config.id +'wrap').draggable({ 
				'cursor': 'pointer', 
				'handle': '#'+ config.id+'Title', 
				'start': function() {
					if (config.dragDisplay) {
						$('#bg'+ config.id).hide();
						$('#i'+ config.id).hide();
					}	
				},
				'stop': function() {
					if (config.dragDisplay) {
						$('#bg'+ config.id).show();
						$('#i'+ config.id).show();
					}
				}
			});
		}
				
		if ($.browser.msie && ($.browser.version == '6.0')) {
			// ie6 셀렉트 박스가 표시되는 점때문에 추가
			bgWidth = ($('#'+ config.id).width() + (parseInt($('#'+ config.id).css('border-width')) * 2));
			bgHeight = ($('#'+ config.id).height() + (parseInt($('#'+ config.id).css('border-width')) * 2));
	
			$('#bg'+ config.id).css({
				'border' : 0,
				'background-color': 'transparent',
				'position': 'absolute',
				'width' : bgWidth,
				'height' : bgHeight,
				'left':0,
				'top':0,
				'margin':0,
				'padding':0,
				'zIndex':-1
			});
		}
		
		hDialogList.push(config.id);
	},
	
	
	h_tips : function(o) {
		
		if ($('#f_tooltip_body').length) return true;
				
		op = {
			'title' : '',		// 제목
			'id' : '',		// 내용에 넣을 객체 id
			'content' : '',		// 내용
			'url' : '',		// 출력 url
			'titleStyle' : {'padding':'3px', 'border':'1px solid #A7A7A7', 'background-color':'#E7E7E7', 'word-break':'break-all', 'font-weight':'bold'}, 
			'contentStyle' : {'padding':'3px', 'word-break':'break-all', 'background-color':'#ffffff', 'border':'1px solid #A7A7A7'},		// 내용 div 기본 스타일
			'frameStyle' : {'width':'100%', 'height':'100%', 'border': 0},		// 프레임 기본 스타일
			'shadowBgColor' : '#919191',		// 그림자 배경색
			'ev' : {}, // 이벤트
			'e' : {},	// 실행 객체
			'wrapper':'body'		// 어느 dom 안에 생성할 것인가
		};
		
		if (!o.title && !o.content && !o.url && !o.id) return false;
		var config = $.extend(op, o);
		
		o_left = eval(parseInt(config.ev.clientX));
		o_top = eval(parseInt(config.ev.clientY));
		
		$('<div></div>').css({'left':o_left, 'top':o_top, 'position':'absolute', 'zIndex':999, 'text-align':'left'})
		.attr({'id':'h_tooltip_body'}).appendTo(config.wrapper);
		
		if (config.title.length) $('<div></div>').css(config.titleStyle).attr({'id':'h_tooltip_title'}).text(config.title).appendTo('#h_tooltip_body');
		if (config.content.length || config.url.length || config.id.length) {
			$('<div></div>').css(config.contentStyle).attr('id','h_tooltip_content').appendTo('#h_tooltip_body');
			if (config.content.length) $('#h_tooltip_content').append(config.content);
			if (config.url.length) $('<iframe></iframe>').css(config.frameStyle).attr({'src':config.url, 'frameBorder':0}).appendTo('#h_tooltip_content');
		}
		// 본문에 넣을 객체가 있다면
		if (config.id.length && $('#h_tooltip_content').length) $('#h_tooltip_content').append($('#'+ config.id).show());
		
		$('<div></div>').attr({'id':'h_tooltip_shadow'})
		.css({'left':(o_left + 2), 'top':(o_top + 2), 'position':'absolute', 'zIndex':'998', 'width':$('#h_tooltip_body').width(), 'height':$('#h_tooltip_body').height(), 'background-color':config.shadowBgColor, 'opacity':'0.4'})
		.appendTo(config.wrapper);
		
		if ($.browser.msie && $.browser.version == '6.0') {
			$('<iframe></iframe>').attr({'id':'h_tooltip_body_bg','frameborder':0, 'src':'about:blank', 'scrolling':'no'})
			.css({'left':o_left, 'top':o_top, 'position':'absolute', 'zIndex':'995', 'width':$('#h_tooltip_body').width(), 'height':$('#h_tooltip_body').height(), 'background-color':'transparent'})
			.appendTo(config.wrapper);
			
			$('<iframe></iframe>').attr({'id':'h_tooltip_shadow_bg','frameborder':0, 'src':'about:blank', 'scrolling':'no'})
			.css({'left':(o_left + 2), 'top':(o_top + 2), 'position':'absolute', 'zIndex':'996', 'width':$('#h_tooltip_body').width(), 'height':$('#h_tooltip_body').height(), 'background-color':'transparent'})
			.appendTo(config.wrapper);
		}
		
		$(config.e).hover( '', function(event) {
			
			if ($('#h_tooltip_body').length) {
				tmp = "";
				if (tmp = event.relatedTarget) tmp = tmp.id;
				
				if (tmp == 'h_tooltip_body' || tmp == 'h_tooltip_title' || tmp == 'h_tooltip_content') {
					$('#h_tooltip_body').hover( '', function() {
						if (config.id.length && $('#h_tooltip_content').length) $(config.wrapper).append($('#'+ config.id).hide());
						$('#h_tooltip_body, #h_tooltip_body_bg').remove();
						if ($('#h_tooltip_shadow').length) $('#h_tooltip_shadow, #h_tooltip_shadow_bg').remove();
					});
					
				}else{
					if (config.id.length && $('#h_tooltip_content').length) $(config.wrapper).append($('#'+ config.id).hide());
					$('#h_tooltip_body, #h_tooltip_body_bg').remove();
					if ($('#h_tooltip_shadow').length) $('#h_tooltip_shadow, #h_tooltip_shadow_bg').remove();
				}
			}
	
		});
			
	}
});


jQuery.fn.highlight = function(pat) {
	if (!pat.length) return false;
	
	function innerHighlight(node, pat) {
		var skip = 0;
		if (node.nodeType == 3) {
			var pos = node.data.toUpperCase().indexOf(pat);
			if (pos >= 0) {
				var spannode = document.createElement('span');
				spannode.className = 'highlight';
				var middlebit = node.splitText(pos);
				var endbit = middlebit.splitText(pat.length);
				var middleclone = middlebit.cloneNode(true);
				spannode.appendChild(middleclone);
				middlebit.parentNode.replaceChild(spannode, middlebit);
				skip = 1;
			}
		}else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
			for (var i = 0; i < node.childNodes.length; ++i) {
				i += innerHighlight(node.childNodes[i], pat);
			}
		}
		return skip;
	}
	
	return this.each(function() {
		innerHighlight(this, pat.toUpperCase());
	});
};
		
jQuery.fn.removeHighlight = function() {
	return this.find("span.highlight").each(function() {
		this.parentNode.firstChild.nodeName;
		with (this.parentNode) {
			replaceChild(this.firstChild, this);
			normalize();
		}
	}).end();
};

/***
jQuery unparam
param => object
***/
jQuery.extend({
	unparam : function(params) {
		var objResult = {};
		$.each(params.split("&"), function(){ var prm = this.split("="); objResult[prm[0]] = prm[1]; });
		return objResult;
	},
	unparamText : function(params) {
		var txtResult = new Array();
		$.each(params.split("&"), function(){ var prm = this.split("="); txtResult.push('"'+ prm[0] +'" : "'+ decodeURIComponent(prm[1]) +'"'); });
		return txtResult.join(",");
	},
	urldecode : function(u) {
		return decodeURIComponent(u).replace(/\+/g, ' ');
	},
	urlencode : function(u) {
		str = (u+'').toString();
		return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
                                                                    replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
	},
	str_replace : function(search, replace, subject, count) {
		f = [].concat(search),
		r = [].concat(replace),
		s = subject,
		ra = r instanceof Array, sa = s instanceof Array;    s = [].concat(s);
		if (count) {
			this.window[count] = 0;
		}
		for (i=0, sl=s.length; i < sl; i++) {
			if (s[i] === '') {
				continue;
			}
			for (j=0, fl=f.length; j < fl; j++) {            
				temp = s[i]+'';
				repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
				s[i] = (temp).split(f[j]).join(repl);
				if (count && s[i] !== temp) {
					this.window[count] += (temp.length-s[i].length)/f[j].length;
				}        
			}
		}
		return sa ? s : s[0];
	},
	time : function () {
		return Math.floor(new Date().getTime()/1000);
	},
	rand : function (min, max) {
		var argc = arguments.length;
		if (argc === 0) {
			min = 0;
			max = 2147483647;    } else if (argc === 1) {
			throw new Error('Warning: rand() expects exactly 2 parameters, 1 given');
		}
		return Math.floor(Math.random() * (max - min + 1)) + min;
	},
	str_cut : function(str, len) {
		var j = 0;
		for (var i = 0; i < str.length; i++) {
			j += (str.charCodeAt(i) > 128) ? 2 : 1;
			if (j > len) return str.substring(0, i) + " ...";
		}
		return str;
	},
	usort : function (inputArr, sorter) {
	    var valArr = [], k = '', i = 0, strictForIn = false, populateArr = [];
	
	    if (typeof sorter === 'string') {
	        sorter = this[sorter];
	    } else if (sorter instanceof Array) {
	        sorter = this[sorter[0]][sorter[1]];
	    }
	
	    // BEGIN REDUNDANT
	    this.php_js = this.php_js || {};
	    this.php_js.ini = this.php_js.ini || {};
	    // END REDUNDANT
	
	    strictForIn = this.php_js.ini['phpjs.strictForIn'] && this.php_js.ini['phpjs.strictForIn'].local_value;
	    populateArr = strictForIn ? inputArr : populateArr;
	    
	
	    for (k in inputArr) { // Get key and value arrays
	        if (inputArr.hasOwnProperty) {
	            valArr.push(inputArr[k]);
	            if (strictForIn) {
	                delete inputArr[k];
	            }
	        }
	    }
	    try {
	        valArr.sort(sorter);
	    } catch (e) {
	        return false;
	    }
	    for (i = 0; i < valArr.length; i++) { // Repopulate the old array
	        populateArr[i] = valArr[i];
	    }
	
	    return strictForIn ? true : populateArr;
	},
	addslashes : function (str) {
		return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\u0000/g, "\\0");
	},
	htmlspecialchars : function (string, quote_style, charset, double_encode) {
	    var optTemp = 0, i = 0, noquotes= false;
	    if (typeof quote_style === 'undefined' || quote_style === null) {
	        quote_style = 2;
	    }
	    string = string.toString();
	    if (double_encode !== false) { // Put this first to avoid double-encoding
	        string = string.replace(/&/g, '&amp;');
	    }
	    string = string.replace(/</g, '&lt;').replace(/>/g, '&gt;');
	
	    var OPTS = {
	        'ENT_NOQUOTES': 0,
	        'ENT_HTML_QUOTE_SINGLE' : 1,
	        'ENT_HTML_QUOTE_DOUBLE' : 2,
	        'ENT_COMPAT': 2,
	        'ENT_QUOTES': 3,
	        'ENT_IGNORE' : 4
	    };
	    if (quote_style === 0) {
	        noquotes = true;
	    }
	    if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags
	        quote_style = [].concat(quote_style);
	        for (i=0; i < quote_style.length; i++) {
	            // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
	            if (OPTS[quote_style[i]] === 0) {
	                noquotes = true;
	            }
	            else if (OPTS[quote_style[i]]) {
	                optTemp = optTemp | OPTS[quote_style[i]];
	            }
	        }
	        quote_style = optTemp;
	    }
	    if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
	        string = string.replace(/'/g, '&#039;');
	    }
	    if (!noquotes) {
	        string = string.replace(/"/g, '&quot;');
	    }
	
	    return string;
	},
	htmlspecialchars_decode : function (string, quote_style) {
	    var optTemp = 0, i = 0, noquotes= false;
	    if (typeof quote_style === 'undefined') {
	        quote_style = 2;
	    }
	    string = string.toString().replace(/&lt;/g, '<').replace(/&gt;/g, '>');
	    var OPTS = {
	        'ENT_NOQUOTES': 0,
	        'ENT_HTML_QUOTE_SINGLE' : 1,
	        'ENT_HTML_QUOTE_DOUBLE' : 2,
	        'ENT_COMPAT': 2,
	        'ENT_QUOTES': 3,
	        'ENT_IGNORE' : 4
	    };
	    if (quote_style === 0) {
	        noquotes = true;
	    }
	    if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags
	        quote_style = [].concat(quote_style);
	        for (i=0; i < quote_style.length; i++) {
	            // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
	            if (OPTS[quote_style[i]] === 0) {
	                noquotes = true;
	            }
	            else if (OPTS[quote_style[i]]) {
	                optTemp = optTemp | OPTS[quote_style[i]];
	            }
	        }
	        quote_style = optTemp;
	    }
	    if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
	        string = string.replace(/&#0*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
	        // string = string.replace(/&apos;|&#x0*27;/g, "'"); // This would also be useful here, but not a part of PHP
	    }
	    if (!noquotes) {
	        string = string.replace(/&quot;/g, '"');
	    }
	    // Put this in last place to avoid escape being double-decoded
	    string = string.replace(/&amp;/g, '&');
	
	    return string;
	},
	clipboard_copy : function (v) {
		// data 부분만 복사한다.
		if (typeof config.v == 'object') {
			var string = $(v).text();
		}else{
			var string = v;
		}
			
		if (window.clipboardData) {
			window.clipboardData.setData('Text', string);
		}else if (window.netscape) {
			netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
			var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
			if (!clip) return;
			var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
			if (!trans) return; 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 = string; 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);
		}
		return false;
	}
});
