// JavaScript Document

function RBAjaxFetch(processor,destination,input0,input1,input2,input3,input4,input5,input6,input7,input8,input9,input10) {
	
	
	// Carries out a simple fetch from a page
	
	// processor is the name of the file in the ajax-php folder - the calling file must be in the root
	// destination is the name of the element where the output will be sent
	// input is sent to the page in the get string as 'q'
	
	//document.getElementById(destination).innerHTML="Please Wait...";
	
	
	// Prepare the variables, make them into a POST string, and get them ready to go
	var params = "";
	params = params + "q0=" + encodeURIComponent(input0) ; 
	params = params + "&q1=" + encodeURIComponent(input1) ; 
	params = params + "&q2=" + encodeURIComponent(input2) ; 
	params = params + "&q3=" + encodeURIComponent(input3) ; 
	params = params + "&q4=" + encodeURIComponent(input4) ; 
	params = params + "&q5=" + encodeURIComponent(input5) ; 
	params = params + "&q6=" + encodeURIComponent(input6) ; 
	params = params + "&q7=" + encodeURIComponent(input7) ; 
	params = params + "&q8=" + encodeURIComponent(input8) ; 
	params = params + "&q9=" + encodeURIComponent(input9) ; 
	params = params + "&q10=" + encodeURIComponent(input10) ; 

	
	if (input1=="") {
		document.getElementById(destination).innerHTML="";
		return;
	}
	
	if (window.XMLHttpRequest) {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	} else {
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
  
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			document.getElementById(destination).innerHTML=xmlhttp.responseText;
		}
	}
	
	//xmlhttp.open("GET","ajax-php/" + processor + ".php?q="+input,true);
	xmlhttp.open("POST","ajax-php/" + processor + ".php",true);
	
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	//xmlhttp.setRequestHeader("Content-length", params.length);
	//xmlhttp.setRequestHeader("Connection", "close");

	xmlhttp.send(params);
	
}
