
var xmlhttp;

function showSubcategory(str, broj){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Browser does not support HTTP Request");
	  return;
	  }
	var url="./includes/subcategories.php";
	url=url+"?q="+str+broj;
	url=url+"&sid="/*+Math.random()*/;


	if(broj == 1)xmlhttp.onreadystatechange = stateChanged1;
	else if(broj == 2)xmlhttp.onreadystatechange = stateChanged2;
	else if(broj == 3)xmlhttp.onreadystatechange = stateChanged3;
	else if(broj == 4)xmlhttp.onreadystatechange = stateChanged4;
	else if(broj == 5)xmlhttp.onreadystatechange = stateChanged5;
		
	
	xmlhttp.open("GET",url,true);
	//alert ('subcategory'+broj);
	xmlhttp.send(null);
}



function stateChanged1(){
	// GDJE UPISATI ŠTO
	if (xmlhttp.readyState==4) document.getElementById("subcategory1").innerHTML=xmlhttp.responseText;
}
function stateChanged2(){
	// GDJE UPISATI ŠTO
	if (xmlhttp.readyState==4) document.getElementById("subcategory2").innerHTML=xmlhttp.responseText;
}
function stateChanged3(){
	// GDJE UPISATI ŠTO
	if (xmlhttp.readyState==4) document.getElementById("subcategory3").innerHTML=xmlhttp.responseText;
}
function stateChanged4(){
	// GDJE UPISATI ŠTO
	if (xmlhttp.readyState==4) document.getElementById("subcategory4").innerHTML=xmlhttp.responseText;
}
function stateChanged5(){
	// GDJE UPISATI ŠTO
	if (xmlhttp.readyState==4) document.getElementById("subcategory5").innerHTML=xmlhttp.responseText;
}


function GetXmlHttpObject(){

	if (window.XMLHttpRequest) {
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  return new XMLHttpRequest();
	}
	if (window.ActiveXObject){
	  // code for IE6, IE5
	  return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}

