var isIE = document.all;
var isNN=!document.all&&document.getElementById;
var isN4=document.layers;
var isActive=false;
var MoveEnabled = false;
var helpState=false;

function ToggleHelp()
{
	helpState = !helpState;
	ToggleFloatingLayer('FloatingLayer',helpState)	
}

function ToggleFloatingLayer(DivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
	   alert("Top:" + document.layers[DivID].top);
       document.layers[DivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(DivID);
        obj.style.display = iState ? "block" : "none";
    }
    else if(document.all)	// IE 4
    {
        document.all[DivID].style.visibility = iState ? "visible" : "hidden";
    }
}

function MoveInit(e){
  topOne=isIE ? "BODY" : "HTML";
  whichOne=isIE ? document.all.FloatingLayer : document.getElementById("FloatingLayer");  
  ActiveOne=isIE ? event.srcElement : e.target;  
  
  
	if (ActiveOne.id != "")
	{
		while (ActiveOne.id!="titleBar"&&ActiveOne.tagName!=topOne) {
			ActiveOne=isIE ? ActiveOne.parentElement : ActiveOne.parentNode;
		}  
  
		if (ActiveOne.id=="titleBar"){
		    offsetx=isIE ? event.clientX : e.clientX;
			offsety=isIE ? event.clientY : e.clientY;
			nowX=parseInt(whichOne.offsetLeft);
			nowY=parseInt(whichOne.offsetTop);
			MoveEnabled=true;
			document.onmousemove=Move;
		}
  }
}

function Move(e){
  if (!MoveEnabled) 
	return;
	
  whichOne.style.left= (isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx) + 'px'; 
  whichOne.style.top= (isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety) + 'px';
  return false;  
}

function MoveN4(whatOne){
  if (!isN4) return;
  N4=eval(whatOne);
  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 (isActive){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

document.onmousedown=MoveInit;
document.onmouseup=Function("MoveEnabled=false");
