function startSearch () {
	trazi = document.getElementById("search").value
	ajaxCallback = displayResults;
	ajaxRequest("ajax/search.php?search="+trazi);
}

function displayResults () {
	response = ajaxreq.responseText;
	document.getElementById("centertext").innerHTML = response;
}

function enter_pressed(e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return false;
	return (keycode == 13);
}

function activePoll(id) {
	ajaxCallback = showActive;
	ajaxRequest("../ajax/activePoll.php?id="+id);
}

function showActive() {
	response = ajaxreq.responseText;
	document.getElementById("activePoll").innerHTML = response;
}

function activeNews() {
	box=document.getElementById("checks").active;
	txt="";
	if (!box.length) {
		txt = box.value;
	} else {
		for (i=0;i<box.length;++ i) {
			if (box[i].checked) {			
				txt = txt + box[i].value + ",";
			}
		}
	}
	ajaxCallback = showNews;
	ajaxRequest("../ajax/activeNews.php?id="+txt);
}

function showNews() {
	response = ajaxreq.responseText;
	document.getElementById("newsReport").innerHTML = response;
}

function getAdresa(id, loc, kat) {
	ajaxCallback = displayAdrese;
	ajaxRequest("../ajax/getAdresa.php?id="+id+"&loc="+loc+"&kat="+kat);
}

function displayAdrese() {
	response = ajaxreq.responseText;
	document.getElementById("adrese").innerHTML = response;
}

function createOrder() {
	var duzina = document.poll.vote.length;
	for (var i=0; i<duzina; i++)  {
		if (document.poll.vote[i].checked)  {
			found_it = document.poll.vote[i].value
		}
	}
	process(found_it);
}

function process(int) {
	ajaxCallback = displayRezultat;
	ajaxRequest("poll/kpoll_vote.php?vote="+int+"&rand="+Math.random());
}

function displayRezultat() {
	response = ajaxreq.responseText;
	if (response == 'err') {
		document.getElementById("err_message").innerHTML = 'Samo mo&#382;ete glasovati jedanput na dan';
	} else {
		document.getElementById("pollbox").innerHTML = response;
	}
	pollResize();
}

function showResults() {
	ajaxCallback = results;
	ajaxRequest("poll/showResult.php");
}

function results() {
	response = ajaxreq.responseText;
	document.getElementById("pollbox").innerHTML = response;
	pollResize();
}

function pollResize() {
	var maxheight = 15;
	maxheight=maxheight + document.getElementById("contentleft").clientHeight;
	var frame = null;
	frame = maxheight + 170 + document.getElementById("red_area").clientHeight;
	
	document.getElementById("contentleft").style.height = maxheight+"px";
	document.getElementById("contentcenter").style.height = maxheight+"px";
	document.getElementById("contentpreright").style.height = maxheight+"px";
	document.getElementById("frame").style.height = frame+"px";
}