
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
DoIt=false;

function ddInit(e){
 TWD=isIE ? "BODY" : "HTML";
 TWD1=isIE ? document.all.thePopup : document.getElementById("thePopup");
 TWD2=isIE ? event.srcElement : e.target;
 while (TWD2.id!="titleBar"&&TWD2.tagName!=TWD){
   TWD2=isIE ? TWD2.parentElement : TWD2.parentNode;
 }
 if (TWD2.id=="titleBar"){
   offsetx=isIE ? event.clientX : e.clientX;
   offsety=isIE ? event.clientY : e.clientY;
   nowX=parseInt(TWD1.style.left);
   nowY=parseInt(TWD1.style.top);
   ddEnabled=true;
   document.onmousemove=dd;
 }
}

function dd(e){
  if (!ddEnabled) return;
  TWD1.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
  TWD1.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;
}

function ddN4(TWD3){
  if (!isN4) return;
  N4=eval(TWD3);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (DoIt){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) TWD1.style.visibility="hidden";
  else if (isN4) document.thePopup.visibility="hide";
}

function showMe(){
  if (isIE||isNN) TWD1.style.visibility="visible";
  else if (isN4) document.thePopup.visibility="show";
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");


//
// function to brighten and darken in between layer (layer 1)
// #layer1 { background-color: black;filter:alpha(opacity=85);position: absolute;width: 100%;height: 100%;visibility: hidden;z-index: 3;}
//
//

function darken() {
  var layerElement = document.getElementById("layer1");
  layerElement.style.visibility='visible';
}

function brighten() {
  var layerElement = document.getElementById("layer1");
  layerElement.style.visibility='hidden';
  layerElement.style.border=0;
}

function setPopup ( name, sourcefile, height_window ) {
  var layerElement = document.getElementById("popupName");
  layerElement.innerHTML = name;

  var layerElement = document.getElementById("popupContent");
  layerElement.innerHTML = "<IFRAME style='z-index:4;' width=100% height="+height_window+" SRC="+ sourcefile + " SCROLLING=No MARGINWIDTH=0 MARGINHEIGHT=0 FRAMEBORDER=No></IFRAME>";
}
