var Rezultati;

function isIE() {
	return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}
function vidljiv(obj){
	if (isIE()) {
		obj = obj.parentElement;
		objall = gallery.firstChild;
		for (; objall != null; objall = objall.nextSibling) {
			if (objall.className == 'aktivan') {
				objall.className ='pasivan';
			}
		}
		obj.className = 'aktivan';
		if (!(obj.className != 'promena' && obj.nextSibling != null && obj.nextSibling.className == 'promena' && obj.nextSibling.style.display == 'block')) {
			objall = gallery.firstChild;
			for (; objall != null; objall = objall.nextSibling) {
				if (objall.className == 'promena') {
					objall.style.display ='none';
				}
			}
		}
		for (; obj.nextSibling != null && obj.nextSibling.className == 'promena'; ) {
			obj = obj.nextSibling;
			if (obj.style.display == 'block') {
				obj.style.display ='none';
			} else {
				obj.style.display ='block';
			}
		}
	}
		else {
		obj = obj.parentNode;
		objall = gallery.firstChild.nextSibling;
		for (; objall != null; objall = objall.nextSibling.nextSibling) {
			if (objall.className == 'aktivan') {
				objall.className ='pasivan';
			}
		}
		obj.className = 'aktivan';
		if (!(obj.className != 'promena' && obj.nextSibling.nextSibling != null && obj.nextSibling.nextSibling.className == 'promena' && obj.nextSibling.nextSibling.style.display == 'block')) {
			objall = gallery.firstChild.nextSibling;
			for (; objall != null; objall = objall.nextSibling.nextSibling) {
				if (objall.className == 'promena') {
					objall.style.display ='none';
				}
			}
		}
		for (; obj.nextSibling.nextSibling != null && obj.nextSibling.nextSibling.className == 'promena'; ) {
			obj = obj.nextSibling.nextSibling;
			if (obj.style.display == 'block') {
				obj.style.display ='none';
			} else {
				obj.style.display ='block';
			}
		}
	}
}

function popup(what) {
		obj = document.getElementById('popup');
		obj.src = what;
//		while (obj.readyStateValue != 4) {}
		obj.style.visibility ='visible';
}

function closepopup(obj) {
	if (isIE()) {
		obj.parentElement.parentElement.innerHTML = '';
		document.parentWindow.frameElement.style.visibility ='hidden';
	}else{
		obj.parentNode.innerHTML = '';
		this.frameElement.style.visibility ='hidden';
	}
}

function GetPage(n, rcount) {
	document.params.action += '&p=' + n;
	if (rcount != 0) {document.params.action += '&ipp=' + rcount};
	document.params.submit();
}

function ChangeView(vrsta, oblast, arhiva, rcount, sort, itemid, arhiviraj) {
	document.params.action += '&v=' + vrsta;
	document.params.action += '&o=' + oblast;
	if (arhiva == 'True') {document.params.action += '&a=Da'};
	if (rcount != 0) {document.params.action += '&ipp=' + rcount};
	if (sort != '') {document.params.action += '&srt=' + sort};
	if (itemid != '0') {document.params.action += '&iid=' + itemid};
	if (arhiviraj != '0') {document.params.action += '&arh=' + arhiviraj};
	document.params.submit();
}

function ChangeViewGalerija(itemid, arhiviraj) {
	
	if (itemid != '0') {document.paramsG.action += '&iid=' + itemid};
	if (arhiviraj != '0') {document.paramsG.action += '&arh=' + arhiviraj};
	document.paramsG.submit();
}

function CalendarSelect(year, month, day) {
	document.params.action += '&y=' + year;
	if (month != 0) {document.params.action += '&m=' + month};
	if (day != 0) {document.params.action += '&d=' + day};
	document.params.submit();
}

function validateAnketa(frm, msg){
	if (Rezultati == false) {
		for (var iElement = 0; iElement < frm.length; iElement++)
		{
			if (frm(iElement).type == "radio" && frm(iElement).checked == true)
			{
				return true;
			}
		}
		alert (msg);
		return false;
	}
	return true;
}
// ---------------- DB navigate

var pf_offset = 8;
function GetCookieValue(name) {
	var allcookie = document.cookie;
	var i = 0;
	var stop = false;
	var value = "";
	while ((i < allcookie.length) && (!stop)) {
		if (allcookie.substr(i,name.length + 1) == name + "=") {
			i += name.length + 1;
			while ((i < allcookie.length) && (allcookie.charAt(i) != ";")) {
				value += allcookie.charAt(i);
				i++;
			}
			stop = true;
		}
		i++;
	}
	return value;
}

function Export() {
	window.showModalDialog("export.asp?mp=" + max_page + "&query=" + escape(query),"Export","dialogHeight=210pt;" + "dialogWidth=270pt; center=1; edge=sunken; status=0; help=0;" + "scroll=0; resizable=0");
}

function ClearNull(obj) {
	document.getElementById("null_" + obj.name).checked = false;
}

function ClearEdit(obj) {
	if (obj.checked) {
		if (document.getElementById(obj.name.slice(5)).type == "checkbox") {
			document.getElementById(obj.name.slice(5)).checked = false;
		} else {
			document.getElementById(obj.name.slice(5)).value = "";
		}
	}
}

function Change_RPP(obj) {
	var si = obj.selectedIndex;
	document.getElementById("rpp_top").selectedIndex = si;
	document.getElementById("rpp_bottom").selectedIndex = si;
	document.cookie = "record_per_page=" + document.getElementById("rpp_top").options[si].text;
	GetPage(1);
}

function Sort(sort) {
	document.cookie = "QuickOrder=" + escape(sort);
	GetPage(1);
}

function ResetSearch() {
	document.params.op.value = 8;
	document.params.SQLNum.value = "2";
	document.params.p.value = 1;
	document.params.submit();
}

function Search() {
	if (document.getElementById("keywords").value == "") {
		alert("Enter keywords for searching!");
	} else {
		document.params.op.value = 7;
		document.params.SQLNum.value = "2";
		document.params.p.value = 1;
		document.params.keywords.value = document.getElementById("keywords").value;
		if (document.getElementById("exactphrase").checked) {
			document.params.exactphrase.value = 1;
		} else {
			document.params.exactphrase.value = 0;
		}
		document.params.submit();
	}
}
