﻿var last_opis=-1;
var xmlDoc

function printOpisJak(i){
  if(i!=last_opis){
	document.getElementById("jak_content"+i).innerHTML=xmlDoc.getElementsByTagName("qa")[i].childNodes[1].childNodes[0].data;
	if(last_opis!=-1){
	  document.getElementById("jak_content"+last_opis).innerHTML="";
	}
	last_opis=i;
  }
}

function jak(){ 
  
var xmlHttp=GetXmlHttpObject();
xmlHttp.onreadystatechange=function(){
	if (xmlHttp.readyState==4){
	if (xmlHttp.status == 200){
		xmlDoc=xmlHttp.responseXML;
		
		var r="<table cellspacing=\"0\" id=\"jak\" cellpadding=\"0\" border=\"0\"><tbody>";
		for(var i=0;i<xmlDoc.getElementsByTagName("qa").length;i++){
			r+="<tr><td class=\"jak\" id=\"jak_title"+i+"\"><a class=\"jak\" id=\"jak_a_title"+i+"\" onClick=\"printOpisJak("+i+");\" href=\"#\">";
			r+=xmlDoc.getElementsByTagName("qa")[i].childNodes[0].childNodes[0].nodeValue+"</a></td></tr>";
			r+="<tr><td class=\"jak_content\" id=\"jak_content"+i+"\"></td></tr>";
		}
		r+="</tbody></table>";
		document.getElementById("jak").innerHTML=r;
		clearTimeout(t);
	}else{
		alert('There was a problem with the request.');
	}
	}
};
xmlHttp.open("GET","jak.xml",true);
xmlHttp.send(null);
var t=setTimeout('jak()',500);
}
