// JavaScript Document
// Get base url
url = document.location.href;
xend = url.lastIndexOf("/") + 1;
var base_url = 'http://'+window.location.hostname+'/';

var ajax_get_error = false;

function ajax_do (url) {
	// Does URL begin with http?
	if (url.substring(0, 4) != 'http') {
		url = base_url + url;
	}
	//alert(url);
	// Create new JS element
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;
//	alert(url);
	// Append JS element (therefore executing the 'AJAX' call)
	document.body.appendChild (jsel);

	return true;
}

function ajax_get (url, el) {
	
	url=url.replace('&amp;','&');
	
	// Has element been passed as object or id-string?
	if (typeof(el) == 'string') {
		el = document.getElementById(el);
	}

	// Valid el?
	if (el == null) { return false; }

	// Does URL begin with http?
	if (url.substring(0, 4) != 'http') {
		url = base_url + url;
	}
//alert(escape(url));
	// Create getfile URL
	getfile_url = base_url+'includes/js/getfile.php?url='+escape(url) + '&el=' + escape(el.id);
//alert(getfile_url);
	// Do Ajax
//	document.getElementById(el.id).innerHTML='asdsdsas';
//alert(getfile_url);
	ajax_do (getfile_url);
	
	return true;
}



function ajax_get2 (url, el) {
	url=url.replace('&amp;','&');
	///alert(url);
	// Has element been passed as object or id-string?
	if (typeof(el) == 'string') {
		el = document.getElementById(el);
	}
	el.innerHTML='<img src="/imagini/ajax-loader.gif">';
	// Valid el?
	if (el == null) { return false; }

	// Does URL begin with http?
	if (url.substring(0, 4) != 'http') {
		url = base_url + url;
	}
//alert(escape(url));
	// Create getfile URL
	getfile_url = base_url+'includes/js/getfile.php?url='+escape(url) + '&el=' + escape(el.id);
//alert(getfile_url);
	// Do Ajax
//	document.getElementById(el.id).innerHTML='asdsdsas';
//alert(getfile_url);
	ajax_do (getfile_url);
	
	return true;
}

