	
	var timerID;
	
	function ShowLayer(id)
	{
	  document.getElementById().style.display = "block"; 
	}
	
	function HideTimedLayer(id)
	{  
	    clearTimeout(timerID);
	    document.getElementById(id).style.display = "none";
	}
	
	function timedLayer(id)
	{
	  setTimeout("HideTimedLayer(\"" + id + "\")", 10000);
	}
	
	/*
	function expandCollapse() {
		for (var i=0; i<expandCollapse.arguments.length; i++) {
			var element = document.getElementById.(expandCollapse.arguments[i]);
			element.style.display = (element.style.display == "none") ? "block" : "none";
		}
	}
	*/
	
	function getControlPrefix() {
	   if (getControlPrefix.prefix)
	      return getControlPrefix.prefix;
	   
	   var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
	   var o, o2;
	   for (var i = 0; i < prefixes.length; i++) {
	      try {
	         // try to create the objects
	         o = new ActiveXObject(prefixes[i] + ".XmlHttp");
	         o2 = new ActiveXObject(prefixes[i] + ".XmlDom");
	         return getControlPrefix.prefix = prefixes[i];
	      }
	      catch (ex) {};
	   }
	   
	   throw new Error("Could not find an installed XML parser");
	}		
	
	function XmlHttp() {}

	XmlHttp.create = function () {
		try {
			if (window.XMLHttpRequest) {
				var req = new XMLHttpRequest();

				// some older versions of Moz did not support the readyState property
				// and the onreadystate event so we patch it!
				if (req.readyState == null) {
					req.readyState = 1;
					req.addEventListener("load", function () {
						req.readyState = 4;
						if (typeof req.onreadystatechange == "function")
						req.onreadystatechange();
					}, false);
				}

				return req;
			}
			if (window.ActiveXObject) {
				return new ActiveXObject(getControlPrefix() + ".XmlHttp");
			}
		}
		catch (ex) {}
		// fell through
		throw new Error("Your browser does not support XmlHttp objects");
	};
	
	var xmlhttp = XmlHttp.create();
	
	function makeReqUrl(actUrl) {
		frm=document.forms[0];
		rUrl = actUrl+'?';
		for (var i=0; i<frm.length; i++) {
			current = document.forms[0].elements[i];
			rUrl += current.name + '=' + current.value + '&'; 
		}
		//window.alert('rurl: ' + rUrl);
		//frm.reset();
		return rUrl;
	}
	
	function makeReqUrlFN(actUrl, formNum) {
		frm=document.forms[formNum];
		rUrl = actUrl+'?';
		for (var i=0; i<frm.length; i++) {
			current = document.forms[formNum].elements[i];
			rUrl += current.name + '=' + current.value + '&'; 
			//current.disabled = true;
		}
		//window.alert('rurl: ' + rUrl);
		//frm.reset();
		return rUrl;
	}
	
	function lf(furl, el) {
		//window.alert('furl: ' + furl);
	    var element = document.getElementById(el);
	    element.style.display = 'block';
	    //element.innerHTML = '<i><b><br><br><br>Zahtev se izvršava ...<br><br><br><br></b></i>';
	    //element.innerHTML = '<span class=load>Loading ...</small></span>';
	    xmlhttp.open("GET", furl);
	    //xmlhttp.setRequestHeader('Accept-Charset','windows-1250');
	    try {
		    xmlhttp.onreadystatechange = function() {
		        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		            element.innerHTML = xmlhttp.responseText;
		        } 
				//else {
				// 	window.alert('Greska: ' + 'readyState: ' + xmlhttp.readyState + ' status: ' + xmlhttp.status);
				//}
		    }
		    xmlhttp.send(null);
		    return true;
	    } catch(ex) {
	    	//window.alert('Greska: ' + ex);
	    	return false;
	    }
	}
	
	function recalculateTimeout(Mb){
		var H=100;
		for(var o=1; o<=(Mb-2)/2; o++){
			H=H*2
		}
		H=H+50;
		return H
	}
	
	function searchLoop(u, e, ss) {
		var timeoutAdjustment = 1;
		var old='';
		if(!ss) {
			return false;
		} else {
			timeoutAdjustment = recalculateTimeout(timeoutAdjustment);
		}
		//window.alert(old+':'+ss);
		if(old!=ss) {
			if(lf(u, e)) {
				timeoutAdjustment = recalculateTimeout(timeoutAdjustment);
				old = ss;
			} else {
				//setTimeout("searchLoop()", timeoutAdjustment);
				old = '';
			}
		} else {
			return false;
		}
	}
	
	//setTimeout("searchLoop()", 10);
	
	function loadFragWithConfirm(confirmMsg, fragment_url, element_id) {
		if(confirm(confirmMsg)) {
			loadFragmentInToElement(fragment_url, element_id);
		} else {
			return false;
		}
	} 
	
	function ss(furl, imgObjID, ident) {
		imgObj = document.getElementById(imgObjID);
		isrc = imgObj.src;
	    if(isrc.indexOf('star_n.gif')>1) {
	    	imgObj.src='data/ui/star_y.gif';
	    	furl += '&yn=1';				
	    	//document.getElementById('opisAct'+ident).innerHTML = document.getElementById('opisActHid'+ident).innerHTML;
		} else {
	    	imgObj.src='data/ui/star_n.gif';
	    	furl += '&yn=0';							
	    	//document.getElementById('opisAct'+ident).innerHTML = ident;
		}
		//window.alert(furl);
	    xmlhttp.open("GET", furl);
	    try {
		    xmlhttp.onreadystatechange = function() {
		        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		            return true;
		        } 
//		        else {
//		        	window.alert('Greska: ' + 'readyState: ' + xmlhttp.readyState + ' status: ' + xmlhttp.status + 'response' + xmlhttp.responseText);
//		        	return true;
//		        }
		    }
		    xmlhttp.send(null);
	    } catch(ex) {
	    	window.alert('Greska: ' + ex);
	    }	
		return true;
	}
	
	function li(baseurl, gtype, el) {
	    var iplace = document.getElementById(el);
	    var frm = document.getElementById('reportFrm');
	    var pm = frm.getmpm.value;
	    var odD = frm.odDatuma.value;
	    var doD = frm.doDatuma.value;
	    var tmp = new Date();
		var suffix = tmp.getTime();
	    var furl = baseurl+'?gtype='+gtype+'&getmpm='+pm+'&odDatuma='+odD+'&doDatuma='+doD+'&'+suffix
	 	//window.alert('furl: ' + furl);
	    iplace.style.display = 'block';
	    iplace.innerHTML = '<i><b><br><br><br><img src="/img/ui/wait.gif"><br><br><br><br></b></i>';
	    var slika = document.createElement('img');
	    slika.src = furl;
	    //if(slika.complete) {
		    slika.onload = function () {
		    	try {
		    		sClone = slika.cloneNode(true)
		    		sClone.alt="dotoverdot";
		    		iplace.replaceChild(sClone, iplace.firstChild);
		    	} catch (ex) {
		    		window.alert('Uvatili smo egzepsn ' + ex);
		    	}
		    	return true;
	    	}
	    return true;
	}
	
	function loadFragWithConfirm(confirmMsg, fragment_url, element_id) {
		if(confirm(confirmMsg)) {
			loadFragmentInToElement(fragment_url, element_id);
		} else {
			return false;
		}
	} 	
	
	// Object for URLENCODED POST requests
	function PostRequest() {};
	PostRequest.prototype = {
	    url: '',
	    
	    postbody: '',
	    
	    prepare: function(xmlhttp) {
	        xmlhttp.open('POST',this.url,true);
	        xmlhttp.setRequestHeader(
	                    'Content-Type',
	                    'application/x-www-form-urlencoded; charset=UTF-8'
	                );
	        xmlhttp.setRequestHeader('Content-Length', this.postbody.length);
	    },
	    
	    send: function(xmlhttp) {
	        xmlhttp.send(this.postbody);
	    }
	}
	
	// Some function to create the XMLHttpRequest object and make a request
	function makeRequest(request) {
	    var xmlhttp = new XMLHttpRequest();
	    request.prepare(xmlhttp);
	    request.send(xmlhttp);
	}	
	
	
	
	function createTable() {
		var x = xmlDoc.getElementsByTagName('emperor');
		var newEl = document.createElement('TABLE');
		newEl.setAttribute('cellPadding',5);
		var tmp = document.createElement('TBODY');
		newEl.appendChild(tmp);
		var row = document.createElement('TR');
		for (j=0;j<x[0].childNodes.length;j++)
		{
			if (x[0].childNodes[j].nodeType != 1) continue;
			var container = document.createElement('TH');
			var theData = document.createTextNode(x[0].childNodes[j].nodeName);
			container.appendChild(theData);
			row.appendChild(container);
		}
		tmp.appendChild(row);
		for (i=0;i<x.length;i++)
		{
			var row = document.createElement('TR');
			for (j=0;j<x[i].childNodes.length;j++)
			{
				if (x[i].childNodes[j].nodeType != 1) continue;
				var container = document.createElement('TD');
				var theData = document.createTextNode(x[i].childNodes[j].firstChild.nodeValue);
				container.appendChild(theData);
				row.appendChild(container);
			}
			tmp.appendChild(row);
		}
		document.getElementById('writeroot').appendChild(newEl);
	}
	
	function popustForm(divCont, ident) {
		old = divCont.innerHTML;
		var frmHTML = '<input size=3 type="text" value="" name="ident_popust['+ident+']" onchange="this.className=\'redWhite\'">';
		//window.alert(frmHTML);
		divCont.innerHTML = frmHTML;
		popustField = divCont.firstChild;
		popustField.focus();
		popustField.onblur = function () {
			pfv = popustField.value;
			//window.alert(pfv);
			if(isNaN(pfv) | !pfv) {
				popustField.value = 0;
				//window.alert('Popust mora biti broj izmedju 0 i 100');
				document.getElementById('pFrmSubmit').style.display='none';
				document.getElementById('pFrmSubmit2').style.display='none';
				return false;
			} else {
				if ((pfv < 0) | (pfv > 100)) {
					popustField.value = 0;
					//window.alert('Popust mora biti broj izmedju 0 i 100');
					document.getElementById('pFrmSubmit').style.display='none';
					document.getElementById('pFrmSubmit2').style.display='none';
					return false;
				} else {
					document.getElementById('pFrmSubmit').style.display='block';
					document.getElementById('pFrmSubmit2').style.display='block';	
				}
				// pfv += ' %';
				// popustField.className='';
				// popustField.style.border='';				
				// popustField.style.background='inherit';
				// popustField.disabled=true;
				// divCont.innerHTML = pfv;
			}
		}
		
		
				divCont.onclick = function rEvent() {
					return false;
				}
		
		//		f = document.getElementById(frmName);
		//		f.ident_popust.focus();
		
	}
