function formOpdracht()
	{
	contentNormal();
	changeForm('start',1);
	changeFormRegel('start');
	
	changeRegels();
	hideTFILayers();
	document.opdracht.Nrorder.focus();
	}

function changeVerlader(verladerid)
	{
	viewAjax = 'processNote';

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
		{
		alert ("Uw browser ondersteund geen Ajax");
		return;
		}

	var url="TFI/changeVerlader.php?verladerid="+verladerid;
	
	document.getElementById(viewAjax).innerHTML="";
	xmlHttp.onreadystatechange=viewChanged;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null); 
	
	if(xmlHttp.responseText=='ok')
		{
		changeView('TFI/fOpdracht','no','','','ASC');
		setTimeout('formOpdracht()',500);
		}
	return;
	}
function hideTFILayers()
	{
	hideLayer('zoekDatum');
	hideLayer('toonAdresboek');
	
	var elms = document.getElementsByTagName('div');
	for(var i = 0, maxI = elms.length; i < maxI; ++i) 
		{        
		switch(elms[i].id)
			{
			case "selecteerPlus":
			case "selecteerADR":
			case "plusreferentie":
			case "formVerzendeenheid":
			hideLayer(elms[i].id);
			if(elms[i].id=="plusreferentie")
				{
				var ref = document.opdracht.Plusreferentie.value;
					if(ref.length>5)
					{
					showLayer(elms[i].id,'start');
					}
				}
			break;
			}
		}
	
	}


function hideRembours(rmb)
	{
	if(rmb==0)
		{
		document.opdracht.Rembours.value="";
		hideLayer('rembours');
		}
	else
		{
		if(document.getElementById('rembours'))
			{
			showLayer('rembours','start');	
			}
		else
			{
			setTimeout('showLayer(\'rembours\',\'start\')',1000);
			}
		}
	}

function confirmJoin()
	{
	// Alleen uitvoeren als de opdracht niet al is samengevoegd
	if(document.opdracht.OpdrachtID.value=="" || document.opdracht.OpdrachtID.value==null)
		{
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
			{
			alert ("Uw browser ondersteund geen Ajax");
			return;
			}

		var url="TFI/check_Adres.php";
		var zndsoort="zndsoort="+document.opdracht.Zndsoort.value;
		// Niet samenvoegen bij doorleveringen
		if(zndsoort!='D')
			{
			if(zndsoort=='A')
				{
				var values=zndsoort+"&geapost="+document.opdracht.afhpostcode.value;
				values=values+"&geastraat="+document.opdracht.afhstraat.value;
				values=values+"&geahuisnr="+document.opdracht.afhhuisnummer.value;
				values=values+"&gealand="+document.opdracht.afhkdland.value;
				}
			else
				{
				var values=zndsoort+"&geapost="+document.opdracht.geapostcode.value;
				values=values+"&geastraat="+document.opdracht.geastraat.value;
				values=values+"&geahuisnr="+document.opdracht.geahuisnummer.value;
				values=values+"&gealand="+document.opdracht.geakdland.value;
				}
			// Datum meenemen in vergelijking
			values = values+"&dtzend="+document.opdracht.Dtzend.value;
			
			xmlHttp.onreadystatechange=viewChanged;
			xmlHttp.open("POST",url,false);
			xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			xmlHttp.send(values);
	
			var cadres = xmlHttp.responseText;
			
			var aAdres = cadres.split('****');
			
			if(cadres!='nieuw' && aAdres.length>1)
				{	
				var akkoord = confirm('Er is al een andere opdracht geboekt voor ' + aAdres[1] + ', wilt u deze samenvoegen?');
				
				if(akkoord)
					{	
					document.opdracht.OpdrachtID.value=aAdres[0];
					// Zendingtype niet wijzigen als een opdracht wordt gewijzigd (ivm onjuiste barcodes)
					document.opdracht.Zndsoort.disabled=1;
					
					getOpdracht(document.opdracht.Zndsoort.value,aAdres[0]);
					getOpdrachtRegels(aAdres[0]);
					}
				}
			
			}
		}
	contentNormal();
	hideTFILayers();
	return;
	}

function vulAdres(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12)
	{
	s0 = decodeURIComponent((s0 + '').replace(/\+/g, '%20'));
	s1 = decodeURIComponent((s1 + '').replace(/\+/g, '%20'));
	s2 = decodeURIComponent((s2 + '').replace(/\+/g, '%20'));
	s3 = decodeURIComponent((s3 + '').replace(/\+/g, '%20'));
	s4 = decodeURIComponent((s4 + '').replace(/\+/g, '%20'));
	s5 = decodeURIComponent((s5 + '').replace(/\+/g, '%20'));
	s6 = decodeURIComponent((s6 + '').replace(/\+/g, '%20'));
	s7 = decodeURIComponent((s7 + '').replace(/\+/g, '%20'));
	s8 = decodeURIComponent((s8 + '').replace(/\+/g, '%20'));
	s9 = decodeURIComponent((s9 + '').replace(/\+/g, '%20'));
	s10 = decodeURIComponent((s10 + '').replace(/\+/g, '%20'));
	s11 = decodeURIComponent((s11 + '').replace(/\+/g, '%20'));
	s12 = decodeURIComponent((s12 + '').replace(/\+/g, '%20'));


	if(s0=='afz')
		{
		document.opdracht.afznaam.value=s2;
		document.opdracht.afznaam2.value=s3;
		document.opdracht.afzstraat.value=s4;
		document.opdracht.afzhuisnummer.value=s5;
		document.opdracht.afzpostcode.value=s6;
		document.opdracht.afzplaats.value=s7;
		document.opdracht.afzkdland.value=s8;
		document.opdracht.zoekafz.value=s1;	
		contentNormal();
		hideTFILayers();
		}

	if(s0=='afh')
		{	
		document.opdracht.afhnaam.value=s2;
		document.opdracht.afhnaam2.value=s3;
		document.opdracht.afhstraat.value=s4;
		document.opdracht.afhhuisnummer.value=s5;
		document.opdracht.afhpostcode.value=s6;
		document.opdracht.afhplaats.value=s7;
		document.opdracht.afhkdland.value=s8;
		document.opdracht.Afleverinstructie.value=s9;
		document.opdracht.afhtelefoon.value=s10;
		document.opdracht.afhemail.value=s11;
		document.opdracht.zoekafh.value=s1;	
		/*document.opdracht.smstelefoon.value=s12;*/
		getPlus();
		confirmJoin();
		}

	if(s0=='gea')
		{	
		document.opdracht.geanaam.value=s2;
		document.opdracht.geanaam2.value=s3;
		document.opdracht.geastraat.value=s4;
		document.opdracht.geahuisnummer.value=s5;
		document.opdracht.geapostcode.value=s6;
		document.opdracht.geaplaats.value=s7;
		document.opdracht.geakdland.value=s8;
		document.opdracht.Afleverinstructie.value=s9;
		document.opdracht.geatelefoon.value=s10;
		document.opdracht.geaemail.value=s11;
		document.opdracht.zoekgea.value=s1;
		/*document.opdracht.smstelefoon.value=s12;*/
		getPlus();
		confirmJoin();
		}

	if(s0=='adr' || s0=='adrgea' || s0=='adrafz' || s0=='adrafh')
		{
		if(s0.length>3)
			{
			document.adminForm.Type.value=s0.substr(3);
			}
		
		document.adminForm.Naam.value=s2;
		document.adminForm.Naam2.value=s3;
		document.adminForm.Straat.value=s4;
		document.adminForm.Huisnummer.value=s5;
		document.adminForm.Postcode.value=s6;
		document.adminForm.Plaats.value=s7;
		document.adminForm.Kdland.value=s8;
		document.adminForm.Opmerking.value=s9;
		document.adminForm.Telefoon.value=s10;
		document.adminForm.Email.value=s11;
		document.adminForm.AdresKode.value=s1;
		}
	}

function getPlus()
	{
	viewAjax = 'selecteerPlus';

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
		{
		alert ("Uw browser ondersteund geen Ajax");
		return;
		}

	var url="TFI/gServices.php";
	var values="zndsoort="+document.opdracht.Zndsoort.value+"&kdland="+document.opdracht.geakdland.value;

	var services=new Array();
	document.opdracht.plusselect.checked=false;
	
	// Plusdiensten blokkeren voor pakketzendingen
	if(document.opdracht.Zndsoort.value=='P')
		{
		//document.opdracht.plusselect.checked=false;
	//	document.opdracht.plusselect.disabled=1;
		
		var plusdiensten = document.opdracht.elements["plus[]"];
		if(plusdiensten && plusdiensten.length)
			{	
			for(i=0;i<plusdiensten.length;i++)
				{
			//	document.opdracht.elements['plus[]'][i].checked=false;
				}
			}
		}
	else
		{	
		document.opdracht.plusselect.disabled=0;
		}
		
	s=0;
	if(document.opdracht.elements["plus[]"])
		{
		var plusdiensten = document.opdracht.elements["plus[]"];
		if(plusdiensten.length)
			{	
			for(i=0;i<plusdiensten.length;i++)
				{
				if(document.opdracht.elements['plus[]'][i].checked==true)
					{
					document.opdracht.plusselect.checked=true;
					services[s]=document.opdracht.elements['plus[]'][i].value;
					s++;
					}
				}	
			}
		}
	else
		{
		document.opdracht.plusselect.checked=false;
		}
	var values=values+"&services="+services;
	
	document.getElementById(viewAjax).innerHTML="";
	xmlHttp.onreadystatechange=viewChanged;
	xmlHttp.open("POST",url,false);
	xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xmlHttp.send(values);
	
	document.getElementById(viewAjax).innerHTML=xmlHttp.responseText;
	
	if(document.opdracht.elements["plus[]"])
		{
		var plusdiensten = document.opdracht.elements["plus[]"];
		if(plusdiensten.length)
			{	
			for(i=0;i<plusdiensten.length;i++)
				{
				
				if(in_array(document.opdracht.elements['plus[]'][i].value,services) || document.opdracht.elements['plus[]'][i].checked==true)
					{
					document.opdracht.elements['plus[]'][i].checked=true;
					document.opdracht.plusselect.checked=true;
					}
				}
			}
		}
	else
		{
		document.opdracht.plusselect.checked=false;
		}
	}

function selecteerPlus(e)
	{
	if(document.opdracht.elements["plus[]"])
		{
		var plusdiensten = document.opdracht.elements["plus[]"];
		s=0	
		for(i=0;i<plusdiensten.length;i++)
			{
			if(document.opdracht.elements['plus[]'][i].checked==true)
				{
				s++;
				}
			}
		if(s>0)
			{
			document.opdracht.plusselect.checked=true;
			}
		else
			{
			document.opdracht.plusselect.checked=false;
			}
		}
	else
		{
		document.opdracht.plusselect.checked=false;
		}
	
	getPlus();
	showLayer('selecteerPlus',e);
	contentNormal();
	}

function verbergPlus()
	{
	hideTFILayers();
	
	if(document.opdracht.elements["plus[]"])
		{
		var plusdiensten = document.opdracht.elements["plus[]"];
		s=0	
		for(i=0;i<plusdiensten.length;i++)
			{
			if(document.opdracht.elements['plus[]'][i].checked==true)
				{
				s++;
				}
			if(s>0)
				{
				document.opdracht.plusselect.checked=true;
				}
			else
				{
				document.opdracht.plusselect.checked=false;
				}
			}
		}
	else
		{
		document.opdracht.plusselect.checked=false;
		}
	
	}

function getADR()
{
viewAjax = 'selecteerADR';

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
	{
	alert ("Uw browser ondersteund geen Ajax");
	return;
	}

var url="TFI/gADR.php";
var values="zndsoort="+document.opdracht.Zndsoort.value+"&kdland="+document.opdracht.geakdland.value;

var services=new Array();
document.opdracht.adrselect.checked=false;

// Plusdiensten blokkeren voor pakketzendingen
if(document.opdracht.Zndsoort.value=='P')
	{
	document.opdracht.adrselect.checked=false;
	document.opdracht.adrselect.disabled=1;
	var adrregels = document.opdracht.elements["adr[]"];
	
	for(i=0;i<adrregels.length;i++)
		{
		document.opdracht.elements['adr[]'][i].checked=false;
		}
	}
else
	{	
	document.opdracht.adrselect.disabled=0;
	}
	
s=0;
if(document.opdracht.elements["adr[]"])
	{
	var adrregels = document.opdracht.elements["adr[]"];
	
	for(i=0;i<adrregels.length;i++)
		{
		if(document.opdracht.elements['adr[]'][i].checked==true)
			{
			document.opdracht.adrselect.checked=true;
			services[s]=document.opdracht.elements['adr[]'][i].value;
			s++;
			}
		}
	}
var values=values+"&services="+services;

document.getElementById(viewAjax).innerHTML="";
xmlHttp.onreadystatechange=viewChanged;
xmlHttp.open("POST",url,false);
xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlHttp.send(values);
document.getElementById(viewAjax).innerHTML=xmlHttp.responseText;

if(document.opdracht.elements["adr[]"])
	{
	var adrregels = document.opdracht.elements["adrs[]"];

	for(i=0;i<plusdiensten.length;i++)
		{
		if(in_array(document.opdracht.elements['adr[]'][i].value,services) || document.opdracht.elements['adr[]'][i].checked==true)
			{
			document.opdracht.elements['adr[]'][i].checked=true;
			document.opdracht.plusselect.checked=true;
			}
		}
	}
}
function selecteerADR(e)
{
if(document.opdracht.elements["adr[]"])
	{
	var adrregels = document.opdracht.elements["adr[]"];
	s=0	
	for(i=0;i<adrregels.length;i++)
		{
		if(document.opdracht.elements['adr[]'][i].checked==true)
			{
			s++;
			}
		}
	if(s>0)
		{
		document.opdracht.adrselect.checked=true;
		}
	else
		{
		document.opdracht.adrselect.checked=false;
		}
	}
else
	{
	document.opdracht.adrselect.checked=false;
	}

getADR();
showLayer('selecteerADR',e);
}

function verbergADR()
{
hideTFILayers();

if(document.opdracht.elements["adr[]"])
	{
	var adrregels = document.opdracht.elements["adr[]"];
	s=0	
	for(i=0;i<adrregels.length;i++)
		{
		if(document.opdracht.elements['adr[]'][i].checked==true)
			{
			s++;
			}
		if(s>0)
			{
			document.opdracht.adrselect.checked=true;
			}
		else
			{
			document.opdracht.adrselect.checked=false;
			}
		}
	}
else
	{
	document.opdracht.adrselect.checked=false;
	}

}

function stuurDatum(view,table,field,str1,str2,str3,str4,str5)
	{
	if(view=='fOpdracht')
		{
		if(field=='Dtzend')
			{
			eval( "document.opdracht." + field + ".value = str3 + '-' + str2 + '-' + str1;");
			return;
			}
		}
	else
		{
		
		if(field=='vandatum' || field=='totdatum')
			{
			
			if(document.vantotdatum)
			{
			eval( "document.vantotdatum." + field + ".value = str3 + '-' + str2 + '-' + str1;");
			
			
			if(document.vantotdatum.vandatum.value!='' && document.vantotdatum.vandatum.value!='undefined' && document.vantotdatum.totdatum.value!='' && document.vantotdatum.totdatum.value!='undefined')
				{
				filterGrid(field,str3 + '-' + str2 + '-' + str1,'',view,table,'no');
				}
			}
			}
		else
			{
			eval( "document.filter_tabel." + field + ".value = str3 + '-' + str2 + '-' + str1;");
			filterGrid(field,str3 + '-' + str2 + '-' + str1,'',view,table,'no');
			}
		return;
		}
	
	} 

function showAdresboek(depot,stamnr,str,sortering,pagina)
	{
	if (str.length>0)
		{
		viewAjax = 'toonAdresboek';
		
	

		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
			{
			alert ("Uw browser ondersteund geen Ajax");
			return;
			}

		var url="TFI/tAdres.php";
		var values="filter_Type="+str+"&sortering="+sortering+"&stamnr="+stamnr+"&depot="+depot+"&pagina="+pagina;
	
		if(document.forms['filter_adres'])
		{
		for(i=0; i<document.forms['filter_adres'].elements.length; i++)
			{
			if(document.forms['filter_adres'].elements[i].value!='' && document.forms['filter_adres'].elements[i].name!='undefined')
				{
				values = values+"&"+document.forms['filter_adres'].elements[i].name+"="+document.forms['filter_adres'].elements[i].value;
				}
			}
			
		}
		
		xmlHttp.onreadystatechange=viewChanged;

		xmlHttp.open("POST",url,false);
		xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlHttp.send(values);
		document.getElementById(viewAjax).innerHTML=xmlHttp.responseText;
		}
	}

function getOpdracht(zndsoort,opdrachtid)
	{
	viewAjax = 'searchAdress';
	document.getElementById(viewAjax).innerHTML="";

	if(zndsoort!="" && zndsoort!=null && zndsoort!="undefined" &opdrachtid!="" && opdrachtid!=undefined)
		{	
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
			{
			alert ("Uw browser ondersteunt geen JavaScript");
			return;
			}
		var url="TFI/gOpdracht.php";

		var values= "zndsoort="+zndsoort+"&opdrachtid="+opdrachtid;
				
	xmlHttp.onreadystatechange=viewChanged;
	xmlHttp.open("POST",url,false);
	xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xmlHttp.send(values);  

	var Opdracht= xmlHttp.responseText;

	// Melding geven als opdracht niet is gevonden
	if(Opdracht=="")
		{
		alert('Onbekende Opdracht');
		return;
		}
	else
		{	
		aOpdracht = Opdracht.split('--');
		
		document.opdracht.OpdrachtID.value=aOpdracht[0];
		document.opdracht.Zndsoort.value=aOpdracht[1];
		document.opdracht.Zendingnummer.value=aOpdracht[4];
		document.opdracht.Dtzend.value=aOpdracht[5];
		document.opdracht.Nrorder.value=aOpdracht[6];
		
		document.opdracht.zoekafz.value="";
		document.opdracht.afznaam.value=aOpdracht[24];
		document.opdracht.afznaam2.value=aOpdracht[25];
		document.opdracht.afzstraat.value=aOpdracht[27];
		document.opdracht.afzhuisnummer.value=aOpdracht[28];
		document.opdracht.afzpostcode.value=aOpdracht[29];
		document.opdracht.afzplaats.value=aOpdracht[30];
		document.opdracht.afzkdland.value=aOpdracht[31];
		
		document.opdracht.zoekafh.value="";
		document.opdracht.afhnaam.value=aOpdracht[7];
		document.opdracht.afhnaam2.value=aOpdracht[8];
		document.opdracht.afhtelefoon.value=aOpdracht[9];
		document.opdracht.afhemail.value=aOpdracht[37];
		document.opdracht.afhstraat.value=aOpdracht[10];
		document.opdracht.afhhuisnummer.value=aOpdracht[11];
		document.opdracht.afhpostcode.value=aOpdracht[12];
		document.opdracht.afhplaats.value=aOpdracht[13];
		document.opdracht.afhkdland.value=aOpdracht[14];

		document.opdracht.zoekgea.value="";
        document.opdracht.geanaam.value=aOpdracht[15];
   		document.opdracht.geanaam2.value=aOpdracht[16];
   		document.opdracht.geatelefoon.value=aOpdracht[17];
   		document.opdracht.geaemail.value=aOpdracht[18];
		document.opdracht.geastraat.value=aOpdracht[19];
		document.opdracht.geahuisnummer.value=aOpdracht[20];
		document.opdracht.geapostcode.value=aOpdracht[21];
		document.opdracht.geaplaats.value=aOpdracht[22];
		document.opdracht.geakdland.value=aOpdracht[23];
		
   		                                              
        document.opdracht.Afleverinstructie.value=aOpdracht[26];
   		document.opdracht.Rembours.value=aOpdracht[32];
   		document.opdracht.Betaalwijze.value=aOpdracht[33];
   		if(aOpdracht[33]!='')
			{
   			document.opdracht.Betaalwijze.value=aOpdracht[33];
   			document.opdracht.Valuta.value=aOpdracht[34];
			}
   		else
   			{
   			document.opdracht.Betaalwijze.value='C';
   			document.opdracht.Valuta.value='EUR';
   			}
   		

   		
   		
   		aPlusdiensten =aOpdracht[36].split('**');
   		if(plusdiensten = document.opdracht.elements["plus[]"])
		
   		
   			{
   			for(i=0;i<plusdiensten.length;i++)
   				{
   				if(in_array(document.opdracht.elements['plus[]'][i].value, aPlusdiensten))
   					{
   					document.opdracht.plusselect.checked=true;	
   					document.opdracht.elements['plus[]'][i].checked=true;
   					}
   				}
   			}
		document.opdracht.Plusreferentie.value=aOpdracht[35];
		                                
		return;
		}
	}
	return;
	}

function fillAdress(f,s)
    {

	viewAjax = 'searchAdress';
    document.getElementById(viewAjax).innerHTML="";

	if(f!="" && f!=null && f!="undefined")
		{	
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
	 		{
	  		alert ("Uw browser ondersteunt geen JavaScript");
	  		return;
	  		}
		var url="TFI/gAdress.php";
		var values ="";
		if(s=="" || s==undefined)
			{
			if(f=="afz" && document.opdracht.afzpostcode.value!=""){values= "postcode="+document.opdracht.afzpostcode.value+"&land="+document.opdracht.afzkdland.value;}
			if(f=="afh" && document.opdracht.afhpostcode.value!=""){values= "postcode="+document.opdracht.afhpostcode.value+"&land="+document.opdracht.afhkdland.value;}
			if(f=="gea" && document.opdracht.geapostcode.value!=""){values= "postcode="+document.opdracht.geapostcode.value+"&land="+document.opdracht.geakdland.value;}
			if(f.substr(0,3)=="adr" && document.adminForm.Postcode.value!=""){values= "postcode="+document.adminForm.Postcode.value+"&land="+document.adminForm.Kdland.value;}
			}
		else
			{
			values= "type="+f+"&adreskode="+s;
			}		
		//alert(values);
		if(values!="")
		{
		xmlHttp.onreadystatechange=viewChanged;
		xmlHttp.open("POST",url,false);
		xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlHttp.send(values);  
		
		var Adress= xmlHttp.responseText;
	
		// Melding geven als adres niet is gevonden
		if(Adress=="")
			{
			if(s=="" || s==undefined)
				{
			//	if(f=="afz"){document.opdracht.afzpostcode.focus();}
			//	if(f=="afh"){document.opdracht.afhpostcode.focus();}
			//	if(f=="gea"){document.opdracht.geapostcode.focus();}
				if(f.substr(0,3)=="adr"){document.adminForm.Postcode.focus();}
				//alert('Ongeldige postcode');
				}
			else
				{
				vulAdres(f,s,'','','','','','','003','','','');
			//	if(f=="afz"){document.opdracht.afzpostcode.focus();}
			//	if(f=="afh"){document.opdracht.afhpostcode.focus();}
			//	if(f=="gea"){document.opdracht.geapostcode.focus();}
				if(f.substr(0,3)=="adr"){document.adres.Postcode.focus();}
				//if(f=="afh"){document.opdracht.zoekafh.focus();}
				//if(f=="gea"){document.opdracht.zoekgea.focus();}
				
				//if(f.substr(0,3)=="adr"){document.adres.ZoekKode.focus();}
				//alert('Adres niet gevonden');
				}
			return;
			}
		else
			{	
			aAdress = Adress.split('--');
			
			if(s=="" || s==undefined)
				{
			if(f=="afz")
				{
				document.opdracht.afzstraat.value=aAdress[0];
				document.opdracht.afzpostcode.value=aAdress[1];
				document.opdracht.afzplaats.value=aAdress[2];
				document.opdracht.afzhuisnummer.focus();
				return;
				}
			if(f=="afh")
				{
				document.opdracht.afhstraat.value=aAdress[0];
				document.opdracht.afhpostcode.value=aAdress[1];
				document.opdracht.afhplaats.value=aAdress[2];
				document.opdracht.afhhuisnummer.focus();
				confirmJoin();
				return;
				}
			if(f=="gea")
				{
				document.opdracht.geastraat.value=aAdress[0];
				document.opdracht.geapostcode.value=aAdress[1];
				document.opdracht.geaplaats.value=aAdress[2];
				confirmJoin();
				document.opdracht.geahuisnummer.focus();
				return;
				}  
			if(f.substr(0,3)=='adr')
				{
				
				document.adminForm.Straat.value=aAdress[0];
				document.adminForm.Postcode.value=aAdress[1];
				document.adminForm.Plaats.value=aAdress[2];
				document.adminForm.Huisnummer.focus();
				return;
			}
				}
			else
				{
				vulAdres(aAdress[0],aAdress[1],aAdress[2],aAdress[3],aAdress[4],aAdress[5],aAdress[6],aAdress[7],aAdress[8],aAdress[9],aAdress[10],aAdress[11],aAdress[12])
				}	
			}
		}
    	}
	return;
    }

function changeForm(event,rembours)
	{
	// Alleen remboursen tonen als land is toegestaan
	hideRembours(rembours);

	// 	Aanpassen te selecteren plusleveringen
	getPlus();
	
	// Bij pakketzendingen alleen de verzendeenheid collo beschikbaar maken
	if(document.opdracht.Zndsoort.value=='P')
		{
		document.opdrachtregel.VerzendeenheidID.disabled=1;
		document.opdrachtregel.Aantal.value=1;
		document.opdrachtregel.Aantal.disabled=1;
		}
	else
		{
		document.opdrachtregel.VerzendeenheidID.disabled=0;
		document.opdrachtregel.Aantal.disabled=0;
		}
	
	// Bij afhalers alleen afhaaladres tonen en remboursvelden verbergen
	if(document.opdracht.Zndsoort.value=='A' || document.opdracht.Zndsoort.value=='D')
		{
		showLayer('afhaaladres','start');
		if(document.opdracht.Zndsoort.value=='A')
			{
			if(document.opdracht.zoekgea.value!='')
				{
				document.opdracht.zoekafh.value=document.opdracht.zoekgea.value;
				document.opdracht.zoekgea.value="";
				}
			
			for(i=0; i<document.forms['opdracht'].elements.length; i++)
				{
				if(field = document.forms['opdracht'].elements[i].name)
					{
					c=0;
					if(document.forms['opdracht'].elements[i].value!='' && field.substr(0,3)=='gea')
						{
						if(field=='afhnaam')
							{
							c=1;
							}
						if(c>0)
							{
							eval("document.opdracht.afh" + field.substr(3) +".value=document.forms['opdracht'].elements[i].value");
							document.forms['opdracht'].elements[i].value="";
							}
						}
					}
				}
		
			hideLayer('leveradres');
			hideRembours(0);	
			}
		else
			{
			showLayer('leveradres','start');	
			}
		}
	else
		{
		// Bij leveringen alleen leveradres tonen
		hideLayer('afhaaladres');
		if(document.opdracht.zoekafh.value!='')
			{
			document.opdracht.zoekgea.value=document.opdracht.zoekafh.value;
			document.opdracht.zoekafh.value="";
			}
		
		for(i=0; i<document.forms['opdracht'].elements.length; i++)
			{
			if(field = document.forms['opdracht'].elements[i].name)
				{
				c=0;
				if(document.forms['opdracht'].elements[i].value!='' && field.substr(0,3)=='afh')
					{
					if(field=='geanaam')
						{
						c=1;
						}
					if(c>0)
						{
						eval("document.opdracht.gea" + field.substr(3) +".value=document.forms['opdracht'].elements[i].value");
						document.forms['opdracht'].elements[i].value="";
						}
					}
				}
			}
		showLayer('leveradres','start');
		}
	
	var mainobj = document.getElementById('content');
	mainobj.style.filter= "alpha(opacity=100)";
	return; 
	
	}

function delOpdracht(opdrachtid)
	{
	viewAjax = 'searchAdress';
    document.getElementById(viewAjax).innerHTML="";

	if(opdrachtid!="" && opdrachtid!=null && opdrachtid!="undefined")
		{	
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
			{
			alert ("Uw browser ondersteunt geen JavaScript");
			return;
			}
		var url="TFI/delOpdracht.php";
		var values= "opdrachtid="+opdrachtid;
	
		xmlHttp.onreadystatechange=viewChanged;
		xmlHttp.open("POST",url,false);
		xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlHttp.send(values);
		changeView('TFI/dagoverzicht','no','','','ASC');
		
		}
	}

function delAdres(adresid,sortering,pagina)
	{
	viewAjax = 'searchAdress';
	document.getElementById(viewAjax).innerHTML="";

	if(adresid!="" && adresid!=null && adresid!="undefined")
		{	
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
			{
			alert ("Uw browser ondersteunt geen JavaScript");
			return;
			}
		var url="TFI/delAdres.php";
		var values="adresid="+adresid;
		var values2="adresid="+adresid+"&sortering="+sortering+"&pagina="+pagina;
		
		if(document.forms['filter_tabel'])
			{
			for(i=0; i<document.forms['filter_tabel'].elements.length; i++)
				{
				if(document.forms['filter_tabel'].elements[i].value!='' && document.forms['filter_tabel'].elements[i].name!='undefined')
					{
					values2 = values2+"&"+document.forms['filter_tabel'].elements[i].name+"="+document.forms['filter_tabel'].elements[i].value;
					}
				}
			}
		
		xmlHttp.onreadystatechange=viewChanged;
		xmlHttp.open("POST",url,false);
		xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlHttp.send(values);
		
		viewAjax = 'content';
		var url="TFI/fAdres.php";
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
			{
			alert ("Uw browser ondersteund geen Ajax");
			return;
			}
		xmlHttp.onreadystatechange=viewChanged;

		xmlHttp.open("POST",url,false);
		xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlHttp.send(values2);
		document.getElementById(viewAjax).innerHTML=xmlHttp.responseText;
		}
	}

function filterAjax(view,sortering,pagina)
	{
	if(view.length>0)
		{
		viewAjax = 'content';
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
			{
			alert ("Uw browser ondersteund geen Ajax");
			return;
			}

		var url=view+".php";
		var values="sortering="+sortering+"&pagina="+pagina;
	
		if(document.forms['filter_tabel'])
		{
		for(i=0; i<document.forms['filter_tabel'].elements.length; i++)
			{
			if(document.forms['filter_tabel'].elements[i].value!='' && document.forms['filter_tabel'].elements[i].name!='undefined')
				{
				values = values+"&"+document.forms['filter_tabel'].elements[i].name+"="+document.forms['filter_tabel'].elements[i].value;
				}
			}
			
		}
		
		xmlHttp.onreadystatechange=viewChanged;

		xmlHttp.open("POST",url,false);
		xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlHttp.send(values);
		document.getElementById(viewAjax).innerHTML=xmlHttp.responseText;
		}
	}

function verzend_ve()
	{
	var akkoord = confirm('Heeft u alle etiketten en de verzendlijst geprint van de opdrachten die worden verzonden?');
	
	if(akkoord)
		{
		changeView('TFI/createVebestand','no','');
		}
	
	}



