var xmlHttp;
function newXMLHttpRequest() {
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
}

function yourcomment($name,$comment){
	document.getElementById("yourname").innerHTML = '<em>Preview:</em><br />From '+$name;
	$comment = $comment.split("\n").join("<br />")
	document.getElementById("yourcomment").innerHTML = $comment;
}
function loginShow(){
	document.getElementById("loginbox").innerHTML = '<form action="/login.php" method="post">Username: <input type="text" name="username" /><br />Password: <input type="password" name="password" /><br /><input type="submit" value="Login" name="submit_login" /></form>';
}

function addLink(){
	newXMLHttpRequest();
	xmlHttp.onreadystatechange = addlinkUpdate;
	$vars = 'url='+document.getElementById("el_url").value+'&name='+document.getElementById("el_name").value;
	xmlHttp.open("POST",'backend/ajax/addlink.php?id='+document.getElementById("id").innerHTML,true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send($vars);
}

function addlinkUpdate(){
	if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
		document.getElementById("ellist").innerHTML += xmlHttp.responseText;
	} else if (xmlHttp.readyState == 4 && xmlHttp.status != 200) {
		document.getElementById("ellist").innerHTML += 'Error: '+xmlHttp.status;
	}
}


function changeLexicon(id){
	newXMLHttpRequest();
	xmlHttp.onreadystatechange = updateLexicon;
	document.getElementById("lexicategories").innerHTML = 'Please wait...';
	xmlHttp.open("GET",'backend/ajax/changelexicon.php?id='+id,true);
	xmlHttp.send(null);
}

function updateLexicon(){
	if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
		document.getElementById("lexicategories").innerHTML = xmlHttp.responseText;
	} else if (xmlHttp.readyState == 4 && xmlHttp.status != 200) {
		document.getElementById("lexicategories").innerHTML = 'Error: '+xmlHttp.status;
	}
}

