function ahah(url, target) {
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (req != undefined) {
		req.onreadystatechange = function() {ahahDone(url, target);};
		req.open("GET", url, true);
		req.send("");
	}
}
function ahahDone(url, target) {
	if (req.readyState == 4) {
		if (req.status == 200) {
			document.getElementById(target).innerHTML = req.responseText;
		} else {
			document.getElementById(target).innerHTML=" Error:\n"+ req.status + "\n" +req.statusText;
		}
	}
}
function load(name, div) {
	document.getElementById(div).innerHTML = '<div style="text-align:center;padding:20px 0;"><img style="width:180px;" src="images/loading.gif" /></div>';
	ahah(name,div);
	return false;
}

function ahahToElement(url, target) {
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (req != undefined) {
		req.onreadystatechange = function() {ahahToElementDone(url, target);};
		req.open("GET", url, true);
		req.send("");
	}
}
function ahahToElementDone(url, target) {
	if (req.readyState == 4) {
		if (req.status == 200) {
			target.innerHTML = req.responseText;
		} else {
			target.innerHTML=" Error:\n"+ req.status + "\n" +req.statusText;
		}
	}
}
function loadToElement(name, element) {
	element.innerHTML = '<div style="text-align:center;padding:20px 0;"><img style="width:180px;" src="images/loading.gif" /></div>';
	ahahToElement(name,element);
	return false;
}

// SHOW/HIDE HELP BOX
function showHelpBox(caller,target,offsetX,offsetY){
	var position = $('#'+caller).offset();
	
	$('#'+target).css({ "left":(position['left']+$('#'+caller).width()+offsetX)+'px', "top":(position['top']+$('#'+caller).height()+offsetY-140)+'px'}).show();
}
function hideHelpBox(target){
	$('#'+target).hide();
}

// SHOW MORE ENTRIES
function showMoreEntries(tags,offset,count,entities,targetElement){
	loadToElement('xcontent_entities.php?tags='+tags+'&offset='+offset+'&count='+count+'&entities='+entities+'',targetElement);
}



