// JavaScript Document

function load() {
  if (GBrowserIsCompatible()) {
	var map = new GMap2(document.getElementById("kaart"));
	map.setCenter(new GLatLng(51.3286, 5.981959), 17);

	var baseIcon = new GIcon();
	baseIcon.shadow = "/img/map_shadow.png";
	baseIcon.iconSize = new GSize(20, 34);
	baseIcon.shadowSize = new GSize(37, 34);
	baseIcon.iconAnchor = new GPoint(9, 34);
	baseIcon.infoWindowAnchor = new GPoint(9, 2);
	baseIcon.infoShadowAnchor = new GPoint(18, 25);

	var icon = new GIcon(baseIcon);
	icon.image = "/img/map_marker.png";
	var point = new GLatLng(51.328574, 5.981981);
	var marker = new GMarker(point, icon);
	
	GEvent.addListener(map, "click", function() {
	  var center = map.getCenter();
	  window.open("http://maps.google.nl/?ie=UTF8&om=1&z=17&ll=51.3286,5.981959&spn=0.003607,0.012134");
	});

	
	map.addOverlay(marker);

  }
}

window.addEvent('domready', function() {
	
	if (!document.getElementsByTagName) return;
	 var anchors = document.getElementsByTagName("a");
	 for (var i=0; i<anchors.length; i++) {
	   var anchor = anchors[i];
	   if (anchor.getAttribute("href") &&
		   anchor.getAttribute("rel") == "external")
		 anchor.target = "_blank";
	 }
	
	//var contactSlide = new Fx.Slide('con_data',{duration: 1000}).hide();
	var contactSlide = new Fx.Slide('con_data',{duration: 500}).hide();
	$('contact').style.display = 'none';
	
	$('contactklikker').addEvent('click', function() {
		$('contact').style.display = 'block';
		contactSlide.hide();
		contactSlide.slideIn();
		$('contact_sluiten').style.display = 'block';
		setTimeout("load();", 600);
		return false;
	});
	
	$('contact_sluiten').addEvent('click', function() {
		$('contact_sluiten').style.display = 'none';
		GUnload();
		contactSlide.slideOut();
		setTimeout("$('contact').style.display = 'none'", 600);
		return false;
	});

});

function verstuurcontact(){
	
	if(valideer()){
		
		$('contact_versturen').style.display = 'none';
		$('contact_busy').innerHTML = '<img src="/img/loader.gif" alt="loader" style="vertical-align: middle;" />&nbsp;uw bericht wordt verstuurd';
		$('contact_busy').style.display = 'block';
		
		$('formulier').send({onComplete: allesklar});
		//new Ajax('/incl/contact.php', {method: 'post', postbody: $('formulier').toQueryString(), onComplete: allesklar}).request();
	}
	return false;

}

function allesklar(){
	
	$('contact_busy').innerHTML = 'uw bericht is succesvol verstuurd';
	setTimeout("done()", 1000);
	
}

function done(){
	
	$('contact_sluiten').fireEvent('click');
	$('contact_busy').innerHTML = '';
	$('contact_versturen').style.display = 'block';
	
}

function valideer(){

	var naam = $('contact_naam').value;
	var voornaam = $('contact_voornaam').value;
	var email = $('contact_email').value;
	var tekst = $('contact_tekst').value;
	if(naam.length < 2){
		alert('vul uw naam in aub');
		return false;
	}else if(voornaam.length < 2){
		alert('vul uw voornaam in aub');
		return false;
	}else if(email.length < 5){
		alert('vul uw email adres in aub');
		return false;
	}else if(tekst.length < 1){
		alert('vul een vraag of opmerking in aub');
		return false;
	}else{
		return true;
	}
	
}

function clublokaal(){
	window.open('http://www.3hoog.nl/clublokaal/');
}
		