var obName;

function loadurl(dest,obNameInp) {
	try {
		// Moz supports XMLHttpRequest. IE uses ActiveX.
		// browser detction is bad. object detection works for any browser
		xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e) {
		// browser doesn't support ajax. handle however you want
	}
	obName=obNameInp;
	// the xmlhttp object triggers an event everytime the status changes
	// triggered() function handles the events
	xmlhttp.onreadystatechange = triggered;
	// open takes in the HTTP method and url.
	xmlhttp.open("GET", dest);
	// send the request. if this is a POST request we would have
	// sent post variables: send("name=aleem&gender=male)
	// Moz is fine with just send(); but
	// IE expects a value here, hence we do send(null);
	xmlhttp.send(null);
}

function triggered() {
	// if the readyState code is 4 (Completed)
	// and http status is 200 (OK) we go ahead and get the responseText
	// other readyState codes:
	// 0=Uninitialised 1=Loading 2=Loaded 3=Interactive
	
	if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
		// xmlhttp.responseText object contains the response.
		document.getElementById(obName).innerHTML = xmlhttp.responseText;
	}			
	if ((xmlhttp.readyState <4) ) {
			document.getElementById(obName).innerHTML = '<img src="/public/images/graph/site/loading.gif" hsize=32> loading...';
	}
	
}



//wsparcie dla wyskakujacych divow
var timer;
var divx;
var divy;
var decalx;
var decaly;
var contenerw;
var contenerh;
var contenersl;
var contenerst;
var currentDivDetail;

function startDetail(ladiv,event){

	if (document.getElementById(ladiv) == null) return;

	var td_info = ladiv.replace("div_info","td_info");
	if(document.getElementById(td_info).innerHTML == "" || document.getElementById(td_info).innerHTML == "VIDE") return;
	
	stopDetail(ladiv);

	currentevent = event;


	var contener = document.getElementById('content');

	if (contener == null) {
		contener = document.body;
		decalx = 0;
		decaly = 0;
	}else {
		decalx = 168;
		decaly = 110;
	}

	divx = decalx + currentevent.clientX + contener.scrollLeft + 15;
	divy = decaly + currentevent.clientY + contener.scrollTop + 15;

	contenerw = contener.clientWidth;
	contenerh = contener.clientHeight;
	contenersl = contener.scrollLeft;
	contenerst = contener.scrollTop;

	timer = setTimeout("pokazSzczegoly('"+ladiv+"')",100);
}

function stopDetail(ladiv){

 	if (document.getElementById(ladiv) == null) return;
	if (timer != null){
		clearTimeout(timer);
	}
	var d = document.getElementById(ladiv);
	d.style.display="none";
}

function o_over(o){if (typeof(o.style) != 'undefined') o.style.backgroundColor = '#F0F0F0';}
function o_move(o){}
function o_out(o){if (typeof(o.style) != 'undefined') o.style.backgroundColor = '';}

function pokazSzczegoly(ladiv){

	var d = document.getElementById(ladiv);

	d.style.left = divx;
	d.style.top = divy;
	d.style.display="inline";
	d.style.background = "#ff00ff";
	
document.getElementById('info').innerHTML = "loading..."+divx+"  "+divy;
	
	if( (divx - contenersl + d.clientWidth) > contenerw ) d.style.left = contenerw - d.clientWidth + contenersl;
	if( (divy - contenerst + d.clientHeight) > contenerh ) d.style.top = contenerh - d.clientHeight + contenerst;
}



