//AJAX
var xmlhttp = null;
if (window.XMLHttpRequest){
	// If IE7, Mozilla, Safari, etc: Use native object
	xmlhttp = new XMLHttpRequest(); // no var
}
else if (window.ActiveXObject){
	// ...otherwise, use the ActiveX control for IE5.x and IE6
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // no var
}
else{
	// no XMLHTTP... leave as null
}

//Kijk of er wel 12 tekens zijn ingevuld in het veld
function check12(formulier){
	
	inhoud=formulier.klantnummer.value
	if(inhoud.length<12){
		alert('Het klantnummer moet minimaal 12 tekens bevatten.');
		return false;
	}

}

//Maak nog een kies een bestand aan, multi upload
function add_upload(src){
	var new_total = Math.round(document.upload.TOTAL_FILE.value) + 1;
	if(new_total == 6){
	}
	else{
		document.getElementById('attach_' + document.upload.TOTAL_FILE.value).innerHTML = "<input type='file' size='50' name='bestand[]' /></div><div id='attach_" + new_total + "'>";	
		document.upload.TOTAL_FILE.value++;
	}
}

//Ajax, zoeken naar log informatie
function zoeklog() {
    	//Put the form data into a variable
       	var klantnummer = document.zoek.klantnummer.value;
		
		//Change the content of the "result" DIV to "Searching..."
		document.getElementById('zoeklog').innerHTML = "Zoeken...";
		
        //This sets a variable with the URL (and query strings) to our PHP script
		var pst="klantnummer="+escape(klantnummer);
        	
		//Open the URL above "asynchronously" (that's what the "true" is for) using the GET method
		xmlhttp.open('POST', 'zoeklog.php', true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

        //Check that the PHP script has finished sending us the result
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                		//Replace the content of the "result" DIV with the result returned by the PHP script
				document.getElementById('zoeklog').innerHTML = xmlhttp.responseText;
			} else {
                //If the PHP script fails to send a response, or sends back an error, display a simple user-friendly notification
				//document.getElementById('ws1_result').innerHTML = 'Error: preSearch Failed!';
			}
		};
		xmlhttp.send(pst);  
}

//Ajax, zoeken naar bestanden
function zoekdownload() {
    	//Put the form data into a variable
       	var klantnummer = document.zoek.klantnummer.value;
		
		//Change the content of the "result" DIV to "Searching..."
		document.getElementById('files').innerHTML = "Zoeken...";
		
        //This sets a variable with the URL (and query strings) to our PHP script
		var pst="klantnummer="+escape(klantnummer);
        	
		//Open the URL above "asynchronously" (that's what the "true" is for) using the GET method
		xmlhttp.open('POST', 'zoekfiles.php', true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

        //Check that the PHP script has finished sending us the result
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                		//Replace the content of the "result" DIV with the result returned by the PHP script
				document.getElementById('files').innerHTML = xmlhttp.responseText;
			} else {
                //If the PHP script fails to send a response, or sends back an error, display a simple user-friendly notification
				//document.getElementById('ws1_result').innerHTML = 'Error: preSearch Failed!';
			}
		};
		xmlhttp.send(pst);  
}

function goTo(url) {
	location.href = url;
}
