var IE = (document.all)? true:false ;
var NS = (document.layers)? true:false ;


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
//MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
	var p,i,x;
	if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); 
	return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var oldMenu;

function MenuLayerCtrl(ob, tmp, st)
{
	obj = document.getElementById(ob);
	if (obj.style)
	{
		obj = obj.style;
		st = (st == "show")? "visible":(st == "hide")? "hidden":st;
		a_st = "hidden";
	}
	else
	{
		a_st = "hide";
	}

	if (typeof(oldMenu) != "undefined" && oldMenu != null && oldMenu != obj)
	{
		oldMenu.visibility = a_st;
	}

	obj.visibility = st;

	oldMenu = obj;

	return;
}

/*
############## ÇÑ±Û Byte ±æÀÌ Ã¼Å© ###############
*/

var TOG_WORD				= '%0D';
//´Ü¹®¸Þ½ÃÁö¿¡¼­ ¸Þ½ÃÁöÀÇ ±æÀÌ¸¦ Ã¼Å©ÇÏ°í Â¥¸£´Â ÇÔ¼ö
function checkShrtMsgLen(obj,sByteLen) {
	var bResult		= checkMsgLen(obj,sByteLen);
	var iCountByte	= 0;
	var sContentMsg	= '';

	if (!bResult){
		sByteLen_k = Math.floor(sByteLen / 2);
		alert(sByteLen + " Byte¸¦ ³ÑÀ»¼ö ¾ø½À´Ï´Ù.\n\n(ÇÑ±Û " + sByteLen_k + " ÀÚ, ¿µ¹® " + sByteLen + " ÀÚ)");
		sContentMsg = cutText(obj,sByteLen);
		obj.value = sContentMsg;
	}
//	iCountByte = getByteLen(obj);
//	document.frmsms.COUNTBYTE.value = iCountByte[0];
}


function checkMsgLen(obj,sByteLen) {

	var iCounts = new Array();
	iCounts = getByteLen(obj);											//º¯¼öÀÇ ±æÀÌ¸¦ ±¸ÇÏ´Â ÇÔ¼ö

	if (iCounts[0] > sByteLen)
		return false;
	else
		return true;
}


function InputOnlyNum(v) {
	if (v < 48 || v > 57) {
		return false;
	}
	return true;
}


function FocusMove(len, obj1, obj2) {
	key	= event.keyCode;
	if (key != 9 && key != 16) {
		flag	= obj1.value.length;
		if (flag == len) {
			obj2.focus();
		}
	}
}


//ÀÏÁ¤ ¹ÙÀÌÆ® ÀÌ»ó µÇ¸é º¯¼öÀÇ ±æÀÌ¸¦ ÀÚ¸£´Â ÇÔ¼ö
function cutText(obj,sByteLen) {

	var sTmpMsg			= '';
	var iTmpMsgLen		= 0;
	var sOneChar		= '';
	var iCount			= 0;
	var sOneCharNext	= '';

	sTmpMsg = new String(obj.value);
	iTmpMsgLen = sTmpMsg.length;

	for (var k = 0 ;k < iTmpMsgLen ; k++) {
		sOneChar = sTmpMsg.charAt(k);
		sOneCharNext = sTmpMsg.charAt(k+1);
		if (escape(sOneChar) == TOG_WORD) {
			iCount++;
			if (iCount > sByteLen-1) {
				sTmpMsg = sTmpMsg.substring(0,k);
				break;
			}
		}
		else if (escape(sOneChar).length > 4) {
			iCount += 2;
		}
		else {
			iCount++;
		}
		if (iCount > sByteLen) {
			sTmpMsg = sTmpMsg.substring(0,k);
			break;
		}
	}
	return sTmpMsg;
}


//ÇÑ±ÛÀÏ °æ¿ì¿¡´Â 2byte¸¦ ±×¿ÜÀÇ ¹®ÀÚ´Â 1byte·Î °è»êÇÏ¿©  iCounts¿¡ ÀúÀåÇÏ¿© return ÇØÁØ´Ù.
function getByteLen(obj,sMsgLng) {

	var sMsg       = obj.value;
	var sTmpMsg    = '';												//¸Þ½ÃÁö¸¦ ÀÓ½Ã·Î ÀúÀåÇÏ´Â º¯¼ö
	var sTmpMsgLen = 0;													//ÀÓ½Ã·Î ÀúÀåµÈ ¸Þ½ÃÁöÀÇ ±æÀÌ¸¦ ÀúÀåÇÏ´Â º¯¼ö
	var sOneChar   = '';												//ÇÑ¹®ÀÚ¸¦ ÀúÀåÇÏ´Â º¯¼ö
	var iCounts    = new Array();										//ÃÑ ¹ÙÀÌÆ®¿Í ÆäÀÌÁö´ç ¹ÙÀÌÆ® ¼ö¸¦ ÀúÀåÇÏ´Â ¹è¿­

	iCounts[0]=0;														//ÃÑ ¹ÙÀÌÆ®¸¦ ÀúÀå ÇÏ´Â º¯¼ö

	if (sMsgLng != null) {
		sTmpMsg	= new String(sMsgLng);
	}
	else
		sTmpMsg	= new String(sMsg);
	sTmpMsgLen	= sTmpMsg.length;

	for (k = 0 ;k < sTmpMsgLen ;k++) {
		sOneChar = sTmpMsg.charAt(k);
		if (escape(sOneChar) == TOG_WORD) {
			iCounts[0]++;
		}
		else if (escape(sOneChar).length > 4) {
			iCounts[0] += 2;
		}
		else  {
			iCounts[0]++;
		}
	}

	return iCounts;
}

// ÁÖ¹Î¹øÈ£ Ã¼Å©
function chk_jumin(Jno)
{
	J1 = Jno.substr(0,6);
	J2 = Jno.substr(6,7);
	var SUM=0;
	// ÁÖ¹Îµî·Ï¹øÈ£ 1 ~ 6 ÀÚ¸®±îÁöÀÇ Ã³¸®
	// ÁÖ¹Îµî·Ï¹øÈ£¿¡ ¼ýÀÚ°¡ ¾Æ´Ñ ¹®ÀÚ°¡ ÀÖÀ» ¶§ Ã³¸®
 	for(i=0;i<J1.length;i++){
        	if (J1.charAt(i) >= 0 || J1.charAt(i) <= 9) {
        		// ¼ýÀÚ¸é °ªÀ» °öÇØ ´õÇÑ´Ù.
			if(i == 0){
				SUM = (i+2) * J1.charAt(i);
			} else {
				SUM = SUM +(i+2) * J1.charAt(i);
			}
		} else {
			// ¼ýÀÚ°¡ ¾Æ´Ñ ¹®ÀÚ°¡ ÀÖÀ» ¶§ÀÇ Ã³¸®
//			alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼¼¿ä");
			return false;
		}
	}

	// ÁÖ¹Îµî·Ï¹øÈ£ 7 ~  8 ÀÚ¸®±îÁöÀÇ Ã³¸®
	for(i=0;i<2;i++){
	        if (J2.charAt(i) >= 0 || J2.charAt(i) <= 9) {
	        	SUM = SUM + (i+8) * J2.charAt(i);
		}else{
			// ¼ýÀÚ°¡ ¾Æ´Ñ ¹®ÀÚ°¡ ÀÖÀ» ¶§ÀÇ Ã³¸®
//		   	alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼¼¿ä");
       		return false;
		}
	}

	// ÁÖ¹Îµî·Ï¹øÈ£ 9 ~ 12 ÀÚ¸®±îÁöÀÇ Ã³¸®
	for(i=2;i<6;i++){
	        if (J2.charAt(i) >= 0 || J2.charAt(i) <= 9) {
		   SUM = SUM + (i) * J2.charAt(i);
		}else{
			// ¼ýÀÚ°¡ ¾Æ´Ñ ¹®ÀÚ°¡ ÀÖÀ» ¶§ÀÇ Ã³¸®
//		   	alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼¼¿ä");
       		return false;
		}
	}

	// ³ª¸ÓÁö ±¸ÇÏ±â
	 var checkSUM = SUM % 11;
	// ³ª¸ÓÁö°¡ 0 ÀÌ¸é 10 À» ¼³Á¤
	if(checkSUM == 0){
	   var checkCODE = 10;
	// ³ª¸ÓÁö°¡ 1 ÀÌ¸é 11 À» ¼³Á¤
	}else if(checkSUM ==1){
	   var checkCODE = 11;
	}else{
	   var checkCODE = checkSUM;
	}
	// ³ª¸ÓÁö¸¦ 11 ¿¡¼­ »«´Ù
	var check1 = 11 - checkCODE;
	if (J2.charAt(6) >= 0 || J2.charAt(6) <= 9) {
		var check2 = parseInt(J2.charAt(6))
	}else{
		// ¼ýÀÚ°¡ ¾Æ´Ñ ¹®ÀÚ°¡ ÀÖÀ» ¶§ÀÇ Ã³¸®
//		alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼¼¿ä");
		return false;
	}

	if(check1 != check2){
		// ÁÖ¹Îµî·Ï¹øÈ£°¡ Æ²¸± ¶§ÀÇ Ã³¸®
//		alert("ÁÖ¹Îµî·Ï ¹øÈ£¸¦ ´Ù½Ã È®ÀÎ ÇÏ¼¼¿ä.");
		return false;
	}else{
		return true;
	}
}


//¿Ü±¹ÀÎ ÁÖ¹Î¹øÈ£ Ã¼Å©
function chk_foreigner(reg_no) {
	if (reg_no.length != 13) {
		return false;
	}

    var sum = 0;
    var odd = 0;

    buf = new Array(13);
    for (i = 0; i < 13; i++) buf[i] = parseInt(reg_no.charAt(i));

    odd = buf[7]*10 + buf[8];   // ¾Õ¿¡¼­ 8,9¹øÂ° ÀÚ¸®¼ýÀÚ

    if (odd%2 != 0) {		//odd°¡ Â¦¼öÀÌ¾î¾ß ÇÔ
      return false;
    }

    if ((buf[11] != 6)&&(buf[11] != 7)&&(buf[11] != 8)&&(buf[11] != 9)) {  //12¹øÂ° ¼ýÀÚ´Â 6,7,8,9 Áß ÇÏ³ª
      return false;
    }

    multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
    for (i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);


    sum = 11 - (sum % 11);

    if (sum >= 10) sum -= 10;

    sum += 2;

    if (sum >= 10) sum -= 10;

    if ( sum != buf[12]) {
      return false;
    }
    else {
        return true;
    }
}



function Link(obj) {
	obj.target = pageTarget;
}

function ChangeTarget(val) {
	var exp = new Date();
	exp.setTime(exp.getTime() + (365 * 24 * 60 * 60 * 1000));

	pageTarget = val;
	SetCookie ("dgdTarget", val, exp, "/", ".daganda.com");
}

function MakeInfoWindow(wURL, wFeature) {
	var mDate = new Date();
	sec = mDate.valueOf();
	window.open(wURL, "info_window" + sec, wFeature);
}

function MakeWindow(wURL, wFeature)
{
	window.name = "noadMain";
	return window.open(wURL, "noadPopup", wFeature);
}


function MakeAWGraph(name)
{
	if (name)
	{
		aURL = "awGraph.asp?dat=" + escape(name);
	}
	else
	{
		aURL = "";
	}
	awWin = window.open(aURL, "_awPoint", "width=510,height=310");
	awWin.focus();
}

function MakeAWAllTalk(name)
{
	aURL = "awAllTalk.asp?dat=" + escape(name);
	awWin = window.open(aURL, "_awTalk", "width=600,height=600,scrollbars=yes");
	awWin.focus();
}

//trim ¸Þ¼Òµå
function trim(str) {
	var count = str.length;
	var len = count;
	var st = 0;

	while ((st < len) && (str.charAt(st) <= ' ')) {
		st++;
	}
	while ((st < len) && (str.charAt(len - 1) <= ' ')) {
		len--;
	}
	return ((st > 0) || (len < count)) ? str.substring(st, len) : str ;
}


// email Çü½Ä Ã¼Å©
function IsEmail(str) {
  // regular expression Áö¿ø ¿©ºÎ Á¡°Ë
	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");

	return (!r1.test(str) && r2.test(str));
}


function CtrlStatus() {
	strStatus	= "°®ÐÄÍÞÍÞ"
	self.status = strStatus;
	return true;
}


function MakePaymentWin(amt, prod) {
	if (amt == "" || amt == 0)
	{
		alert("°¡°ÝÀ» ¼±ÅÃÇÏ¼¼¿ä");
		return;
	}

	winW = 400;
	winH = 313;
	winL = (window.screen.width - winW) / 2;
	winT = (window.screen.height - winH) / 2;
	dURL = "/pay/paycheck.asp?amt=" + amt + "&productName=" + prod + "&service=" + escape('http://www.donga.com/movie/cinezone/bstillimage.php?gubun=200312090003&stillno=1');
	window.open(dURL, "dgdPay", "width=" + winW + ",height=" + winH + ",left=" + winL + ",top=" + winT);
}


function Open_MyWallet(wURL) {
	winW = 400;
	winH = 313;
	winL = (window.screen.width - winW) / 2;
	winT = (window.screen.height - winH) / 2;
//	dURL = "/pay/paycheck.asp?amt=" + amt + "&productName=" + prod + "&service=" + escape('http://www.donga.com/movie/cinezone/bstillimage.php?gubun=200312090003&stillno=1');
	window.open(wURL, "dgdPay", "width=" + winW + ",height=" + winH + ",left=" + winL + ",top=" + winT);
}


function GetFileNamefromURL(sURL) {
	patt = /\/([^\/\?]+)[^\/]*$/g;
	var re = new RegExp(patt);
	arr = re.exec(sURL);

	return arr[1];
}

function LayerMenu(o) {
	o.style.visibility = (o.style.visibility == "visible")? "hidden" : "visible";
}

function LayerMenu2(o, mode) {
	if (IE)
	{
		obj = eval("document.all['" + o + "']");
		obj.style.visibility = mode;
	}
	else
	{
		obj = eval("document." + o);
		obj.style.visibility = (mode == "visible")? "show" : "hide";
	}
}


function VncWin() {
	window.open('/rc.asp','','scrollbars=no,resizable=no,width=600,height=400');
}

function LayerCtrl() {
	cW = document.body.clientWidth;
	cH = document.body.clientHeight;
	oH = document.body.offsetHeight;
	sH = document.body.scrollHeight;
	sT = document.body.scrollTop;

//	topBtn.style.top = cH - 75 + sT;
	adultMenu.style.left = (cW / 2) + 400;
}

function PopupLogin(nextURL, nextTarget)
{
	winW = 300;
	winH = 183;
	winL = (window.screen.width - winW) / 2;
	winT = (window.screen.height - winH) / 2;
	pURL = "/members/loginform.asp?ln=" + nextURL + "&tn=" + nextTarget;
	lpop = window.open(pURL, "_noadLoginPop", "width=" + winW + ",height=" + winH 
			+ ",left=" + winL + ",top=" + winT + ",scollbars=no,status=no");
	lpop.focus();
}

function PrintFlash(width, height, src)
{
	output = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codeBase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' "
		+ "height='" + height + "' width='" + width + "' classid='clsid:D27CDB6E-AE6D-11cf-96B8-44455354000' style='z-index:1'>"
		+ "<PARAM NAME='Movie' VALUE='" + src + "'>"
		+ "<PARAM NAME='Quality' VALUE='High'><PARAM NAME='wmode' VALUE='transparent'>"
		+ "<PARAM NAME='wmode' VALUE='transparent'>"
		+ "<embed src='" + src + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' "
		+ "type='application/x-shockwave-flash' width='" + width + "' height='" + height + "'></embed></OBJECT>";
	
	document.open();
	document.write(output);
	document.close();

}
document.title = "»¶Ó­·ÃÎÊ°®ÐÄÍÞÍÞ";
document.onmouseover = CtrlStatus;
//window.document.forms[0].onkeypress = function() {if (event.keyCode == 13) event.returnValue = false;}

///// Header and Footer

