// JavaScript Document

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this header

// Modified 2005 by Paul Gorodyansky (http://RusWin.net)
// to allow defining initial coordinates
// (originally they were hard-coded in HTML's <div statement)
// so if a call button is down below the page then one could not even
// see that the layer has appeared!

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;

isHot=false;

var offsetx = null;

function ddInit(e){

  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.right);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){
  if (!ddEnabled) return;
  Newoffsetx=isIE ? event.clientX : e.clientX;
  whichDog.style.right= nowX-(Newoffsetx-offsetx); 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  //if (Br == "IE" || Opera)
  //    txtControl.focus();
  return false;  
}

function hideMe(){
  if (isIE||isNN)
      whichDog.style.visibility="hidden";
}

function showMe(){
  if (isIE||isNN)
  {
    if ( offsetx == null)
    {
     whichDog.style.right =
      (0 - ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft )) + 'px';
     whichDog.style.top =
      (0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px';
    }  
    whichDog.style.visibility="visible";
  }
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");

