var x=-1;
var y=-1;
var currentParent=null;
var currentWin=null;
var isShown='false';

function showWindow (parentId, dx, dy) {
	if ((isShown == 'true') && (currentParent != null)){
		closeSlideWindow(currentParent);
		if (currentParent == parentId) {
			return;
		}
	}
	if (isShown =='false') {
	toggleBox(parentId, 1, dx, dy)
	isShown='true';
	currentParent = parentId;
	}
 }
 
function closeSlideWindow (parentId) {

if (isShown == 'true') {
	toggleBox(parentId, 0, 0, 0)
	isShown='false';
	}
 }
 
 function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer" || b=="Opera") this.b = "ie" 
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	if (this.ie5) this.v = 5
	this.min = (this.ns||this.ie)
}

// automatically create the "is" object
var is = new BrowserCheck()

	var currentX=-1;
	var currentY=-1;

	function init() {
		document.onmousedown = mouseDown
		document.onmousemove = mouseMove
		document.onmouseup = mouseUp
		if (is.ns4) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
	}
	function alertCoord(e) {
	  if( !e ) {
		if( window.event ) {
		  //Internet Explorer
		  e = window.event;
		} else {
		  //total failure, we have no way of referencing the event
		  return;
		}
	  }
	  if( typeof( e.pageX ) == 'number' ) {
		//most browsers
		var xcoord = e.pageX;
		var ycoord = e.pageY;
	  } else if( typeof( e.clientX ) == 'number' ) {
		//Internet Explorer and older browsers
		//other browsers provide this, but follow the pageX/Y branch
		var xcoord = e.clientX;
		var ycoord = e.clientY;
		var badOldBrowser = ( window.navigator.userAgent.indexOf( 'Opera' ) + 1 ) ||
		 ( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ||
		 ( navigator.vendor == 'KDE' )
		if( !badOldBrowser ) {
		  if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//IE 4, 5 & 6 (in non-standards compliant mode)
			xcoord += document.body.scrollLeft;
			ycoord += document.body.scrollTop;
		  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE 6 (in standards compliant mode)
			xcoord += document.documentElement.scrollLeft;
			ycoord += document.documentElement.scrollTop;
		  }
		}
	  } else {
		//total failure, we have no way of obtaining the mouse coordinates
		return;
	  }
	  x=xcoord;
	  y=ycoord;
	}	
	function mouseDown(e) {
		if ((is.ns && e.which!=1) || (is.ie && event.button!=1)) return true
		 x = (is.ns)? e.pageX : event.x+document.body.scrollLeft
		 y = (is.ns)? e.pageY : event.y+document.body.scrollTop
		currentX= x;
		currentY= y;
		alertCoord(e);
		return true
	}
	function mouseMove(e) {
		 x = (is.ns)? e.pageX : event.x+document.body.scrollLeft
		 y = (is.ns)? e.pageY : event.y+document.body.scrollTop
		 alertCoord(e);
		return true
	}
	function mouseUp(e) {
		 x = (is.ns)? e.pageX : event.x+document.body.scrollLeft
		 y = (is.ns)? e.pageY : event.y+document.body.scrollTop
		alertCoord(e);
		return true
	}
	 
	
	function returnObjById( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

		function toggleBox(szDivID, iState, deltaX, deltaY) // 1 visible, 0 hidden
	{
			var xoffSet=x-deltaX;
			var yoffSet=y-deltaY;
		if(document.layers)	   //NN4+
		{
		if (iState==1) {
		   document.layers[szDivID].left = (document.documentElement.scrollLeft+xoffSet)+'px';
		   document.layers[szDivID].top  = (document.documentElement.scrollTop +yoffSet)+'px';
		 }
		   document.layers[szDivID].visibility = iState ? "show" : "hide";
		   document.layers[szDivID].display = iState ? "block" : "none";

		}
		else if(document.getElementById)	  //gecko(NN6) + IE 5+
		{
		var obj = document.getElementById(szDivID);
		
		if (iState==1) {
			obj.style.left = (document.documentElement.scrollLeft+xoffSet)+'px';
			obj.style.top  = (document.documentElement.scrollTop +yoffSet)+'px';
			//alert(obj.style.left+" "+obj.style.top);
		}
			obj.style.visibility = iState ? "visible" : "hidden";
			obj.style.display = iState ? "block" : "none";
		}
		else if(document.all)	// IE 4
		{
		if (iState==1) {
			document.all[szDivID].style.left = (document.documentElement.scrollLeft+xoffSet)+'px';
			document.all[szDivID].style.top  = (document.documentElement.scrollTop +yoffSet)+'px';
		}
			document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
			document.all[szDivID].style.display = iState ? "block" : "none";

		}
	}
	



