// JavaScript Document
var xmlhttp;
var row;
var oldrow;
var div;
var outstyle;

function showDetail(id, fid){
	if (row){
		row.style.display = "none";
	} 
		
	row = document.getElementById("row" + id);
	div = document.getElementById("rowdetail" + id);
	
	if (row == oldrow){
		oldrow = null;
		row.style.display = "none";
		return;
	}
	
	oldrow = row;
	
	if (!row || !div) return;
	
	if (row.style.display == "table-row")
	{
		row.style.display = "none";
		return;
	}
	
	row.style.display = "table-row";
	row.style.background = "#eaf5fd";
	div.innerHTML = (lang == "en")?"Loading detail...":"Nahrávám detail...";
	//alert(lang);
	var url = "../csav/get_flight.php?fplink=true&lang=" + lang + "&fid=" + fid;

	if (window.XMLHttpRequest) {
			  xmlhttp = new XMLHttpRequest();
			  xmlhttp.onreadystatechange = parseDetail;
			  xmlhttp.open("GET", url, true);
			  xmlhttp.send(null);
	}
	// AJAX code for IE
	else if (window.ActiveXObject)  {
			  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
					if (xmlhttp)
					{
							xmlhttp.onreadystatechange = parseDetail;
							xmlhttp.open("GET", url, true);
							xmlhttp.send();
					}
	  }
}

function parseDetail()
{
	if (xmlhttp.readyState == 4) {
	  // if "OK"
	  if (xmlhttp.status == 200) {
		div.innerHTML = xmlhttp.responseText;
	  }
	}
}