isIE=document.all;
isNN=!document.all&&document.getElementById;
ddEnabled=false;
min_y = 115;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id.indexOf( "titleBar")!=0 && hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id.indexOf( "titleBar") == 0 ){
    name = hotDog.id.substr( 8);
    whichDog=isIE ? document.all[name] : document.getElementById(name);
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
  }
}
function dd(e){
  if (!ddEnabled) return;
  left_=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  top_=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  if ( top_ < min_y ) top_ = min_y;
  whichDog.style.left=left_;
  whichDog.style.top=top_;
  return false;  
}
try{
	document.onmousedown=ddInit;
	document.onmouseup=Function("ddEnabled=false");
	document.onmousemove=dd;
} catch( e){}



function PopLayer2_hideMe(){
  this.Layer.innerHTML = "";
  if (isIE||isNN) this.Layer.style.visibility="hidden";
  ddEnabled = false;
  this.open = false;
}
function PopLayer2_showMe(){
  if (isIE||isNN){
    c = str_replace( "$$content$$", this.content, this.header);
    c = str_replace( "$$title$$", this.title, c);
    c = str_replace( "$$name$$", this.name, c);
    c = str_replace( "$$width$$", this.width, c);
    c = str_replace( "$$align$$", this.align, c);
    c = str_replace( "$$bgcolor$$", this.bgcolor, c);
    this.Layer.innerHTML = c;
    this.Layer.style.visibility="visible";
    o = document.body;
    this.m_pos_y = isIE ? (o.scrollTop+o.clientHeight/2)-(this.Layer.clientHeight/2): (o.scrollTop+o.clientHeight/2)-(this.Layer.scrollHeight/2);
    this.m_pos_x = isIE ? (o.scrollLeft+o.clientWidth/2)-(this.Layer.clientWidth/2): (o.scrollLeft+o.clientWidth/2)-(this.Layer.scrollWidth/2);
    if ( this.m_pos_y < this.min_y ) this.m_pos_y = this.min_y;
    this.Layer.style.left = this.m_pos_x;
    this.Layer.style.top = this.m_pos_y;
    this.open = true;
  }
}
function PopLayer2_onScroll()
{
  offset_y = document.body.scrollTop - this.scrollPosition;
  this.scrollPosition = document.body.scrollTop;
  this_layer = document.getElementById( this.name);
  y = parseInt( this_layer.style.top);
  this_layer.style.top = (y+offset_y<this.min_y)?this.min_y:(y+offset_y);
}

function PopLayer2( name, title, content, header)
{
  //-------------------------------------
  //          Local Variables
  //-------------------------------------
  this.whichDog=false;
  this.content = content;
  this.name = name;
  this.title = title;
  this.min_y = 115;
  this.m_pos_y = 0;
  this.m_pos_x = 0;
  this.offsetx = 0;
  this.offsety = 0;
  this.width = 1;
  this.open = false;
  this.align = "center";
  this.bgcolor = "#FFFFFF";
  this.scrollPosition=document.body.scrollTop;
  if ( !header )
  {
    this.header = '\
    <table width="$$width$$" border="0" BGCOLOR="#007DBD" cellspacing="0" cellpadding="1">\
      <tr>\
        <td width="100%">\
          <table border="0" width="100%" cellspacing="0" cellpadding="3" height="36">\
            <tr>\
              <td ID="titleBar$$name$$" style="cursor:move" width="100%"><b class=normal style="color:#FFFFFF;cursor:move">$$title$$</b></td>\
              <td style="cursor:hand" valign="top"><a href="./" onClick="'+name+'_.hideMe();return false"><img src="./images/ico_close.gif" border=0></a></td>\
            </tr>\
            <tr>\
              <td width="100%" bgcolor="$$bgcolor$$" style="padding:4px" colspan="2">\
                 <table width="100%" border="0" cellpadding="1" cellspacing="1" valign=top>\
                   <tr>\
                     <td bgcolor="$$bgcolor$$" align=$$align$$>$$content$$</td>\
                   </tr>\
                 </table>\
              </td>\
            </tr>\
          </table>\
        </td>\
      </tr>\
    </table>\
    ';
  }
  else
  {
    this.header = header;
  }
  this.Layer = isIE ? document.all[name] : document.getElementById(name);
  //-------------------------------------
  //              Methods
  //-------------------------------------
  this.hideMe = PopLayer2_hideMe;
  this.showMe = PopLayer2_showMe;
  this.onScroll = PopLayer2_onScroll;
}