// ÄíÅ°¾²±â
// name: ÄíÅ°¸í
// value: ÄíÅ°°ª
// expire: À¯È¿±â°£(Date°´Ã¼)
function setCookie(name, value, expire)
{
	document.cookie = name + "=" + escape( value ) + "; path=/"
	  + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}

// ÄíÅ° ¾ò±â
// name: ÄíÅ°¸í
function getCookie(name)
{
        var nameOfCookie = name + "=";
        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 )
                                endOfCookie = document.cookie.length;
                        return unescape( document.cookie.substring( y, endOfCookie ) );
                }
                x = document.cookie.indexOf( " ", x ) + 1;
                if ( x == 0 )
                        break;
        }
        return "";
}

// ÇÏ·çµ¿¾È ÆË¾÷Ã¢ÀÌ ¶ßÁö¾Ê°Ô ÇÏ±â
// o: Ã¼Å©Æû °´Ã¼
// cookie_name: ÄíÅ°¸í, '¿À´Ã ÇÏ·ç ÀÌÃ¢À» ¿­Áö¾ÊÀ½'À» Ã¼Å©ÇÏ´Â ÄíÅ°
function closeWin(o, cookie_name)
{
  if ( o.checked )
  {
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + 1 );
    setCookie(cookie_name, "done", todayDate);
  }
  self.close();
}


// ÆË¾÷Ã¢ ´Ý°í º»Ã¢ ÁÖ¼Ò ÀÌµ¿
// url: ÀÌµ¿ÇÒ ÁÖ¼Ò
function gotoURL(url)
{
  opener.document.location = url;
  opener.focus();
  window.close();
}


// ÆË¾÷Ã¢ ´Ý°í »õÃ¢ ¶ç¿ì±â
// url: ÀÌµ¿ÇÒ ÁÖ¼Ò
function openURL(url)
{
  window.open(url).focus();
  window.close();
}


// ÆË¾÷Ã¢ ¶ç¿ì±â
// addr: ÁÖ¼Ò
// cookie_name: ÄíÅ°¸í, '¿À´Ã ÇÏ·ç ÀÌÃ¢À» ¿­Áö¾ÊÀ½'À» Ã¼Å©ÇÏ´Â ÄíÅ°
// param: ÆË¾÷Ã¢ »óÅÂ¸¦ °áÁ¤ÇÏ´Â ÆÄ¶ó¸ÞÅÍ width|height|scrollbars|left|top
function openPopup(addr, cookie_name, param)
{
  if ( getCookie(cookie_name) != "done" ) {
    window.open(addr, cookie_name, param).focus();
  }
}


// param ÀÛ¼º
function makeParam(marginLeft, marginTop, sizeWidth, sizeHeight, scrollbars, alignCenter, valignCenter)
{
  var param = "";

  if (alignCenter == "T")
    marginLeft = screen.width / 2 - sizeWidth / 2;
  if (valignCenter == "T")
    marginTop = screen.height / 2 - sizeHeight / 2;
  if (marginLeft != "")
    param += "left=" + marginLeft + ",";
  if (marginTop != "")
    param += "top=" + marginTop + ",";
  param += "width=" + sizeWidth + ",height=" + sizeHeight;
  if (scrollbars == "T")
    param += ",scrollbars=yes";

  return param;
}

// ·¹ÀÌ¾î ´Ý°í ÆäÀÌÁö ÀÌµ¿
function goNClose(popId,url){
	tf = document.clickFrm;
	tf.seq.value = popId;
	tf.url.value = url;

	closePopup(popId);
	tf.action = "/common/popLayer/clickChk.asp"
	tf.submit();
}


// µå·¡±×ÀÌµ¿
var vidPaneID;//¿©·¯°³ÀÌ±â ¶§¹®¿¡ ÇöÀç²¨ ¼¼ÆÃ
function moveHandler(e){
  if (e == null) { e = window.event }
  if (e.button<=1&&dragOK){
	 savedTarget.style.left=e.clientX-dragXoffset+'px';
	 savedTarget.style.top=e.clientY-dragYoffset+'px';
	 return false;
  }
}
function cleanup(e) {
  document.onmousemove=null;
  document.onmouseup=null;
  savedTarget.style.cursor=orgCursor;
  dragOK=false;
}
function dragHandler(e){
  var htype='-moz-grabbing';
  if (e == null) { e = window.event; htype='move';}
  var target = e.target != null ? e.target : e.srcElement;
  orgCursor=target.style.cursor;
  //alert(target);
  target = vidPaneID;
  //alert(target.className);
 if (vidPaneID && vidPaneID.className=="vidFrame") {
	 savedTarget=target;
	 target.style.cursor=htype;
	 dragOK=true;
	 dragXoffset=e.clientX-parseInt(vidPaneID.style.left);
	 dragYoffset=e.clientY-parseInt(vidPaneID.style.top);
	 document.onmousemove=moveHandler;
	 document.onmouseup=cleanup;
	 return false;
  }
}
document.onmousedown=dragHandler;

var savedTarget=null; // The target layer (effectively vidPane)
var orgCursor=null;   // The original Cursor (mouse) Style so we can restore it
var dragOK=false;     // True if we're allowed to move the element under mouse
var dragXoffset=0;    // How much we've moved the element on the horozontal
var dragYoffset=0;    // How much we've moved the element on the verticle


// Å¬¸¯ Ã³¸® ·¹ÀÌ¾î
//document.write("<div style=\"display:none\"><form name=\"clickFrm\" method=\"post\"><input type=\"hidden\" name=\"seq\"><input type=\"hidden\" name=\"url\"></form></div>");



// ·¹ÀÌ¾î ÆË¾÷ ´Ý±â
function closePopup(popId)
{
    var todayDate = new Date();

	//Ã¼Å© ¹Ú½º ´ÙÀ½¿¡ ¿­Áö ¾ÊÀº °Ë»ç
	if(document.getElementById("closeCheck_" + popId).checked == true){
		todayDate.setDate( todayDate.getDate() + 1 );
		setCookie("popup_" + popId,"done",todayDate);
	}
	//·¹ÀÌ¾î ´Ý±â
	document.getElementById("popup_" + popId).style.display = "none";

}


// ·¹ÀÌ¾î ÆË¾÷ ¶ç¿ì±â
function AppendPopup(popId, left, top, width, height, content, autoClose,alignCenter,valignCenter,bottom,title)
{
	//ÄíÅ° °Ë»ç
	if(getCookie("popup_" + popId) == "done"){return;}


	tags = document.createElement("DIV");
	tags.id = "popup_" + popId;
	tags.onmouseover = function(){
		vidPaneID = document.getElementById("popup_" + popId);
	}
	tags.onmouseout = function(){
		vidPaneID = null;
	}
	tags.className = "vidFrame";
	tags.setAttribute=("class","vidFrame");
    //tags.style.display = "block";
	tags.style.cursor = "move";

	tags.style.position = "absolute";

	if(alignCenter == "T")left = document.body.clientWidth / 2 - left / 2;
	if(valignCenter == "T")top = document.body.clientHeight / 2 - top / 2;

	width = parseInt(width);

	tags.style.left = left + "px";
	tags.style.top = top + "px";
	tags.style.width = width + "px";
	tags.style.height = height + "px";
	//tags.style.width = 315 + "px";
	//tags.style.height = 415 + "px";
	//tags.style.filter = "dropshadow(color=#cccccc, offx=3, offy=3, positive=1)";
	tags.style.filter = "shadow(color=silver,direction=135 strength=4)";
	//tags.innerHTML = content + bottom;

	//·¹ÀÌ¾î ÆË¾÷Àº °¡·Î »çÀÌÁî Áõ°¡ Ã³¸®
	Lwidth = width;
	Lheight = height;

	//div½ºÆ®¸µ
	var div_tag='<div id="popup_' + popId + '" onmouseover="vidPaneID=document.getElementById(\'popup_' + popId + '\')" onmouseout="vidPaneID=null;" class="vidFrame" style="cussor:move;position:absolute;left:' + left + ';top:' + top + ';with:' + width + 'px;height:' + height + 'px">';
	//alert(div_tag);


	tags.innerHTML = '<table border="0" cellspacing="0" cellpadding="0"> <tr> <td ><table width="' + width + 'px" border="0" cellspacing="0" cellpadding="0"> <tr> </tr> <tr> <td width="' + width + 'px"><table width="100%" height="30" border="0" cellpadding="0" cellspacing="0"> <tr> <td background="/common/images/t_04.gif" width="100%" ><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3" width="100%" ><img src="/common/images/1.gif" width="8" height="8"></td> </tr> <tr> <td width="12">&nbsp;</td> <td width="90%" style="color: #FFFFFF; font-weight: bold; "><font color="#666666">' + title + '</font></td> <td width="20"><a href="javascript:closePopup(\'' + popId + '\');void(0);"><img src="/common/images/btn_x.gif" width="13" height="13" border=0></a></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td><table width=100% height=100% border="0" cellpadding="0" cellspacing="0"> <tr> <td background="/common/images/j_02.gif"><table width=100% height=100% border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td>&nbsp;</td> <td  align="center"><!--³»¿ës-->' + content + '<!--³»¿ëe--></td> <td>&nbsp;</td> </tr> </table></td> </tr> </table></td></tr> <tr><td ><table width="100%" height="32" border="0" cellpadding="0" cellspacing="0"> <tr> <td><table width="100%" height="32" border="0" cellpadding="0" cellspacing="0"> <tr> <td background="/common/images/b_02.gif" width="100%" ><table width="100%" height="20" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="20" style="padding-left:10pt"> <input type="checkbox" name="closeCheck_' + popId + '" value="" ></td><td style="color: #FFFFFF;padding-top:3pt"><font color="#666666" face="±¼¸², µ¸¿ò">¿À´Ã ÀÌÃ¢À» ¿­Áö ¾ÊÀ½ </font> </td> <td width="66" style="padding-right:10pt"><div align="right"><a href="javascript:closePopup(\'' + popId + '\');void(0);"><img src="/common/images/btn_close.gif" width="39" height="9" border="0" align="absmiddle" ></a></div></td> </tr> </table></td> </tr> </table></td> </tr> <tr> </td> </tr> </table></td> </tr> </table>';


	document.body.appendChild(tags);
	setTimeout("closePopup('" + popId + "')", autoClose);
}
