window.onload = function(){
	if (GBrowserIsCompatible()) {
		 var map = new GMap2(document.getElementById("gMap"));
		 map.setCenter(new GLatLng(50.50571,4.39872), 13);
		 map.addControl(new GSmallMapControl());
		 map.addControl(new GMapTypeControl());
		  
		 var marker = new GMarker(new GLatLng(50.50454,4.3985));
		 map.addOverlay(marker);
	}
	
	var inputTag = $('adrFrom');
	inputTag.onclick = function(){
		inputTag.value = '';
	}
	inputTag.onblur = function(){
		if(inputTag.value == ''){
			inputTag.value = 'Votre adresse';
		}
	}

}

var win = null;
function popup(mypage,myname,w,h,scroll,pos){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings	='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win			=	window.open(mypage,myname,settings);
}


function goto(){
	var adrFrom = $('adrFrom').value;
	if(adrFrom != '' && adrFrom != 'Votre adresse'){
		var url = "http://maps.google.be/maps?daddr=63%20Rue%20Picolome,%206238%20luttre%20Belgique&saddr="+ escape(adrFrom) +"&dummy=Camping%20Trieu%20du%20bois";
		popup(url,'','950','650','no','center');
	}
}


function sendContact(){
	
	var name 			= 	$F('name');
	var mail 			= 	$F('mail');
	var msg				=	$F('msg');
	var subject 		=	$F('subject');
	
	$('loader').style.display = "block";

	var validationMSG 	= Array();
	validationMSG[0]	= "ERREUR: certaines donn\351es requises n'ont pas \351t\351 fournies.";
	validationMSG[1]	= "Le champ NOM PRENOM doit \352tre rempli.";
	validationMSG[2]	= "L' ADRESSE E-MAIL n'est pas correcte.";
	validationMSG[3]	= "Le champ SUJET doit \352tre rempli.";
	validationMSG[4]	= "Le champ MESSAGE doit \352tre rempli.";
	validationMSG[5]	= "Merci, nous avons bien re\347u votre message<br />vous pouvez fermer cette fen\352tre en <a href=\"javascript:Modalbox.hide()\">cliquant ici</a>";

	new Ajax.Request('inc/contact.inc.php', {
		method:'post',
		parameters: 'name=' + name + '&mail=' + mail +'&subject=' + subject +'&msg=' + msg,
		onComplete: function(requester){
			var arrResponce = requester.responseText;
			var arrResponce = arrResponce.split("|");

			var msgTxt		= "";

			for(i = 0; i <= arrResponce.length - 1; i++ ){
				msgTxt	 	+= validationMSG[arrResponce[i]] + "\n";
			}

			if(arrResponce == '5'){
				Modalbox.show('<div id="valide">' + validationMSG[arrResponce] + '</div>',{title: 'Nous contacter par internet', width: 600});
			}else{
				alert(unescape(msgTxt));
			}
			
			$('loader').style.display = "none";
		}
	});

}
