var xhr = false;
var grad1;
var browserName=navigator.appName; // Get the Browser Name

if(browserName=="Microsoft Internet Explorer") // For IE
{
	window.onload=function () {prepareForm();}; // Call init function in IE
}
else
{
	if (document.addEventListener) // For Firefox
	{
		document.addEventListener("DOMContentLoaded", prepareForm, true); // Call init function in Firefox
	}
} 

function prepareForm() {
	
	if(document.getElementById("odabraniGrad1")){
		this.grad1=document.getElementById("odabraniGrad1").options[document.getElementById("odabraniGrad1").selectedIndex].value;
	}
	else{
		this.grad1="Beograd";
	}

	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else {
		if (window.ActiveXObject) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) { }
		}
	}

	if (xhr) {		
		xhr.onreadystatechange = function(){ setDataArray();};
		xhr.open("GET", "index2.php?grad1="+grad1, true);
		xhr.send(null);
	}
	else {
		alert("Sorry, but I couldn't create an XMLHttpRequest");
	}

}

function setDataArray(){
	if (xhr.readyState == 4) {
		if (xhr.status == 200) {
			if (xhr.responseText) {
				document.getElementById("container").innerHTML=xhr.responseText;
				
			}
		}
	}
}

