function EP_activate(num) {
    document.write(document.getElementById("DEACTIVATED_TEXT" + num).value);
}

function imgOver(param) {
	param.src = param.src.replace("off", "on");
}
function imgOut(param){
	param.src = param.src.replace("on", "off");
}


function pop(url,wname,opt){
	window.open(url,wname,opt);
}

function mcRunObj(string) {
	if(string != undefined)
	{
		document.write(string);
	}	
}	

function EP_activate(num) {
    document.write(document.getElementById("DEACTIVATED_TEXT" + num).value);
}

function pepboxSetup(partnerId) {
	if (partnerId)
	{
		if (partnerId == 'pepbox')
		{
			location.href = '/image/pepbox_setup.exe';
		} else {
			location.href = '/image/' + partnerId + '_pepbox_setup.exe';
		}
	} else {
		location.href = '/image/pepbox_setup.exe';
	}
}

function imageEditorSetup() {
	location.href = '/image/photomi_setup.exe';
}

function movieEditorSetup() {
	location.href = '/image/pepmovie_setup.exe';
}

function ResizeIframe(name, minHeight)
{
	if (IE) {
		var ifrmBody = document.frames(name).document.body;
	} else {
		var ifrmBody = document.getElementById(name).contentDocument.documentElement;
	}
	var oFrame = document.getElementById(name);			

	// width 는 처리 하지 않도록 주석 처리함.  google crom 브라우저에서 width가 정확치 않음
	// 2008.09.18 왕장기 
	//oFrame.style.width = ifrmBody.scrollWidth + "px";

	var height = ifrmBody.scrollHeight;

	if (minHeight)
	{
		if (minHeight > ifrmBody.scrollHeight)
		{
			height = minHeight;
		}
	}

	oFrame.style.height = height + "px";
	
	// GrayBackDiv 크기 조정 추가 함.
	// 2008.09.02 왕장기
	var addHeight = height;
	var bg = $('GrayBackDiv');
	if(bg)
	{
		var currentHeight = $('GrayBackDiv').getHeight();
		bg.style.height = (currentHeight + addHeight)+'px';
	}
}

function ParentResizeIframe(name, minHeight)
{
	if (parent && parent != this && parent.ResizeIframe != null)
	{
		parent.ResizeIframe(name, minHeight);
	}
}

function ParentResizeIframeMulti(name, parentName)
{
	if (parent && parent != this && parent.ResizeIframe != null)
	{
		parent.ResizeIframe(name);
		parent.ParentResizeIframe(parentName);
	}
}

function ResizeImage(num)
{
	var oImg = eval("document.getElementById('edimg" + num + "')");

	if (oImg.width > 716)
		oImg.width = 716;
}

function PopView(url)
{
	url = decodeURI(url);
    window.open("../global/img_viewer.jsp?img_nm=" + url, "imgview", "scrollbars=yes,width=100,height=100,resizable=yes");
}

function Comma(numstr) {
  var numstr = String(numstr);
  var re0 = /(\d+)(\d{3})($|\..*)/;
  if (re0.test(numstr))
    return numstr.replace(re0, function(str,p1,p2,p3) { return Comma(p1) + "," + p2 + p3; });
  else
    return numstr;
}

function GetOnlyText(obj) {
	if (window.ActiveXObject) {
		return obj.innerText;
	} else {
		return obj.textContent;
	}
}

function GetValue(obj, name) {
	var rst = '';
	try {
		var record_data = obj.getElementsByTagName(name);
		if(record_data){
			
			if (record_data.item(0).hasChildNodes()) {
			
				rst = record_data.item(0).firstChild.nodeValue;
			}
		}
	} catch (e) {}
	
	return rst;
}

function SelectBoxOptionAdd(obj, value, text) {
	var new_option = document.createElement('option');
	new_option.value = value;
	new_option.text = text;
	obj.options.add(new_option);
}

function getJsCookie(name){
	var Found = false;
	var start, end;
	var i = 0;

	while(i <= document.cookie.length) {
		 start = i;
		 end = start + name.length;
		 if(document.cookie.substring(start, end) == name) {
			 Found = true;
			 break;
		 }
		 i++;
	}

	if(Found == true) {
		start = end + 1;
		end = document.cookie.indexOf(";", start);
		if(end < start)
			end = document.cookie.length;
		return document.cookie.substring(start, end);
	}
	return "";
}

function setJsCookie(name, value, expiredays) {
	var todayDate = new Date(); 
	todayDate.setDate( todayDate.getDate() + expiredays ); 
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}

function getBody()/*{{{*/
{
	var oBodyScroll = getBodyScroll();
	var oBodySize = getBodyInnerSize();
	var oBody = new Object;
	oBody.width = oBodySize.width;
	oBody.height = oBodySize.height;
	oBody.top = oBodyScroll.top;
	oBody.left = oBodyScroll.left;

	return oBody;
}

function getBodyScroll()/*{{{*/
{
	var x,y;
	if(typeof(self.pageYOffset)!='undefined') // IE 외 모든 브라우저
	{
		x = self.pageXOffset;
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)// Explorer 6 Strict
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (document.body)  // IE 브라우저
	{
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	var result = new Object;
	result.left = x;
	result.top = y;
	return result;
}

function getBodyInnerSize()/*{{{*/
{
	var result = new Object;
	if(self.innerWidth)
	{
		result.width = self.innerWidth;
		result.height = self.innerHeight;
		return result;
	}
	else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict 모드
	{
		result.width = document.documentElement.clientWidth;
		result.height = document.documentElement.clientHeight;
		return result;
	}
	else if (document.body) { // 다른 IE 브라우저
		result.width = document.body.clientWidth;
		result.height = document.body.clientHeight;
		return result;
	}
}

function make_spot_bg()/*{{{*/
{
	var bg = $('SpotLayerBack');
	if(!bg)
	{
		bg = document.createElement('div');
		bg.setAttribute('id','SpotLayerBack');
		bg.className = 'alpha50';
		document.body.appendChild(bg);
		bg.onclick = function(){unload_spot();};
	}
	var oBody = wbs_get_body();
	if(oBody.height > document.body.scrollHeight)
		bg.style.height = oBody.height+'px';
	else
		bg.style.height = document.body.scrollHeight+'px';
	bg.style.display = '';
	document.body.width = '100%';
}

/* 댓글 리사이징 */
function resizeArea(curObj, min, max){
	textarea = curObj;
	if (navigator.userAgent.indexOf("SV1") > 0){   } 
	else if(navigator.userAgent.indexOf("MSIE 7")>0) {  }
	else { max = 300; }

	scrollheight = curObj.scrollHeight;
	if(scrollheight<=min) {
		textarea.style.height = min + 'px';
		textarea.style.overflowY = "hidden";
	}else if(scrollheight>max){
		textarea.style.height = max + 'px';
		textarea.style.overflowY = "auto";
	}else{
		textarea.style.height = scrollheight + 'px';
		textarea.style.overflowY = "hidden";
	}
}

/*암호화*/
var Security = { 
	FrmEncription : function(objFrm){
		for(var i=0;i<objFrm.length;i++){
			objFrm[i].value = this.FrmEncript(objFrm[i].value);
		}
	},
	FrmEncript : function(str){ 
			var bE = this.URLEncode(str); 
			var mE = this.DoEncript(bE);  
			return mE;
	}, 	
	DoEncript : function(value) { 
		var encrypt = "";
		
		var encryptKeyArray = new Array(
				"Z", "a", "U", "V", "d", "e", "f",
				"n", "o", "p", "q", "r", "s", "t",
				"E", "F", "G", "H", "I", "J", "K",
				"W", "X", "Y", "u", "v", "w", "x",
				".", "*", "_", "-", "P", "Q", "R",
				"7", "8", "9", "A", "B", "C", "D",
				"S", "T", "b", "c", "y", "z", "%",
				"0", "1", "2", "3", "4", "5", "6", 
				"g", "h", "i", "j", "k", "l", "m", 
				"L", "M", "N", "O");

		var decryptKeyArray = new Array(
				"0", "1", "2", "3", "4", "5", "6", 
				"7", "8", "9", "A", "B", "C", "D",
				"E", "F", "G", "H", "I", "J", "K",
				"L", "M", "N", "O", "P", "Q", "R",
				"S", "T", "U", "V", "W", "X", "Y",
				"Z", "a", "b", "c", "d", "e", "f",
				"g", "h", "i", "j", "k", "l", "m", 
				"n", "o", "p", "q", "r", "s", "t",
				"u", "v", "w", "x", "y", "z", "%",
				".", "*", "_", "-");
		
		for ( var i=0; i < value.length; i++ ) {
			var tempChar = "";
			if ( i == value.length ) {
				tempChar = value.substring(i);
			} else {
				tempChar = value.substring(i, i+1);
			}
			
			var keySearchPoint = 0;
			for ( var j=0; j < decryptKeyArray.length; j++ ) {
				if ( tempChar == decryptKeyArray[j] ) {
					keySearchPoint = j;
					break;
				}
			}
			
			encrypt += encryptKeyArray[keySearchPoint];
		}
		return encrypt;
	}, 

	URLEncode : function(str){
		var s0, i, s, u;
		s0 = "";                // encoded str
		for (i = 0; i < str.length; i++){   // scan the source
			s = str.charAt(i);
			u = str.charCodeAt(i);          // get unicode of the char
			if (s == " "){s0 += "+";}       // SP should be converted to "+"
			else {
				if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){       // check for escape
					s0 = s0 + s;            // don't escape
				}
				else {                  // escape
					if ((u >= 0x0) && (u <= 0x7f)){     // single byte format
						s = "0"+u.toString(16);
						s0 += "%"+ s.substr(s.length-2);
					}
					else if (u > 0x1fffff){     // quaternary byte format (extended)
						s0 += "%" + (0xf0 + ((u & 0x1c0000) >> 18)).toString(16);
						s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
						s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
						s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
					}
					else if (u > 0x7ff){        // triple byte format
						s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
						s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
						s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
					}
					else {                      // double byte format
						s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
						s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
					}
				}
			}
		} 
		return s0; 
	}

	
}