<!--
/********************************************************************
// ÆÄ ÀÏ ¼³¸í : °øÅë ½ºÅ©¸³Æ®
// ÆÄ  ÀÏ  ¸í : common.js
// ÀÛ  ¼º  ÀÚ : 
// ÀÛ  ¼º  ÀÏ : 
// ¼ö  Á¤  ÀÏ :  
//********************************************************************/  
//alert(document.domain);

/*-----------------------------------------------------------------------------
//	°ø¹éÁ¦°ÅÇÔ¼ö
//	txtMode.value.trim()
-------------------------------------------------------------------------------*/
String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}


//----------------------------------------------------------------------------
// ÀÚµ¿ ³¯Â¥ ÇüÅÂ·Î ¸¸µé¾î ÁÖ´Â ÇÔ¼ö (ex : 2006-05-28)
// onKeyUp="fncAutoDate(this.form, this)"
//---------------------------------------------------------------------------- Start
function fncAutoDate(frm,cls)
{
	var len = cls.value.length;
	var idx;

	if(len >= 1) 
	{
		if(event.keyCode != '45' && (event.keyCode!= '46' && event.keyCode!= '8' && event.keyCode!= '110'))
		{
			if(len <= 4) 
			{
				//ÀÔ·ÂµÈ ¿¬ÀÇ °ªÀ» ¹Þ´Â´Ù.
				try{
					var inYear = parseInt(eval(cls.value.substring(0,4)));
					if(len == 4)
						cls.value += '-';
				}catch(e){
					cls.value = cls.value.substring(0,len-1);
				}

			}
			if(len==7) 
			{
				CheckCalendar("Month", cls, frm);
			}
			if(len==10){
				CheckCalendar("Day", cls, frm);
			}
		}
	}
}

function CheckCalendar(type, cls, frm){
	if(type == "Month"){
		var inMonth = 0;
		inMonth = CheckMonth(cls);
		if(inMonth <= 12 && inMonth > 0){
			cls.value += '-';
		}else if(inMonth == 9999){
			alert("³â-¿ùÀÇ ±¸¼ºÀÌ Àß¸øµÇ¾ú½À´Ï´Ù.\n¿ùÀ» ´Ù½ÃÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À.	");
			return false;
		}else{
			alert("ÇØ´ç ¿ùÀ» Àß¸ø ÀÔ·ÂÇÏ¼Ì½À´Ï´Ù.");
			cls.value = cls.value.substring(0,5);
			frm.focus();
			return false;
		}
	}else{
		var inDate = 0;
		inDate = CheckDay(cls, frm);

		if(inDate == 9999){
			alert("³â-¿ù-ÀÏÀÇ ±¸¼ºÀÌ Àß¸øµÇ¾ú½À´Ï´Ù.\nÀÏÀ» ´Ù½ÃÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À.	");
		}else if(!(inDate <= 31 && inDate > 0)){
			alert("ÇØ´ç ÀÏÀ» Àß¸ø ÀÔ·ÂÇÏ¼Ì½À´Ï´Ù.");
			cls.value = cls.value.substring(0,8);
			frm.focus();
		}
	}
	return true;
}
function CheckMonth(cls){
	// 1. 7ÀÚ¸® °¡¿îµ¥ -°¡ ÀÖ´ÂÁö È®ÀÎÇÑ´Ù.
	var test = cls.value.split("-");
	if(test.length < 2){
		cls.value = cls.value.substring(0,4)+"-";
		return 9999;
	}
	
	//ÀÔ·ÂµÈ ¿¬,¿ùÀÇ °ªÀ» ¹Þ´Â´Ù
	var inYear = parseInt(cls.value.substring(0,4));
	var inMonth = 0;
	
	try{
		inMonth = parseInt(eval(cls.value.substring(5,7)));
	}catch(e){
		cls.value = cls.value.substring(0,len-1);
	}
	
	return inMonth
}

function CheckDay(cls, frm){
	// 1. 9ÀÚ¸® °¡¿îµ¥ -°¡ µÎ°³ ÀÖ´ÂÁö È®ÀÎÇÑ´Ù.
	var test = cls.value.split("-");
	if(test.length < 3){
		cls.value = cls.value.substring(0,7)+"-";
		alert("³â-¿ù-ÀÏÀÇ ±¸¼ºÀÌ Àß¸øµÇ¾ú½À´Ï´Ù.\nÀÏÀ» ´Ù½ÃÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À.	");
		return 9999;
	}

	//ÀÔ·ÂµÈ ¿¬,¿ù,ÀÏÀÇ °ªÀ» ¹Þ´Â´Ù.
	var inYear = parseInt(cls.value.substring(0,4));
	var inMonth	= parseInt(eval(cls.value.substring(5,7)));
	var inDate = 0;
	try{
		inDate = parseInt(eval(cls.value.substring(8,10)));
	}catch(e){
		cls.value = cls.value.substring(0, len-1);
	}

	return inDate;
	
}
//----------------------------------------------------------------------- END



function Length(obj, p_maxbyte, r_byte) 
{
	var tmpStr;
	var temp=0;
	var onechar;
	var tcount;
	tcount = 0;
	
	maxbyte = p_maxbyte;
	aquery = obj.value;
	
	tmpStr = new String(aquery);
	temp = tmpStr.length;
	
    
	tcount = tmpStr.length+(escape(tmpStr)+"%u").match(/%u/g).length-1;
	alert(tcount);
	r_byte.value = tcount
	if(tcount>maxbyte) {
		reserve = tcount-maxbyte;
		alert("Á¤ÇØÁø ¿ë·®ÀÌ ÃÊ°úÇÏ¿© ÀÚµ¿À¸·Î »èÁ¦µË´Ï´Ù.");
		tmpStr = tmpStr.substring(0,maxbyte);	
		obj.value = tmpStr;
		return;
	}	
}


//----------------------------------------------------------------------------
//	ÀÛ¼ºµÈ ³»¿ëÀ» ¹ÙÀÌÆ®´ÜÀ§·Î Àß¶ó³»¾î Ã³¸®ÇÏ´Â ½ºÅ©¸³Æ®
//	onKeyUp="javascript:cal_byte(this, 50, '')"
//----------------------------------------------------------------------------
var maxbyte = "";
var aquery = "";

function cal_byte(obj, p_maxbyte, msg) {
	var tmpStr;
	var temp=0;
	var onechar;
	var tcount;
	tcount = 0;
	
	maxbyte = p_maxbyte;
	aquery = obj.value;

	tmpStr = new String(aquery);
	temp = tmpStr.length;

	for (k=0;k<temp;k++)
	{
		onechar = tmpStr.charAt(k);

		if (escape(onechar).length > 4) {
			tcount += 2;
		}
		else if (onechar!='\r') {
			tcount++;
		}
	}

	if(tcount>maxbyte) {
		reserve = tcount-maxbyte;
		/*
		if(msg.trim() != ""){
			alert("ÀÔ·ÂÇÑ "+msg+" "+reserve+"¹ÙÀÌÆ®°¡ ÃÊ°úµÇ¾ú½À´Ï´Ù.\r\n ÃÊ°úµÈ ºÎºÐÀº ÀÚµ¿À¸·Î »èÁ¦µË´Ï´Ù."); 
		}else{
			alert("ÀÔ·ÂÇÑ ³»¿ëÀÌ "+reserve+"¹ÙÀÌÆ®°¡ ÃÊ°úµÇ¾ú½À´Ï´Ù.\r\n ÃÊ°úµÈ ºÎºÐÀº ÀÚµ¿À¸·Î »èÁ¦µË´Ï´Ù."); 
		}
		*/
		//alert("Á¤ÇØÁø ¿ë·®ÀÌ ÃÊ°úÇÏ¿© ÀÚµ¿À¸·Î »èÁ¦µË´Ï´Ù.");
		alert("Cut Message. ");
		obj.value = netsgo_check();
		return;
	}	
}

function cutText() {
	nets_check(aquery, maxbyte);
}


function netsgo_check() {
	var tmpStr;
	var temp=0;
	var onechar;
	var tcount;
	tcount = 0;

	tmpStr = new String(aquery);
	temp = tmpStr.length;

	for(k=0;k<temp;k++)
	{
		onechar = tmpStr.charAt(k);

		if(escape(onechar).length > 4) {
			tcount += 2;
		}
		else if(onechar!='\r') {
			tcount++;
		}
		if(tcount>maxbyte) {
			tmpStr = tmpStr.substring(0,k);			
			break;
		}
	}
/*	
	if (max == 80) {
		document.sms_input.content.value = tmpStr;
		cal_byte(tmpStr);
	}
*/
	return tmpStr;
}


/*--------------------------------------------
¼³¸í : keyup Event½Ã ¹®ÀÚ¿­ ±æÀÌ¸¦ Ã¼Å©ÇÏ¿© ÇØ´ç ¹®ÀÚ¿­¸¸Å­¸¸ ÀÔ·Â°¡´É
		(ÇÑ±Û 2byte, ¼ýÀÚ,¿µ¹®,°ø¹é  1byte)
ÆÄ¶ó¹ÌÅÍ
tobj : ¹ÙÀÌÆ® Ã¼Å©ÇÒ ÇÊµå
p_maxlen : ÃÖ´ëÀÔ·Â¹®ÀÚ¿­
my_byte2(tobj, p_maxlen, tobj2)
tobj2 : ½ÇÁ¦ ÀÔ·Â ¹ÙÀÌÆ®
»ç¿ë¿¹ : Byte_Check(txt_CONTENT, 2000, txt_CNT);
----------------------------------------------*/
function Byte_Check(tobj, p_maxlen, tobj2)
{
	var tmpStr  = tobj.value;
	var strlen = tobj.value.length+(escape(tobj.value)+"%u").match(/%u/g).length-1;
	var retStr = "";
	tcount = 0;
	
	//alert(tobj2.outerText);
	tobj2.innerHTML = strlen;
	
	if (strlen > p_maxlen )
	{	
		alert("ÃÖ´ë ÀÔ·Â ¹®ÀÚ¿­Àº " + p_maxlen + " Byte ÀÔ´Ï´Ù.");
			
		tobj.value = nets_check(tmpStr,p_maxlen);
		tobj2.innerHTML = tobj.value.length+(escape(tobj.value)+"%u").match(/%u/g).length-1;
		return false;
	}
	return true;
}

function nets_check(p_tmpStr, p_maxlen) {
	var tmpStr;
	var temp=0;
	var onechar;
	var tcount;
	tcount = 0;
	
	//alert(p_tmpStr);
	temp = p_tmpStr.length;
	
	for (var i=0;i<p_tmpStr.length;i++)
	{
		onechar = p_tmpStr.charAt(i);
		//alert(onechar);
		//alert(onechar.length+(escape(onechar)+"%u").match(/%u/g).length-1);
		
		if (onechar.length+(escape(onechar)+"%u").match(/%u/g).length-1 == 2)
		{
			tcount += 2;
		}
		else if(onechar.length+(escape(onechar)+"%u").match(/%u/g).length-1 == 1)
		{
			tcount ++;
		}
		
		if(tcount>p_maxlen) {
			retStr = p_tmpStr.substring(0,i);
			break;
		}
	}					
	return retStr;
}


/*********************************************************************
¼³¸í : ÀÌ¹ÌÁö »õÃ¢¿¡¼­ ¶ç¿ì±â À§ÇÑ ½ºÅ©¸³Æ® µé
*********************************************************************/
var imgObj = new Image();
function showImgWin(imgName) {
	var targetSrc = "";
	var arraySrc = imgName.src.split("/Thumbnail/");
	
	if(arraySrc.length > 1){
		targetSrc = imgName.src.replace("/Thumbnail/","/Origin/");
	}
	else{
		targetSrc = imgName.src.replace("/middle/","/org/");
	}
	imgObj.src = targetSrc;
	setTimeout("createImgWin()", 500);
}
var imageWin = "";
function createImgWin() {
	var showWidths = 0;	
	var showHeights = 0;
	if (! imgObj.complete) {
		setTimeout("createImgWin()", 500);
		return;
	}
	
	var ratio;
	var ratio2;
	
	if(imgObj.width > screen.width - 10 || imgObj.height > screen.height - 125)					//°¡·Î³ª ¼¼·Î ±æÀÌÁß È­¸éº¸´Ù Å¬ °æ¿ì
	{
		if(imgObj.width > screen.width - 10 && imgObj.height > screen.height - 125)				//°¡·Î ¼¼·Î ±æÀÌ°¡ µÑ´Ù Å¬¶§
		{
			ratio		= (screen.width - 10) / imgObj.width;
			ratio2	= (screen.height - 125) / imgObj.height;
			
			if(ratio < ratio2)
			{
				showWidths		= imgObj.width * ratio;
				showHeights		= imgObj.height * ratio; 
			}
			else
			{
				showWidths		= imgObj.width * ratio2;
				showHeights		= imgObj.height * ratio2; 
			}
		}
		else if(imgObj.width > screen.width - 10)																		//°¡·Î ±æÀÌ°¡ ´õ Å¬°æ¿ì
		{
			ratio = (screen.width - 10) / imgObj.width;
			showWidths		= imgObj.width * ratio;
			showHeights		= imgObj.height * ratio; 
		}
		else																																		//¼¼·Î ±æÀÌ°¡ ´õ Å¬ °æ¿ì
		{
			ratio = (screen.height - 125) / imgObj.height;
			showWidths		= imgObj.width * ratio;
			showHeights		= imgObj.height * ratio; 
		}
	}
	else{																																			//°¡·Î ¼¼·Î ±æÀÌ°¡ µÑ´Ù ÀÛÀ» ¶§
		showWidths		= imgObj.width;
		showHeights		= imgObj.height; 
	}
	/*
	if(imageWin)
		imageWin.close();
	*/
	imageWin = window.open("", "imageWin", "width=" + showWidths + ",height=" + showHeights + ",scrollbars=yes");	
	imageWin.document.write("<html><title>ShowImage</title><body style='margin:0;overflow-x:auto;overflow-y:auto'>");
	imageWin.document.write("<img src='" + imgObj.src + "' width='" + showWidths + "' height='" + showHeights + "' onclick='javascript:window.close();' style='cursor:hand'>");
	imageWin.document.write("</body><html>");
	imageWin.document.close();
}

//ÆË¾÷Ã¢ »õÃ¢¿­±â
//function pop(url,w,h,val){
//	window.open(url+"?addr="+val,"","scrollbars=0,toolbar=0,location=0,resizable=0,status=0,menubar=0,resizable=0,width="+w+",height="+h+",left=100,top=100");
//}
function pop(url,w,h,val)
{
	window.open(url+"?addr="+val,"url","scrollbars=0,toolbar=0,location=0,resizable=0,status=0,menubar=0,resizable=0,width="+w+",height="+h+",left=100,top=100");
}