// JavaScript Document

// Code voor AJAX
function makexmlhttp(){
	
	var xmlhttp = null;
	if(window.XMLHttpRequest){
		
		xmlhttp = new XMLHttpRequest();
	}
	else{
		
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e){
			
			window.alert("Your browser doens't support AJAX. Please update your browser to use this site.");
		}
	}
	return xmlhttp;
}


// Code om aanbieders op te halen
function get_aanbieders(code){
	
	var code = code;
	
	document.getElementById('ajax_div').innerHTML = '<img src="_images/ajax-loader.gif" width="50" height="50" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	var url="index.php/get/aanbieders/"+code+"/";
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4)
		{
			document.getElementById('ajax_div').innerHTML = '';
			document.getElementById('ajax_div2').innerHTML = '';	
			document.getElementById('ajax_div').innerHTML = xmlhttp.responseText;
		}
		
	}
	
	xmlhttp.send('');
	
}

// Code om aanbieders op te halen
function get_producten(code){
	
	var code = code;
	
	document.getElementById('ajax_div2').innerHTML = '<img src="_images/ajax-loader.gif" width="50" height="50" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	var url="index.php/get/producten/"+code+"/";
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4)
		{
			document.getElementById('ajax_div2').innerHTML = xmlhttp.responseText;
		}
		
	}
	
	xmlhttp.send('');
	
}

// Code om aanbieders op te halen
function finish(code){
	
	var code = code;
	
	document.getElementById('ajax_div2').innerHTML = '<img src="_images/ajax-loader.gif" width="50" height="50" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	var url="index.php/get/finish/"+code+"/";
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4)
		{
			document.getElementById('ajax_div').innerHTML = '';
			document.getElementById('ajax_div2').innerHTML = '';
			document.getElementById('finish').innerHTML = '';
			document.getElementById('finish').innerHTML = xmlhttp.responseText;
			document.getElementById('submit').innerHTML = '<input type="submit" value="Opslaan" class="opslaan" />';
		}
		
	}
	
	xmlhttp.send('');
	
}