// ÀÌ ºÎºÐÀ» ÀÎÄð¸£µå ÆÄÀÏ·Î »©³»¸é ¼Ò½º°¡ ÇÑ°á °£ÆíÇØ Áö°ÚÁÒ.
var checkZIndex = true;

var dragobject = null;
var tx;
var ty;

var ie5 = document.all != null && document.getElementsByTagName != null;

function getReal(el) {
 temp = el;

 while ((temp != null) && (temp.tagName != "BODY")) {
  if ((temp.className == "moveme") || (temp.className == "handle")){
   el = temp;
   return el;
  }
  temp = temp.parentElement;
 }
 return el;
}


function moveme_onmousedown() {
 el = getReal(window.event.srcElement)

 if (el.className == "moveme" || el.className == "handle") {
  if (el.className == "handle") {
   tmp = el.getAttribute("handlefor");
   if (tmp == null) {
    dragobject = null;
    return;
   }
   else
    dragobject = document.all[tmp];
  }
  else
   dragobject = el;

  if (checkZIndex) makeOnTop(dragobject);

  ty = window.event.clientY - getTopPos(dragobject);
  tx = window.event.clientX - getLeftPos(dragobject);

  window.event.returnValue = false;
  window.event.cancelBubble = true;
  dragobject.filters.alpha.opacity=100;
 }
 else {
  dragobject = null;
 }
}

function moveme_onmouseup() {
 if(dragobject) {
  dragobject.filters.alpha.opacity=100;
  dragobject = null;
 }
}


function moveme_onmousemove() {
 if (dragobject) {
  if (window.event.clientX >= 0 && window.event.clientY >= 0) {
   dragobject.style.left = window.event.clientX - tx + "px";
   dragobject.style.top = window.event.clientY - ty + "px";
   dragobject.filters.alpha.opacity=80;
  }
  window.event.returnValue = false;
 }
}

function getLeftPos(el) {
 if (ie5) {
  if (el.currentStyle.left == "auto")
   return 0;
  else
   return parseInt(el.currentStyle.left);
 }
 else {
  return el.style.pixelLeft;
 }
}

function getTopPos(el) {
 if (ie5) {
  if (el.currentStyle.top == "auto")
   return 0;
  else
   return parseInt(el.currentStyle.top);
 }
 else {
  return el.style.pixelTop;
 }
}

function makeOnTop(el) {
 var daiz;
 var max = 0;
 var da = document.all;

 for (var i=0; i<da.length; i++) {
  daiz = da[i].style.zIndex;
  if (daiz != "" && daiz > max)
   max = daiz;
 }

 el.style.zIndex = max + 1;
}

if (document.all) { //Over IE4 
 document.onmousedown = moveme_onmousedown;
 document.onmouseup = moveme_onmouseup;
 document.onmousemove = moveme_onmousemove;
}


/////////////// PopUp  //////////////////

function getCookie(name) {
   var from_idx = document.cookie.indexOf(name+'=');
   if (from_idx != -1) {
	  from_idx += name.length + 1;
	  to_idx = document.cookie.indexOf(';', from_idx);

	  if (to_idx == -1) {
			to_idx = document.cookie.length;
	  }
	  return unescape(document.cookie.substring(from_idx, to_idx));
   }
}

function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}


// SetCookie
 function setCookie(name, value, expiredays) 
 { 
	var todayDate = new Date(); 
	todayDate.setDate( todayDate.getDate() + expiredays ); 
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
 } 

function notice_closeWin(aa) 
{ 
	if(aa =="1" ){
		if (document.form1.cbox1.checked) setCookie("woori_main1", "done" , 1); 
		document.getElementById("popDiv1").style.display = "none"
	}
	if(aa =="2" ){
		if (document.form2.cbox2.checked) setCookie("woori_main2", "done" , 1); 
		document.getElementById("popDiv2").style.display = "none"
	}
 }   
      
/////////////// PopUp  //////////////////
