var IFrameObj; // our IFrame object
var iframeHTML;
var IFrameDoc;
var oldURL;
function callToServer(s){
if (!document.createElement) {return true};
var form = document.forms[s];

if (!form.targetURL) {return true};

var qs = '';
var fel=new Array('targetURL','mURL');
for (e=0;e<fel.length;e++) {
if (form.elements[fel[e]]) { 
qs+=(qs=='')?'?':'&';
qs+=fel[e]+'='+escape(form.elements[fel[e]].value);
}
} 
qs+='&todo=getNEWS&'
if(oldURL==qs)return true;
var URL = 'index.pl'+qs;
var responseMessage = document.getElementById('responseMessage');
	responseMessage.style.display = 'block';
	responseMessage.innerHTML = "<H3>Obrada stranice</H3><img src='img/pl1.gif' border='0'><br><p>Ucitavam podatke</p><br><br>";

if (!IFrameObj && document.createElement) {

		try {
			var tempIFrame=document.createElement('iframe');
			tempIFrame.setAttribute('id','RSIFrame');
			tempIFrame.style.border='0px';
			tempIFrame.style.width='0px';
			tempIFrame.style.height='0px';
			IFrameObj = form.appendChild(tempIFrame);
			
			if (document.frames) {
				// this is for IE5 Mac, because it will only
				// allow access to the document object
				// of the IFrame if we access it through
				// the document.frames array
				IFrameObj = document.frames['RSIFrame'];
			}
		} catch(exception) {
			// This is for IE5 PC, which does not allow dynamic creation
			// and manipulation of an iframe object. Instead, we'll fake
			// it up by creating our own objects.
			var iframeHTML='<iframe id="RSIFrame" style="';
			iframeHTML+='border:0px;';
			iframeHTML+='width:0px;';
			iframeHTML+='height:0px;';
			iframeHTML+='"><\/iframe>';
			document.innerHTML+=iframeHTML;
			IFrameObj = new Object();
			IFrameObj.document = new Object();
			IFrameObj.document.location = new Object();
			IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
			IFrameObj.document.location.replace = function(location) {
				this.iframe.src = location;

			}
		}
	}
	
	if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
		// we have to give NS6 a fraction of a second
		// to recognize the new IFrame
		setTimeout('callToServer("'+s+'")',10);
		return false;
	}
	
	if (IFrameObj.contentDocument) {
		// For NS6
		IFrameDoc = IFrameObj.contentDocument; 
	} else if (IFrameObj.contentWindow) {
		// For IE5.5 and IE6
		IFrameDoc = IFrameObj.contentWindow.document;
	} else if (IFrameObj.document) {
		// For IE5
		IFrameDoc = IFrameObj.document;
	} else {
		return true;
	}
	

oldURL=qs;
	IFrameDoc.location.replace(URL);
	return false;

}

// handleResponse is passed two parameters when called from the onload
// event of the pages loaded in the hidden IFRAME:
//	st: a string indicating which state is being loaded
//	doc: the document object of the page loaded in the IFRAME
var orig="Ne mogu ucitati";
function handleResponse(st,doc) {
	// get a reference to the multiple select list, which we will populate
	// with the data from the document loaded in the IFRAME

	// get a reference to the DIV containing the data for this state
	var dataEl = doc.getElementById(st)
		
	// get a reference to the collection of the children elements of
	// our DIV containing the data (this collection is the DIVs containing
	// the actual zip names)
	namesColl = dataEl.childNodes
	
	// for easy scripting, assign the number of ZIP names for this state
	// to a variable
	var numNames = namesColl.length
	
	// iterate through the collection of zip Names and
	// create an option element for each one
var str = '' // used to store the text we'll use in the new option
	for (var q=0; q<numNames; q++) {
		if (namesColl[q].nodeType!=1) continue; // it's not an element node, let's skedaddle
				
		str+=namesColl[q].innerHTML;
		
		}
	
	//provide a "success" message
	var responseMessage = document.getElementById('responseMessage');
	responseMessage.innerHTML = orig;
}
