﻿var
	sp_izhod        = "",
	sp_ni_podprto   = "",
	locilo_tisocic  = ".",
	locilo_decimalk = ",";


function PotrdiIzhod()
{
	return sp_izhod;
}


function OmogociIzhod(omogoci)
{
	window.onbeforeunload = omogoci ? null : PotrdiIzhod;
}


function VrniLokalnoStevilo(n)
{
	var
		x,
		str = "",
		je_negativno = n < 0;

	// Odstranimo predznak in zaokrožimo na dve decimalki.
	n = Math.round((je_negativno ? -n : n) * 100);

	// Pretvorimo celi del v niz.
	for (x = Math.floor(n / 100); x; x = Math.floor(x / 1000))
		str = "" + (x % 1000) + (str.length ? locilo_tisocic + str : "");

	// Pretvorimo decimalni del v niz.
	for (x = (new Number(n % 100)).toString(); x.length < 2; x = "0" + x);

	return (je_negativno ? "-" : "") + (str.length ? str : "0") + locilo_decimalk + x;
}


function DeliZaznamki()
{
	var
		u = window.location.href,
		t = document.title;

	if (window.sidebar)
		window.sidebar.addPanel(t, u, "");
	else if (window.external)
		window.external.AddFavorite(u, t);
	else
		alert(sp_ni_podprto);

	return false;
}


function DeliEPosta()
{
	var
		u = window.location.href,
		t = document.title;

	window.location.href = "mailto:?subject=" + encodeURIComponent(t) + "&body=" + encodeURIComponent(u);
	return false;
}


function DeliFacebook()
{
	var
		u = window.location.href,
		t = document.title;

	window.location.href = "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(u) + "&t=" + encodeURIComponent(t);
	return false;
}


function DeliTwitter()
{
	var
		u = window.location.href,
		t = document.title;

	window.location.href = "http://twitter.com/home?status=" + encodeURIComponent(t) + "%20" + encodeURIComponent(u);
	return false;
}


function DeliLinkedIn()
{
	var
		u = window.location.href,
		t = document.title;

	window.location.href = "http://www.linkedin.com/shareArticle?mini=true&url=" + encodeURIComponent(u) + "&title=" + encodeURIComponent(t);
	return false;
}


function DeliDelicious()
{
	var
		u = window.location.href,
		t = document.title;

	window.location.href = "http://delicious.com/save?v=5&noui&jump=close&url=" + encodeURIComponent(u) + "&title=" + encodeURIComponent(t);
	return false;
}


function VnosPovecaj(ime, koliko)
{
	var
		el = document.getElementById(ime);

	if (el) {
		var vrednost = parseInt(el.value, 10);
		if (!isNaN(vrednost)) {
			el.value = vrednost + koliko;
			if (el.fireEvent) {
				el.fireEvent("onchange");
			} else {
				var ev = document.createEvent("HTMLEvents");
				ev.initEvent("change", true, true);
				el.dispatchEvent(ev);
			}
		}
	}
}


function PreberiVarnostnoKodo(ime, url_govor)
{
	var
		el = document.getElementById(ime);

	if (el)
		el.innerHTML = "<embed src=\"" + url_govor + "?" + (new Date()).getTime() + "\" autostart=\"true\" loop=\"false\" volume=\"100\" hidden=\"true\"/>";
}


function ObrniPrikaz(ime, display)
{
	var
		el = document.getElementsByName(ime),
		el_gumba = document.getElementsByName("gumb_" + ime),
		i, n = el.length;

	if (el_gumba && el_gumba.length) {
		var
			m = new String(el_gumba[0].src).match(new RegExp("(.*)_([0-9]+)\.([^.]+)", "i"));

		if (m) el_gumba[0].src = m[1] + "_" + (1 - parseInt(m[2])) + "." + m[3];
	}

	for (i = 0; i < n; i++) {
		if (el[i].style.visibility == "visible") {
			el[i].style.display = "none";
			el[i].style.visibility = "hidden";
		} else {
			el[i].style.display = display;
			el[i].style.visibility = "visible";
		}
	}
}


function VrniXMLHTTP()
{
	if (window.XMLHttpRequest) {
		// Novejši brskalniki.
		return new XMLHttpRequest();
	} else {
		// Internet Explorer 5/6
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
}

