	// Get base url
	url = document.location.href;
	xend = url.lastIndexOf("/") + 1;
	var base_url = url.substring(0, xend);
	
	var ajax_get_error = false;
	
	function ajax_do (url) {
		// Does URL begin with http?
		if (url.substring(0, 4) != 'http') {
			url = base_url + url;
		}
	
		// Create new JS element
		var jsel = document.createElement('SCRIPT');
		jsel.type = 'text/javascript';
		jsel.src = url;
	
		// Append JS element (therefore executing the 'AJAX' call)
		document.body.appendChild (jsel);
	
		return true;
	}
	
	function ajax_get_cale (m, y, el, sid, tip, isl) {
		// Has element been passed as object or id-string?
		
		if (typeof(el) == 'string') {
			el = document.getElementById(el);
		}
	
		// Valid el?
		if (el == null) { return false; }
		
		// Set loading text in el
		if (isl)
			el.innerHTML = "<p>Učitavam...</p>";
		
		// Does URL begin with http?
		if (url.substring(0, 4) != 'http') {
			url = base_url + url;
		}
	
		// Create getfile URL
		
		getfile_url = 'http://www.svetamarija.hr/js/ajax.php?m=' + escape(m) + '&y=' + escape(y) + '&el=' + escape(el.id) + '&sid=' + escape(sid) + '&tip=' + escape(tip) ;
	
		// Do Ajax
		ajax_do (getfile_url);
	
		return true;
	}
	
	function ajax_get_comm (el, nid, ra, tpl, isl) {
		// Has element been passed as object or id-string?
		
		if (typeof(el) == 'string') {
			el = document.getElementById(el);
		}
	
		// Valid el?
		if (el == null) { return false; }
		
		// Set loading text in el
		if (isl == 1) el.innerHTML = "<p>Učitavam...</p>";
		
		// Does URL begin with http?
		if (url.substring(0, 4) != 'http') {
			url = base_url + url;
		}
	
		
	
		// Create getfile URL
		
		getfile_url = 'http://www.svetamarija.hr/js/ncomm.php?nid=' + escape(nid) + '&el=' + escape(el.id) + '&do=' + escape(ra) + '&tpl=' + escape(tpl);
		
		
		// Do Ajax
		ajax_do (getfile_url);
	
		return true;
	}
	
	function ajax_get_poll (val, pid, el) {
		// Has element been passed as object or id-string?
		
		
		
		if (typeof(el) == 'string') {
			el = document.getElementById(el);
		}

		// Valid el?
		if (el == null) { return false; }
		
		
		// Set loading text in el
		el.innerHTML = "<p>Učitavam...</p>";
		
		
		
		// Does URL begin with http?
		if (url.substring(0, 4) != 'http') {
			url = base_url + url;
		}
	
		// Create getfile URL
		
		getfile_url = 'http://www.svetamarija.hr/js/poll.php?val=' + escape(val) + '&el=' + escape(el.id) + '&pid=' + escape(pid);

		// Do Ajax
		ajax_do (getfile_url);
	
		return true;
	}
	
	function save_ncomm(id, el, tpl){
		tx = document.getElementById('smw_text_' + id).value;
		na = document.getElementById('smw_name_' + id).value;
		
		if (escape(tx) == "" || escape(na) == "")
		{
			alert('Niste popunili sva polje...');
			return false;
		}
		
		if (typeof(el) == 'string') {
			el = document.getElementById(el);
		}
		
		if (el == null) { return false; }
		
		getfile_url = 'http://www.svetamarija.hr/js/ncomm.php?nid=' + escape(id) + '&el=' + escape(el.id) + '&do=save' + '&tx=' +  escape(tx) + '&na=' + escape(na) + '&tpl=' + escape(tpl);
		ajax_do (getfile_url);
		
		ajax_get_comm(el, id, 'show', tpl, 0);
	}
	
	function m_over(elem){
		el = document.getElementById(elem);	
		el.setAttribute('class','m_over');
		el.setAttribute('className','m_over');
	}
	function m_clr(elem){
		el = document.getElementById(elem);	
		el.setAttribute('class','m_clr');
		el.setAttribute('className','m_clr');
	}
