/**
 * displays and hides floating layer
 * populates floating layer content using ajax
 */

var show = false;
var returns = Object();
var currentUrl = "";
var mouseOver = "";
var lock = false;

function showfloater(url, lockdiv){
	mouseOver = url;
	if(lockdiv) lock = true;
	if(returns[url] != undefined){
		show=true;
		t=setTimeout("onfloater('"+url+"')",500);
	}else{
		t=setTimeout("showfloater('"+url+"')",500);
	}
}

function loadfloater(url){
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = function()
	{
		if(xmlhttp.readyState == 4){
			returns[url] = xmlhttp.responseText;
			//alert(returns[url]);
		}
	} 
	xmlhttp.send(null);
}

function hidefloater(){
	mouseOver = "";
	if(show && !lock){
		show=false;
		t=setTimeout("offfloater()",700);
	}
}

function onfloater(url){
	if(show && url == mouseOver){
		document.getElementById('floater').style.display="block";
		document.getElementById('floater').style.top = (posTop() + 20) + "px";
		document.getElementById('floater').style.left = "220px";
		if(url != currentUrl){
			var right = document.getElementById('floater');
			right.innerHTML = "";
			right.innerHTML = returns[url];
			currentUrl = url;
		}
	}
	//alert(returns[url]);
}

function offfloater(){
	if(!show){
		document.getElementById('floater').style.display="none";
		document.getElementById('floater').style.left = "-5000px";
		lock = false;
	}
}

function savefloater(){
	show=true;
}

// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} 
function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 
function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} 
function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} 
function posRight() {return posLeft()+pageWidth();} 
function posBottom() {return posTop()+pageHeight();}

