var IE5=(document.getElementById && document.all)? true: false;
var W3C=(document.getElementById)? true: false;
var currIDb=null, currIDs=null, xoff=0, yoff=0; zctr=0; totz=0;

function trackmouse(evt){
  if((currIDb!=null) && (currIDs!=null)){
    var x=(IE5)? event.clientX+document.body.scrollLeft : evt.pageX;
    var y=(IE5)? event.clientY+document.body.scrollTop : evt.pageY;
    currIDb.style.left=x+xoff+'px';
    currIDs.style.left=x+xoff+10+'px';
    currIDb.style.top=y+yoff+'px';
    currIDs.style.top=y+yoff+10+'px';
    return false;
  }
}

function stopdrag(){
  currIDb=null;
  currIDs=null;
  NS6bugfix();
}

function grab_id(evt){
  xoff=parseInt(this.IDb.style.left)-((IE5)? event.clientX+document.body.scrollLeft : evt.pageX);
  yoff=parseInt(this.IDb.style.top)-((IE5)? event.clientY+document.body.scrollTop : evt.pageY);
  currIDb=this.IDb;
  currIDs=this.IDs;
}

function NS6bugfix(){
  if(!IE5){
    self.resizeBy(0,1);
    self.resizeBy(0,-1);
  }
}

function incrzindex(){
  zctr=zctr+2;
  this.subb.style.zIndex=zctr;
  this.subs.style.zIndex=zctr-1;
}

function createPopup(id, title, width, height, x, y, isdraggable, boxcolor, barcolor, shadowcolor, text, textcolor, textptsize, textfamily){
  if(W3C){
    zctr+=2;
    totz=zctr;
    var txt='';
   txt+='<div id="'+id+'_s" style="position:absolute; left:'+(x+7)+'px; top:'+(y+7)+'px; width:'+width+'px; height:'+height+'px; background-color:'+shadowcolor+'; filter:alpha(opacity=0); visibility:visible"> </div>';
    /* ÇÏ´Ü¿¡ "¿À´ÃÇÏ·ç±×¸¸º¸±â" ÀÇ Å©±â¸¸Å­ height 30 px Áõ°¡½ÃÅ´ */
    txt+='<div id="'+id+'_b" style="border:outset '+barcolor+' 2px; position:absolute; left:'+x+'px; top:'+y+'px; width:'+width+'px; overflow:hidden; height:'+(height+30)+'px; background-color:'+boxcolor+'; visibility:visible">';
    /* ·¹ÀÌ¾î Ã¢À» ´ÝÀ» ¶§, "¿À´ÃÇÏ·ç±×¸¸º¸±â" Ã¼Å©¿©ºÎ¿¡ µû¶ó ÄíÅ° ÀúÀå½ÃÅ°±â.. */
    txt+='<div style="width:'+width+'px; height:16px; background-color:'+barcolor+'; padding:0px; border:1px"><table cellpadding="0" cellspacing="0" border="0" width="'+(IE5? width-4 : width)+'"><tr><td width="'+(width-20)+'"><div id="'+id+'_h" style="width:'+(width-20)+'px; height:14px; font: bold 12px Tahoma; cursor:move; color:'+textcolor+'">&nbsp;'+title+'</div></td><td align="right"></td></tr></table></div>';
    txt+='<div id="'+id+'_ov" width:'+width+'px; style="margin:5px; color:'+textcolor+'; font:'+textptsize+'pt '+textfamily+';">'+text+'</div>';
    /* ·¹ÀÌ¾î Ã¢¿¡ "¿À´ÃÇÏ·ç±×¸¸º¸±â" Ãß°¡ */
    txt+='<div align=right id="'+id+'_d" width:'+width+'px; style="color:'+textcolor+'; font:'+textptsize+'pt '+textfamily+';"><input type=checkbox id=showToday_'+id+'> ¿À´ÃÇÏ·ç±×¸¸º¸±â<a onmousedown="document.getElementById(\''+id+'_s\').style.display=\'none\'; document.getElementById(\''+id+'_b\').style.display=\'none\';showToday(document.getElementById(\'showToday_'+id+'\'));return false">&nbsp;<img src=/images/close_b.gif border=0 align=absmiddle style=cursor:pointer></a></div></div>';
    document.write(txt);
    this.IDh=document.getElementById(id+'_h');
    this.IDh.IDb=document.getElementById(id+'_b');
    this.IDh.IDs=document.getElementById(id+'_s');
    this.IDh.IDb.subs=this.IDh.IDs;
    this.IDh.IDb.subb=this.IDh.IDb;
    this.IDh.IDb.IDov=document.getElementById(id+'_ov');
    if(IE5){
      this.IDh.IDb.IDov.style.width=width-6;
      this.IDh.IDb.IDov.style.height=height-22;
  
     
    }else{
      this.IDh.IDs.style.MozOpacity=.5;
    }
    this.IDh.IDb.onmousedown=incrzindex;
    if(isdraggable){
      this.IDh.onmousedown=grab_id;
      this.IDh.onmouseup=stopdrag;
    }
    /* ÀúÀåµÈ ÄíÅ°ÀÇ °ª¿¡ µû¶ó Ã³À½ ÆäÀÌÁö ¶ç¿ï ¶§ º¸ÀÌÁö ¾Êµµ·Ï Ã³¸®. */
    if(document.cookie.indexOf('showToday_'+id+'=off') >= 0){
      document.getElementById('showToday_'+id).checked = true;
      this.IDh.IDs.style.display = 'none';
      this.IDh.IDb.style.display = 'none';
    }
  }
}

if(W3C)document.onmousemove=trackmouse;
if(!IE5 && W3C)window.onload=NS6bugfix;      
      
/* "¿À´ÃÇÏ·ç±×¸¸º¸±â" ÀÇ Ã¼Å©¿©ºÎ¿¡ µû¶ó ÄíÅ°¸¦ ÀúÀåÇÏ´Â ÇÔ¼ö */
function showToday(obj){
  if(obj.checked){
    var cur = new Date();
    cur.setHours(23);
    cur.setMinutes(59);
    cur.setSeconds(59);
    document.cookie = obj.id + "=off; expires=" + cur.toGMTString() + ";";
  }else{
    document.cookie = obj.id + "=;";
  }
}
