var offsetx = 10;
var offsety = 10;

mouseLocation = new Point(-500,-500);

var IE = false;
if (navigator.appName == "Microsoft Internet Explorer") {
	IE = true;
}

function Point(x,y) {
	this.x = x;
	this.y = y;
}
	
function getMouseLoc(e) {
	if (IE) {
		mouseLocation.x = event.x;
		mouseLocation.y = event.y + document.documentElement.scrollTop;
	} else {
		mouseLocation.x = e.pageX;
		mouseLocation.y = e.pageY;
	}
	return true;
}

function moveLayer(layerName, event) {
	var obj;
	getMouseLoc(event);
	if(((findObj(layerName))!= null) && IE) {
		obj = document.getElementById(layerName).style;
		if (mouseLocation.x > 710) {
			obj.pixelRight = document.documentElement.offsetWidth - mouseLocation.x + offsetx;
		} else {
			obj.pixelLeft = mouseLocation.x + offsetx;
		}
		obj.pixelTop = mouseLocation.y + offsety;
		showLayer(layerName);
	} else {
	    obj = document.getElementById(layerName);
        
        
		if (mouseLocation.x > 710) {
			obj.style.right = (window.innerWidth - mouseLocation.x - offsetx) + 'px';
		} else {
			obj.style.left = (mouseLocation.x + offsetx) + 'px';
		}
		obj.style.top = (mouseLocation.y + offsety) + 'px';
		showLayer(layerName);
	}
}

function showLayer(layerName) {    
    
	if (document.getElementById) {
	// this is the way the standards work
	document.getElementById(layerName).style.display = "block";
	document.getElementById(layerName).style.visibility = "visible";
	}
	else if (document.all) {
	// this is the way old msie versions work
	document.getElementById(layerName).style.display = "block";
	document.all[layerName].style.visibility = "visible";
	}
	else if (document.layers) {	
    // this is the way nn4 works        
	document.getElementById(layerName).style.display = "block";    
	document.all[layerName].style.visibility = "visible";    
    }
    
}

function hideLayer(layerName) {
	if (document.getElementById) {
	// this is the way the standards work
	document.getElementById(layerName).style.visibility = "hidden";
	}
	else if (document.all) {
	// this is the way old msie versions work
	document.all[layerName].style.visibility = "hidden";
	}
	else if (document.layers) {
	// this is the way nn4 works
	document.layers[layerName].visibility = "hidden";
	}
}

function writeConsole(content) {
 top.consoleRef=window.open('','myconsole',
  'width=350,height=250'
   +',menubar=0'
   +',toolbar=1'
   +',status=0'
   +',scrollbars=1'
   +',resizable=1')
 top.consoleRef.document.writeln(
  '<html><head><title>Console</title></head>'
   +'<body bgcolor=white onLoad="self.focus()">'
   +content
   +'</body></html>'
 )
 top.consoleRef.document.close()
}
