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;
}


function AantalHonden(){

	document.getElementById('aantal').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	xmlhttp.open("GET","_php/AantalHonden.php",true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4)
		{
			document.getElementById('aantal').innerHTML = xmlhttp.responseText;
		}
		
	}
	
	xmlhttp.send('');
}

function LaadZoekveld(){
	
	document.getElementById('zoekveld').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	xmlhttp.open("GET","_php/LaadZoekveld.php",true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4)
		{
			document.getElementById('zoekveld').innerHTML = xmlhttp.responseText;
		}
		
	}
	
	xmlhttp.send('');
	
	// terug knop weg doen
	document.getElementById('terug').innerHTML = "";
	document.getElementById('icons').innerHTML = "";
}

function ReloadZoekveld(){
	
	document.getElementById('wrapper').innerHTML = "";
	document.getElementById('wrapper').innerHTML = '<div id="zoekveld"></div><div id="aantal"></div>';
	document.getElementById('zoekveld').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	xmlhttp.open("GET","_php/LaadZoekveld.php",true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4)
		{
			document.getElementById('zoekveld').innerHTML = xmlhttp.responseText;
			
			// aantal honden in database weergeven
			AantalHonden();
			
		}
		
	}
	
	xmlhttp.send('');

	// terug knop weg doen
	document.getElementById('terug').innerHTML = "";
	document.getElementById('icons').innerHTML = "";

}

function ReloadZoekveldEmpty(){
	
	document.getElementById('wrapper').innerHTML = "";
	document.getElementById('wrapper').innerHTML = '<div id="zoekveld"></div><div id="aantal"></div>';
	document.getElementById('zoekveld').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	xmlhttp.open("GET","_php/LaadZoekveldEmpty.php",true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4)
		{
			document.getElementById('zoekveld').innerHTML = xmlhttp.responseText;
					
			// aantal honden in database weergeven
			AantalHonden();
		}
		
	}
	
	xmlhttp.send('');
	
	// terug knop weg doen
	document.getElementById('terug').innerHTML = "";
	document.getElementById('icons').innerHTML = "";
}

function LaadHond(){
	
	// codeNummer van hond in variable zetten.
	var code = document.getElementById('code').value;
	
	if ((document.getElementById('code').value.length==0) || (document.getElementById('code').value==null)) {

		// hier gaan we er van uit de bezoeker eigenwijs is!
		ReloadZoekveldEmpty();	
	}
	else{
		
		// Wrapper content ophalen
		LaadWrapperContent();
	
		// Functies aanroepen om de gegevens in te voeren.
		LaadNaamEnTitels(code);
		LaadGeboortedatum(code);
		LaadGeslacht(code);
		LaadType(code);
		LaadUitslag(code);
		LaadFotos(code);
		LaadAfkomst(code);
		
		// Functies aanroepen om onderstade gegevens in te voeren
		LaadStamboom(code);
		LaadKeuring(code);
		LaadGezondheid(code);
		LaadNakomeling(code);
		LaadKeurverslagen(code);
		
		// Mogelijkheid geven om gegevens aan te passen
		LaadAanpassen(code);
		
		// terug knop weg doen
		document.getElementById('terug').innerHTML = "";
		document.getElementById('icons').innerHTML = "";
	}
}

function GaTerugNaarHond(code){
		
	// Wrapper content ophalen
	LaadWrapperContent();

	// Functies aanroepen om de gegevens in te voeren.
	LaadNaamEnTitels(code);
	LaadGeboortedatum(code);
	LaadGeslacht(code);
	LaadType(code);
	LaadUitslag(code);
	LaadFotos(code);
	LaadAfkomst(code);
	
	// Functies aanroepen om onderstade gegevens in te voeren
	LaadStamboom(code);
	LaadKeuring(code);
	LaadGezondheid(code);
	LaadNakomeling(code);
	LaadKeurverslagen(code);
	
	// Mogelijkheid geven om gegevens aan te passen
	LaadAanpassen(code);
	
	// terug knop weg doen
	document.getElementById('terug').innerHTML = "";
	document.getElementById('icons').innerHTML = "";
}

function LaadWrapperContent(){
	
	// Nodige velden voorbereiden om naar de wrapper sturen.
	var wrapper_content = '<div id="basis_naam"></div><div id="basisgegevens_top"><div class="top" id="basis_geborenop"></div><div class="top" id="basis_geslacht"></div><div class="top" id="basis_type"></div><div class="top" id="basis_uitslag"></div><div class="top" id="basis_code"></div></div><div id="basis_fotos"></div></div><div id="extra"><div class="top" id="stamboom"></div><div class="top" id="keuring"></div><div class="top2" id="gezondheid"></div><div class="top" id="nakomeling"></div><div class="top" id="keurverslagen"></div></div><div id="aanpassen"></div>';	
		
	// Content naar wrappper sturen
	document.getElementById('wrapper').innerHTML = wrapper_content;
}

function LaadGeboortedatum(code){

	document.getElementById('basis_geborenop').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadGeboortedatum.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('basis_geborenop').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function LaadGeslacht(code){

	document.getElementById('basis_geslacht').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadGeSlacht.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('basis_geslacht').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function LaadType(code){

	document.getElementById('basis_type').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadType.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('basis_type').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function LaadUitslag(code){

	document.getElementById('basis_uitslag').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadUitslag.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('basis_uitslag').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function LaadAfkomst(code){

	document.getElementById('basis_code').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadAfkomst.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('basis_code').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function LaadNaamEnTitels(code){

	document.getElementById('basis_naam').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadNaamEnTitels.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('basis_naam').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function LaadFotos(code){

	document.getElementById('basis_fotos').innerHTML = '<img style="margin:100px 0 0 0;" src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadFotos.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('basis_fotos').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function LaadFoto(foto){

	document.getElementById('foto').style.visibility = 'visible';
	document.getElementById('foto').style.display = 'block';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadImage.php";
	url=url+"?image="+foto;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('foto').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function VerbergFoto(foto){


	document.getElementById('foto').style.visibility = 'hidden';
	document.getElementById('foto').style.display = 'none';
	document.getElementById('foto').innerHTML = '';

}

function LaadStamboom(code){

	document.getElementById('stamboom').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadStamboom.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('stamboom').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function LaadKeuring(code){

	document.getElementById('keuring').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadKeuring.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('keuring').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function LaadGezondheid(code){

	document.getElementById('gezondheid').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadGezondheid.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('gezondheid').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function LaadNakomeling(code){

	document.getElementById('nakomeling').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadNakomeling.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('nakomeling').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function LaadKeurverslagen(code){

	document.getElementById('keurverslagen').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadKeurverslagen.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('keurverslagen').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}

function LaadAanpassen(code){
	
	
	document.getElementById('aanpassen').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';
	
	var xmlhttp = makexmlhttp();
	
	var url="_php/LaadAanpassen.php";
	url=url+"?code="+code;
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange = function(){
		
		if(xmlhttp.readyState == 4){
			
			document.getElementById('aanpassen').innerHTML = xmlhttp.responseText;
		}
	
	}
	
	xmlhttp.send('');
}


var xmlHttp

function HondSuggest(str)
{

document.getElementById('dropdown').innerHTML = '<img src="_images/ajax-loader.gif" width="43" height="11" alt="loading" />';

if (str.length==0)
  { 
  document.getElementById("dropdown").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="_php/HondSuggest.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("dropdown").innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function HideDropdown(){
	
	document.getElementById('dropdown').style.display = 'none';
	document.getElementById('dropdown').style.visibility = 'hidden';
}

function ShowDropdown(){

	document.getElementById('dropdown').style.display = 'block';
	document.getElementById('dropdown').style.visibility = 'visible';
}