var WbmMail="webmaster@ipa-serbia.org";
function PopUp(url,target,attr){
	if(!attr.length) attr = "toolbar=no,scrollbars=no,resizable=yes,status=no, title=no";
	_iWin = window.open("", "Site_Index", attr);
	if(target=='_parent'){
		if (_iWin.window.opener.name.length == 0) {
			_iWin.window.opener.name = "parentwin";
		}
  	}
  	mm_tName = _iWin.window.opener.name;
	_iWd=_iWin.document;
	_iWin.window.location.href=url;
	_iWin.window.focus();
	_iWin.window.resizeTo(400,500);

}
function PreUcitajSlike(niz){
	var d=document;
	if(d.images){
		if(!d.PredSlike) d.PredSlike=new Array();
		var i,j=d.PredSlike.length;
		for(i=0; i<niz.length; i++)
		{
			var nemaSlika=true;
			for(k=0; k<d.PredSlike.length; k++){
				if(d.PredSlike[k].src==niz[i]){
					nemaSlika=false;
					break;
				}
			}
			//alert(nemaSlika);
			if(nemaSlika){
				d.PredSlike[j]=new Image;
				d.PredSlike[j++].src=niz[i];
			}
			
		}
	}
//	alert(niz.length);
}
var xdocURL='';
function processReqChange() {
	//alert(rq);
	if (req.readyState == 4) {
        if (req.status == 200) {
			 xmlDoc=req.responseXML;
			 //alert(xmlDoc.documentElement.tagName);
			 ElemList = xmlDoc.getElementsByTagName("strana");
			 if(ElemList[0]!=null && ElemList[0].lastChild!=null){
				 if(navigator.userAgent.indexOf('IE')>=0)document.getElementById('strana').innerHTML=ElemList[0].lastChild.nodeValue;
				 else document.getElementById('strana').innerHTML=ElemList[0].textContent;
			 }
			 else alert("Zadata Strana nije pronadjena!");
			 document.getElementById('naslovNaStrani').innerHTML='';
			 if(xmlDoc.getElementsByTagName("naslov")[0]==null) document.title=' \xB7 IPA Srbija';
			 else {
				document.getElementById('naslovNaStrani').innerHTML=xmlDoc.getElementsByTagName("naslov")[0].lastChild.nodeValue;
				document.title=xmlDoc.getElementsByTagName("naslov")[0].lastChild.nodeValue+" \xB7 IPA Srbija";
			 }
			 if(document.getElementById('editStrana'))document.getElementById('editStrana').href= "e.php?st="+ queryArgValue(xdocURL, 'st')+"&jz="+queryArgValue(xdocURL, 'jz') ;
			document.getElementById('UcitavanjeLY').style.visibility='hidden';
			Ucitano=true;	
        } else {
            alert("Postoji Problem u ucitavanju podataka.\nObratite se administratoru ("+WbmMail+").\nKod: " +
                req.status+" - "+req.statusText);
		}
		
		
    }
}
function queryArgValue(query, arg){
	//alert(query);
	query=query.replace('?','&');
		//alert(query);
	query='&&'+query;
		//alert(query);
	if(0<(p=query.indexOf("&"+arg+"="))){
		pp=query.indexOf('&',p+1);
		if(pp<=0)pp=query.length;
		//alert(p+' '+pp);
		ss=query.substring(p+arg.length+2,pp);
		return ss;
	}else return false;
}
var req=null;
function loadXMLDoc(url) {
	//window.event.srcElement.href="";
/*	if(url.indexOf('slika')){
		document.location=url;
		return;
	}*/
	//window.close();
	if(document.getElementById('UcitavanjeLY')!=null)document.getElementById('UcitavanjeLY').style.visibility='visible';
	Ucitano=false;
	sat();
	xdocURL=url;
	//if(req!=null) req.abort();
	req = false;
	//this.color='#000000';
	if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		try {
			req = new XMLHttpRequest();
		} catch(e) {
			req = false;
		}
	} else if(window.ActiveXObject) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				req = false;
			}
		}
	}

	if(req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send("");
	}
}


function DodajPodMeni(m){
	//window.event.srcElement.href="";
	//lnk.href="";
	meni1x=document.getElementById('meni'+m);
	if(meni1x!=null && meni1x.innerHTML!=""){
		meni1x.innerHTML='';
		return;
	}
	for(i=0; i<=100; i++){
		if(document.getElementById('meni'+i))//!=null;
			document.getElementById('meni'+i).innerHTML='';
	}

	//document.getElementById('TabelaSadrzaj').style.height=document.getElementById('TabelaBrojac').offsetHeight+document.getElementById('TabelaBrojac').offsetTop-document.getElementById('TabelaNaslov').offsetHeight+'px';
	if(ma[m]==null) return;
	mhtml="<table class='PodMeniTabela'  cellspacing='0px' cellpadding='0px' border='0px'>";
	for(i=0; i<ma[m].length; i++){
		mhtml+='<tr class="PodMeniRed"><td class="PodMeniSlika"></td>';//<img src="'+mi[m][i]+'"/>
		mhtml+='<td class="PodMeniPolje"><a class="PodMeniLink" href=\''+ma[m][i]+'\' '+(mc[m][i]!="" ? 'onClick=\'this.href="#";'+mc[m][i]+';return false;\'' : '') +'>'+mt[m][i]+'</a></td>';
		mhtml+='<td class="PodMeniDesno"></td></tr>';
	}
	mhtml+="</table>";	
	meni1x.innerHTML=mhtml;//'<table><tr><td><a href="#" onClick="Load(); return false;">PodMeni</a></td></tr><tr><td> drugaKolona</td></tr></table>';
	//alert(document.getElementById('TabelaBrojac').offsetHeight);
		//alert(document.getElementById('TabelaBrojac').offsetTop);
	//document.getElementById('TabelaSadrzaj').style.height=document.getElementById('TabelaBrojac').offsetHeight+document.getElementById('TabelaBrojac').offsetTop-document.getElementById('TabelaNaslov').offsetHeight+'px';
}
function UpisiUCvor(idc, txtNovi){
	var tekstCvor = document.createTextNode(txtNovi);
	if (document.getElementById(idc).childNodes.length > 0)
	{
		document.getElementById(idc).removeChild(document.getElementById(idc).childNodes[0]);
	}
	document.getElementById(idc).appendChild(tekstCvor);
}