/*
 * Change mouseover, to see which part of the page will be edited
 */
function changeBackgroundColor(id, color, border, width) {
	if (color) {
		document.getElementById(id).style.backgroundColor = '#' + color;
		document.getElementById(id).style.borderWidth = width;
		document.getElementById(id).style.borderStyle = 'solid';
		document.getElementById(id).style.borderColor = '#' + border;
	} else {
		document.getElementById(id).style.backgroundColor = '';
		document.getElementById(id).style.borderColor = '';
		document.getElementById(id).style.borderWidth = '0';
	}
}

/* 
 * Do http request 
 */
function GetXmlHttpObject() { 
	var objXMLHttp = null;
	if (window.XMLHttpRequest) {
		objXMLHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
} 

/*
 * Change text and expand or fold menu
 */
function showText(id, subid, contentid) {	
	/* do http request */
	var xmlHttp = GetXmlHttpObject();
	
	/* error on request */
	if (xmlHttp == null) {
		alert("Browser does not support HTTP Request");
		return;
	} 
	
	/* do request */
	var url = "inc/get_text.inc.php?contentid=" + contentid;
	
	/* process page */
	xmlHttp.onreadystatechange = 
		function stateChanged() { 
			if (xmlHttp.readyState == 4) {
				if(xmlHttp.status == 200) { 
					//alert(xmlHttp.responseText);
					document.getElementById('edit_content').innerHTML = xmlHttp.responseText;
					document.getElementById('edit_link').href = "index.php?pos=content&id=" + id + "&contentid=" + contentid;
				} else {
					alert("Probleem met het request!" + xmlHttp.status);
				}
			}
		}   

	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
