function cancelajax(element) {
	
	document.getElementById(element+"_tbox").value = document.getElementById(element+"_text").innerHTML;
	document.getElementById(element+"_edit").style.display="none";
	document.getElementById(element+"_text").style.display="";
	document.getElementById(element+"_linkedit").style.display="";
	
	
	
}
function submitajax(element,type) {
	
	document.getElementById(element+"_text").innerHTML = document.getElementById(element+"_tbox").value;
	document.getElementById(element+"_edit").style.display="none";
	document.getElementById(element+"_text").style.display="";
	document.getElementById(element+"_linkedit").style.display="";
	
	ajaxsubmit(element+"_form","admin_editajax.php?type="+type);
	
}
function buildPOST(theFormName) {
    theForm = document.forms[theFormName];
    var qs = ''
    for (e=0;e<theForm.elements.length;e++) {
        if (theForm.elements[e].name!='') {
            var name = theForm.elements[e].name;
            qs+=(qs=='')?'':'&'
            qs+= name+'='+escape(theForm.elements[e].value);
        }
    }
    qs+="\n";
    return qs
}

function ajaxsubmit(frmForm,url) {
	 var xmlHttp=null; // Defines that xmlHttp is a new variable.
	 // Try to get the right object for different browser
	 try {
	    // Firefox, Opera 8.0+, Safari, IE7+
	    xmlHttp = new XMLHttpRequest(); // xmlHttp is now a XMLHttpRequest.
	 } catch (e) {
	    // Internet Explorer
	    try {
	       xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    } catch (e) {
	       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	 }
	 xmlHttp.onreadystatechange = function() {

	    if (xmlHttp.readyState == 4)
				 var ok=false;
	       try { // In some instances, status cannot be retrieved and will produce an error (e.g. Port is not responsive)
	          if (xmlHttp.status == 200) {
             //Set the main HTML of the body to the info provided by the AJAX Request
	             //document.getElementById("ajax_output").innerHTML = xmlHttp.responseText;
				 if (xmlHttp.responseText=="OK") {
					 
					ok=true; 
				 }
	          }
	       } catch (e) {
	         // document.getElementById("ajax_output").innerHTML = "Error on Ajax return call : " + e.description;
	       }
		   if (ok==false) {
			   
				alert("Update failed for some reason.. wombles?");   
		   }
	 
	 }
	 xmlHttp.open("post",url); // .open(RequestType, Source);
	 xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
 	xmlHttp.send(buildPOST(frmForm)); // Since there is no supplied form, null takes its place as a new form.
 
}