// Set osnovnih funkcija
function gbid(oelm)			{ return document.getElementById(oelm); }
function getWindowHeight()	{ return parseInt(window.innerHeight ? window.innerHeight : document.body.parentNode.clientHeight); }
function getWindowWidth()	{ return parseInt(window.innerWidth ? window.innerWidth : document.body.parentNode.clientWidth); }

// Funkcija za podesavanje velicina osnovnih elemenata strane
function podesiStranu(shLogo) {	
	var dH = gbid("div_header"), dC = gbid("div_content"), dF = gbid("div_footer");
	var h = getWindowHeight(), v = getWindowWidth();
	dC.style.top = dH.clientHeight + 10 + "px";
	dC.style.height = (h - dH.clientHeight - dF.clientHeight - 15) + "px";
	
	if (!document.all)
		dF.style.top = (h - dF.clientHeight)+"px";	// !IE
	else
		dF.style.top = (h - dF.offsetHeight)+"px";	// IE
		
	if (shLogo != false) {
		var logoW = ((v - dC.clientWidth) / 2);
		dC.style.left = logoW + "px";

		var imgL = gbid("img_logo"), dL = gbid("div_logo"), logoMargin = 10;
		if (logoW > 150)
			imgL.style.width = (150 - logoMargin) + "px";
		else		
			imgL.style.width = (logoW - logoMargin) + "px";
			
		dL.style.width = (logoW - logoMargin) + "px";
		dL.style.top = ((h - dF.offsetHeight - dL.offsetHeight) - 3) + "px";
		dL.style.left = (logoMargin/2) + "px";
		
		dL.style.visibility = 'visible';		// Ukljuci prikaz logoa...
	}

	var photoD = gbid("photoDivL");		// Ako je vidljiva velika slika, i nju treba centrirati
	if (photoD) centerElement(photoD);
	
	// Sada ukljuci prikaz skrivenih elemenata koji su uvek ukljuceni
	dC.style.visibility = 'visible';
	dF.style.visibility = 'visible';
}

// Browser specificne varijable
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;

// Funkcija za utvrdjivanje browsera
function BrowserInfo() {
  this.name = navigator.appName;
  this.codename = navigator.appCodeName;
  this.version = navigator.appVersion.substring(0,4);
  this.platform = navigator.platform;
  this.javaEnabled = navigator.javaEnabled();
  this.screenWidth = screen.width;
  this.screenHeight = screen.height;
}

function centerElement(obj) {
	var elm;
	if (typeof(obj) == 'string') elm = gbid(obj);
	else elm = obj;
		
	elm.style.left = ((getWindowWidth() - elm.offsetWidth) / 2) + "px";
	var topPos = ((getWindowHeight() - elm.offsetHeight) / 2);
	if (topPos < 0) topPos = 0; 	// spreci da top bude manje od 0
	elm.style.top = topPos + "px";
}

// Kreiraj novi XMLHTTP Request objekat
function newXMLHttp() {
	if (window.XMLHttpRequest) { return new XMLHttpRequest(); }
	else if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); }
	
	alert("Your browser does not support AJAX");
	return null;
}


// Dodeli sadrzaj udaljenog dokumenta elementu u lokalnom dokumentu posredstvom AJAXa
function GetXMLHttp(oid, otp, ohref, ofunc) {
	var xmlhttp = newXMLHttp();
	if (xmlhttp) {
		if (ofunc) xmlhttp.onreadystatechange=ofunc(xmlhttp);
		else xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { $(oid).innerHTML=xmlhttp.responseText; }}
	}

	xmlhttp.open(otp,ohref,true);
	xmlhttp.send(null);

	return xmlhttp;
};

