function check(){
	var fout = "";
	if( $('t5').value.length < 2){ fout = fout+"\n- Bedrijfsnaam niet ingevuld";}
	if( $('t1').value.length < 2){ fout = fout+"\n- Plaatsnaam niet ingevuld";}
	if( $('t2').value.length < 2){ fout = fout+"\n- Straatnaam niet ingevuld";}
	if( $('t3').value.length < 1){ fout = fout+"\n- Huisnummer niet ingevuld. Vul 0 in als u het niet weet";}
	if( $('t4').value.length < 2){ fout = fout+"\n- Postcode niet ingevuld. Vul 0000AB in als u het niet weet";}
	if( $('lat').value.length < 2 || $('lon').value.length < 2){ fout = fout+"\n- Geen plaats aangegeven op de kaart";}	

	
	if( fout.length > 1){
		alert("De volgende fouten zijn opgetreden:"+fout);
		return false;
	}else{
		return true;
	}
	
} 


var mapT;
var marker;

var gmapTspot_lat = 0;
var gmapTspot_lon = 0;

function google_load_toevoegen(){


    if (GBrowserIsCompatible()) {
        mapT = new GMap2(document.getElementById("mapT"));
        mapT.addControl(new GLargeMapControl());
        mapT.addControl(new GMapTypeControl());
        mapT.setCenter(new GLatLng(52, 5), 6);
        geocoder = new GClientGeocoder();
        GEvent.addListener(mapT, "click", function(clickmarker, point){
            marker = createMarkerT(point);
        });
        
    }
    
}



function createMarkerT(point){
    if (marker) 
        mapT.removeOverlay(marker);
    marker = new GMarker(point, {
        clickable: false
    });
    mapT.addOverlay(marker);
    marker.openInfoWindowHtml("Coordinaten van <b>" + strip_tags($('t5').value) + "</b>:<br/><b>Lat: " + point.lat() + "<br/>Lon: " + point.lng() + "</b>");
    gmapTspot_lat = point.lat();
    gmapTspot_lon = point.lng();
    document.getElementById('lat').value = point.lat();
    document.getElementById('lon').value = point.lng();
    return marker;
}

var aantal_cliks = 0;
function addAddressToMapT(response){

    mapT.clearOverlays();
    if (!response || response.Status.code != 200) {
        if (aantal_cliks < 1) {
            aantal_cliks++;
        }
    }
    else {
        aantal_cliks = 0;
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
        
        document.getElementById('lat').value = place.Point.coordinates[1];
        document.getElementById('lon').value = place.Point.coordinates[0];
        
        lat_w = place.Point.coordinates[1];
        lng_w = place.Point.coordinates[0];
        mapT.setCenter(new GLatLng(lat_w, lng_w), 16);
        
        marker = createMarkerT(point);
        
    }
    
    
    
     
}
 
function showLocationT(){
	var address = $('t1').value+" "+$('t2').value; 
    geocoder.getLocations(address, addAddressToMapT);
} 

function findLocationT(address){

    showLocationT();  
}

function show_cords(lat,lng){
	point = new GLatLng(lat,lng);

        mapT.setCenter(point, 16);
        
        marker = createMarkerT(point);
}

function findpostcode(bel){
	if(bel == 1){
		if($('nl').checked){
			
			
	
			$("t4").value = ""
			$("t4").style.background = "url('/i/loadingS.gif') left no-repeat";
			var req = new Request({
			method: 'get',
			url: '/inc/tools/postcode/postcode_achterhalen.php',
	
			onSuccess: function(txt){
				$("t4").style.background = "";
				$("t4").value = txt;
			}
	
		}).send("straat=" + strip_tags($('t2').value.replace(" ", "+")) + "&huisnr=" + strip_tags($('t3').value.replace(" ", "+")) + "&plaats=" + strip_tags($('t1').value.replace(" ", "+")));
		
		}
		
	}
    
       
}

