var Ypos;
function GdAjax(url, metoda, funkcija, formData){
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
		    http_request.overrideMimeType('text/xml');
		// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			errLog("Msxml2.XMLHTTP"+e.description);
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {"Microsoft.XMLHTTP"+errLog(e.description);}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = eval(funkcija);
	if(metoda!=""){
		http_request.open('POST', url, true);
		http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		http_request.send(formData);
	}else{
		http_request.open('GET', url, true);
		http_request.send(null);
	}
}
//funkcija ce dohvatiti podatke za izlagače i poslati ih na prikaz
//	funkcija će prikazati izlagače
function showIzlagace(){
     if (http_request.readyState == 4) {
      if (http_request.status == 200) {
      	var res = http_request.responseText.split("***");
			if (res[0]!=""){
				$("_divInfo").setStyle('display','block');
				$("_divInfo").empty().innerHTML=res[0];
				//if ($("pregled")) window.location.href='#pregled';
				$("_divInfo").setStyle('top',Ypos);
			}
    	}else{
       		alert('Imamo malih problema sa serverom, molimo probajte kasnije. (' + http_request.status + ').');
      }
   }
}
function goGetIzlagace(id,sajam, id2){
	GdAjax("ajax.aspx?rqst=getIzlagace&id=" + id + "&sajam=" + sajam + "&id2=" + id2,"","showIzlagace");
}
window.addEvent('domready',function(){
	$$("a.izvLink").each(function(el){
		el.addEvent('click',function(ele){
			Ypos = ele.page.y+10;
		});
	})
	$$("div.togglerDiv").each(function(el){
		el.addEvent('click',function(ele){
			Ypos = ele.page.y+10;
		});
	})
});
