/***************************************************************************************
******************************** ÆË¾÷ µå·¡±× ·¹ÀÌ¾î *************************************
****************************************************************************************/

// ºê¶ó¿ìÀú ¹öÀüº° Ã¼Å©
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

// ³Ý½ºÄÉÀÌÇÁ °è¿­ÀÇ ³·Àº ¹öÀü ºê¶ó¿ìÀú¸¦ À§ÇÑ....
var dragswitch=0;
var nsx;
var nsy;
var nstemp;

function drag_dropns(name){
 if (!ns4)
	return;
 temp=eval(name);
 temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
 temp.onmousedown=gons;
 temp.onmousemove=dragns;
 temp.onmouseup=stopns;
}

function gons(e){
 temp.captureEvents(Event.MOUSEMOVE);
 nsx=e.x;
 nsy=e.y;
}

function dragns(e){
 if (dragswitch==1){
	temp.moveBy(e.x-nsx,e.y-nsy);
	return false;
 }
}

function stopns(){
 temp.releaseEvents(Event.MOUSEMOVE);
}
// ³Ý½ºÄÉÀÌÇÁ °è¿­ ³·Àº ¹öÀü ºê¶ó¿ìÀú¸¦ À§ÇÑ.... ³¡


// Å©·Î½ººê¶ó¿ìÀúÀÇ ³ôÀº ¹öÀüÀ» À§ÇÑ º¯¼ö Á¤ÀÇ
var crossobj;
var tempx;
var tempy;
var offsetx;
var offsety;

// ¸¶¿ì½º µå·¡±×¿¡ ÀÇÇÑ ·¹ÀÌ¾î ¿òÁ÷ÀÓ ÅëÁ¦
function drag_drop(e){
 if (ie4&&dragapproved){
	crossobj.style.left=tempx+event.clientX-offsetx;
	// ¿òÁ÷ÀÎ·¹ÀÌ¾îÀÇ ¿ÞÂÊ  = ¿ø·¡À§Ä¡ + ÇöÀç¸¶¿ì½ºÀ§Ä¡ - ´­·¶À»´ç½Ã ¸¶¿ì½ºÀ§Ä¡  Áï ¿ø·¡·¹ÀÌ¾îÀ§Ä¡¿¡¼­ ¸¶¿ì½º°¡ ¿òÁ÷ÀÎ¸¸Å­¸¸ ´õÇØ¶ó
	crossobj.style.top=tempy+event.clientY-offsety;
	return false;
 }
 else if (ns6&&dragapproved){
	crossobj.style.left=tempx+e.clientX-offsetx+"px";
	crossobj.style.top=tempy+e.clientY-offsety+"px";
	return false;
 }
}


//Å©·Î½ººê¶ó¿ìÂ¡À» À§ÇØ °¢ º¯¼ö°¡ Á¤ÀÇ
function initializedrag(e){
 // Å©·Î½ººê¶ó¿ìÂ¡À» À§ÇÑ ¿ÀºêÁ§Æ® ¼±ÅÃ getElementById¸¦ ¾µ°ÍÀÎÁö all.¾ÆÀÌµð¸íÀ» ¾µ°ÇÀÎÁö
 crossobj=ns6? document.getElementById("drag_popup") : document.all.drag_popup;

 // ÀÌº¥Æ®°¡ ÀÏ¾î³­ ¿ÀºêÁ§Æ® ¼±ÅÃ
 var firedobj=ns6? e.target : event.srcElement;

 // ºê¶ó¿ìÀúº° ÃÖ»óÀ§ ¿ÀºêÁ§Æ® ÀÌ¸§°ú DTD Á¤ÀÇ¿¡ µû¶ó body, documentElementÀÇ Â÷ÀÌ
 var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body";


 // while °ú if ¹®Àº ¾î¶² È¿¿ëÀÌ ÀÖ´ÂÁö Àß ¸ð¸£°Ú´Ù. ÆË¾÷À» ¿òÁ÷ÀÌ´Âµ¥´Â ²À ÇÊ¿äÇÏÁö´Â ¾Ê´Ù.
 // while¹® ÀüÃ¼¿Í ifÀÇ Á¶°ÇÀ» Á¦°ÅÇØµµ È¿°ú¿¡ ÀÌ»óÀº ¾ø´Ù
 while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
	firedobj=ns6? firedobj.parentNode : firedobj.parentElement;
 }

 if (firedobj.id=="dragbar"){
	offsetx=ie4? event.clientX : e.clientX;
	offsety=ie4? event.clientY : e.clientY;
	tempx=parseInt(crossobj.style.left);
	tempy=parseInt(crossobj.style.top);

	dragapproved=true;
	document.onmousemove=drag_drop;
 }
}

// ¹®¼­¾îµð¿¡¼­ ¸¶¿ì½º¸¦ ¶¼µµ ´õÀÌ»ó µå·¹±× µÇÁö ¾Êµµ·Ï
document.onmouseup=new Function("dragapproved=false");


// Ã¢´Ý±â¿Í Äí±â ¹ß±Þ
function popupClose(e,myCookie,value) {
 var obj=ns6? e.target : event.srcElement;
 while(obj.tagName != "DIV") {
	obj=ns6? obj.parentNode : obj.parentElement;
 }
 obj.style.display = 'none';

 //ÇÏ·ç ÇÑ¹ø¸¸ ¿­±â
 if(myCookie) {
	setCookie(myCookie,value,1);
 }
}

// ÇöÀç º¸À¯ Äí±â °Ë»ç
function getCookie( name ) {

 // ÇöÀç À¥»çÀÌÆ®¿¡ ¸Â´Â ¸ðµç Äí±â¸¦ cookieName=cookieValue; cookieName=cookieValue; cookieName=cookieValue ÇüÅÂ·Î ÀúÀåµÈ´Ù.
 var allCookie = document.cookie;

 // cookieValue ¸¸ ¸®ÅÏ ½ÃÅ°±â À§ÇØ¼­ Ã£´Â ¹®ÀÚ°¡ " cookieName= "¸¦ Ã£°ÔÇÑ´Ù.
 var nameOfCookie = name + "=";

 // allCookie¿¡¼­ cookieName°ú  ÇÕÄ¡ÇÏ´Â cookieValue ¸¦ substring(½ÃÀÛÁ¡,³¡Á¡)À¸·Î °¡Á®¿Ã°Å¶ó ÃÖÃÊ ½ÃÀÛÁ¡ 0À¸·Î ¼³Á¤
 var x = 0;

 while ( x <= document.cookie.length ) {

	// ³¡Á¡Àº ½ÃÀÛÁ¡¿¡ Ã£À» ÄíÅ°ÀÌ¸§À» ´õÇÑ°ª
	var y = (x+nameOfCookie.length);

	if ( document.cookie.substring( x, y ) == nameOfCookie ) { //ÄíÅ°ÀÌ¸§À» Ã£¾Ò´Ù¸é

	 if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) { //allCookieÀÇ ¸Ç ¸¶Áö¸· ÀÚ¸®°¡ ÀÏ¶§¿Í ¾Æ´Ò¶§ÀÇ ³¡ÀÚ¸®
		endOfCookie = document.cookie.length;
	 }

	 //³¡Á¡ÀÌ ½ÃÀÛÀÚ¸®°¡ µÇ°í À§¿¡¼­ ±¸ÇÑ ³¡ÀÚ¸®±îÁöÀÇ °ªÀÌ cookieValue°¡ µÈ´Ù.
	 return unescape( document.cookie.substring( y, endOfCookie ) );
	}

	// ÀÏÄ¡ÇÏ´Â Äí±âÀÌ¸§ÀÌ ¾Æ´Ò¶§ Äí±â¿Í ´ÙÀ½Äí±âÀÇ ±¸ºÐÀº ÇÑÄ­ ¶Ù´Â °ÍÀ¸·Î ±¸ºÐÇÏ¿© ´ÙÀ½ ÄíÅ°ÀÇ ½ÃÀÛÁ¡À» Àâ´Â´Ù.
	x = document.cookie.indexOf( " ", x ) + 1;

	// Äí±â°¡ ÇÏ³ªµµ ¾øÀ¸¸é while¹®À» ¹þ¾î³ª¶ó
	if ( x == 0 ) break;
 }

 // Äí±â°¡ ¾ø´Ù¸é ºó°ªÀ» ¸®ÅÏÇÑ´Ù.
 return "";
}

//»õ·Î¿î Äí±â µî·Ï
function setCookie( name, value, expiredays ) {

 // ¿À´Ã ³¯Â¥¸¦ ±¸ÇÏ°í
 var todayDate = new Date();

 // ¿À´Ã ³¯Â¥¿¡ ?ÀÏÀ» ´õÇÏ°í
 // ¿©±â¼­ ½Ã°£´ÜÀ§¸¦ ÀÚÀ¯·Ó°Ô ¼³Á¤ÇÒ ¼ö ÀÖ´Ù.
 todayDate.setDate( todayDate.getDate() + expiredays );

 //ÄíÅ°¸¦ »õ·Ó°Ô µî·ÏÇÑ´Ù.
 document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"

 //setCookie ¿¡¼­ °ªÀ» escapeÇÏ°í getCookie¿¡¼­ unescape ÇÏ´Â °ÍÀ» ÁÖÀÇÇÏÀÚ
}
