// 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;
	}

	// 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);

	
}

function ajax_get (url, 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; }

	// Does URL begin with http?
	if (url.substring(0, 4) != 'http') {
		url = base_url + url;
	}

	// Create getfile URL
	var scrol=getScrollXY();
	if (navigator.appName == "Microsoft Internet Explorer")
	{	
		var comm_left=screenSizeW/2-225 + 1*scrol[0];
		var comm_top=screenSizeH/2-250 + 1*scrol[1];
		
	}
	else{
		var comm_left=screenSizeW/2-225 + 1*scrol[0];
		var comm_top=screenSizeH/2-250 + 1*scrol[1];
	}
	
	hideSelects('hidden');
	el.style.width='500px';
	el.style.height='600px';
	el.style.top=comm_top + 'px';
	el.style.left=comm_left + 'px';
	el.style.display='';

	
	
	
	el.innerHTML='<img src="/ke_images/loading.gif" border="0" alt="loading...">';
	
	document.getElementById('transpbg').style.display='';
	document.getElementById('transpbg').style.width=(screenSizeW+1*scrol[0]) + 'px';
	
	document.getElementById('transpbg').style.height=(screenSizeH+1*scrol[1]) + 'px';
	
	getfile_url = base_url+'ajaxdo/getfile~000-0!el=' + escape(el.id) + '|url='+escape(url);

	// Do Ajax
//	document.getElementById(el.id).innerHTML='asdsdsas';
//alert(getfile_url);
	ajax_do (getfile_url);
	
	//return true;
}


