if (window.XMLHttpRequest) {
		requesttt = new XMLHttpRequest(); // Mozilla, Safari, Opera
	} else if (window.ActiveXObject) {
		try {
			requesttt = new ActiveXObject('Msxml2.XMLHTTP'); // IE 5
		} catch (e) {
			try {
				requesttt = new ActiveXObject('Microsoft.XMLHTTP'); // IE 6
			} catch (e) {}
		}
}

var ttid = null;

document.onmousemove = mausposition;

//Aktualisierung
if(window.setTimeout('tooltipAnfrage()', 1000)){
	tooltipAnfrage();
}

function tooltipAnfrage(){
	
	var wertett = "status=anfragebl";
	requesttt.open("POST", "letztesrennen.php5");
	requesttt.setRequestHeader("Pragma", "no-cache");
	requesttt.setRequestHeader("Cache-Control", "must-revalidate");
	requesttt.setRequestHeader("If-Modified-Since", document.lastModified);
	requesttt.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	requesttt.onreadystatechange = tooltipAusgabe;
	requesttt.send(wertett);
	
}

function tooltipAusgabe(){
	
	if(requesttt.readyState == 4){
		var daten = eval(requesttt.responseText);
		window.datenpaket = daten;
		document.getElementById(blid).innerHTML = sndformat(eval(requesttt.responseText));
	}	
	
}

function mausposition(e) {
  if (ttid != null) {
    var x = (document.all) ? window.event.x + ttid.offsetParent.scrollLeft : e.pageX;
    var y = (document.all) ? window.event.y + ttid.offsetParent.scrollTop  : e.pageY;
	if (y < 100) {
		ttid.style.left = (x + 20) + "px";
		ttid.style.top = (y + 20) + "px";
	}
	else if(y >= 100 && y <= 220){
		ttid.style.left = (x + 20) + "px";
		ttid.style.top = (y - 100) + "px";
	}
	else{
		ttid.style.left = (x + 20) + "px";
		ttid.style.top = (y - 170) + "px";
	}
	
  }
}

function zeigeTooltip(id){

	blid = id;
  	ttid = document.getElementById(id);
	ttid.style.display = "block"
	tooltipAusgabe();
	
}

function sndformat(sndfeld){
	if(blid == "Baden-W\u00fcrttemberg"){
		firstmen = 0;
		lastmen = 9;
	}
	if(blid == "Bayern"){
		firstmen = 10;
		lastmen = 19;
	}
	if(blid == "Berlin"){
		firstmen = 20;
		lastmen = 29;
	}
	if(blid == "Brandenburg"){
		firstmen = 30;
		lastmen = 39;
	}
	if(blid == "Hessen"){
		firstmen = 40;
		lastmen = 49;
	}
	if(blid == "Mecklenburg-Vorpommern"){
		firstmen = 50;
		lastmen = 59;
	}
	if(blid == "Niedersachsen"){
		firstmen = 60;
		lastmen = 69;
	}
	if(blid == "Nordrhein-Westfalen"){
		firstmen = 70;
		lastmen = 79;
	}
	if(blid == "Rheinland-Pfalz"){
		firstmen = 80;
		lastmen = 89;
	}
	if(blid == "Sachsen"){
		firstmen = 90;
		lastmen = 99;
	}
	if(blid == "Sachsen-Anhalt"){
		firstmen = 100;
		lastmen = 109;
	}
	if(blid == "Schleswig-Holstein"){
		firstmen = 110;
		lastmen = 119;
	}
	if(blid == "Th\u00fcringen"){
		firstmen = 120;
		lastmen = 129;	
	}
	var ausgabebl = "<table border='0' cellpadding='0' cellspacing='0' class='tooltipcss'>";
	ausgabebl += 
	"<tr class='bold'><td style='border-bottom:1px solid'>Rang</td><td style='border-bottom:1px solid'>Fahrer</td><td style='border-bottom:1px solid'>Zeit</td></tr>";
	for(i=firstmen;i<=lastmen;i++){
		if(i % 2){ var bg = "background-color:#f7f7f7;"; }else{ var bg = ""; }
		if(sndfeld[i][1] == "Strafzeit"){
			var textcolor = "color:red;"
		}
		else{
			var textcolor = "color:black;"
		}
		//if(sndfeld[i][2] == "00:00,"){ var ttinhalt = "<i><font color='red'>Ausstehend</font></i>";}else{ var ttinhalt = feld[i][2]; }
		ausgabebl += 
		"<tr style='height:18px;"+bg+"'>"+
		"<td style='text-align:center; border-bottom:1px dotted #cbcbcb;'>"+sndfeld[i][0]+"</td>"+
		"<td style='width:100px; padding-left:5px; border-bottom:1px dotted #cbcbcb;'>"+sndfeld[i][1]+"</td>"+
		"<td style='"+textcolor+"  border-bottom:1px dotted #cbcbcb;'>"+sndfeld[i][2]+"</td>"+
		"</tr>";
	}
	ausgabebl += "</table>";
	return ausgabebl; 
}


function versteckeTooltip(){
	
	ttid.style.display = "none";

}