var global = this;
var zpage = 0;
var date_format = "DD/MM/YYYY";
var global_position_x = 0;
var global_position_y = 0;
var timer1;
var formerrors	= new Array(
	'Merci de patienter...',
	'Ce champ est obligatoire!',
	'Ce champ n\'est pas une chaîne alphanumérique valide!',
	'Ce champ n\'est pas une valeur numérique valide!',
	'Ce champ n\'est pas une adresse MAC valide !',
	'Ce champ n\'est pas un email valide!',
	'Ce champ n\'est pas une date valide !\nIl doit être au format JJ/MM/AAAA\nExemple : 21/05/1978 pour le 21 mai 1978',
	'Ce champ est trop long ou trop court!',
	'Ce champ n\'est pas une adresse web valide !',
	'Ce champ n\'est pas une adresse IP valide !',
	'Ce champ contient un(des) caractère(s) interdit(s) dans un SMS!\nLes caractères valides sont les lettres, les chiffres et ()èéùàüñöä+\'"&%/\\*.:,;<>=?@!#-',
	'Ce champ n\'est pas égal au champ ',
	'Ce champ n\'est pas un numéro de téléphone portable valide !',
	'Le mot de passe ne peut contenir que des chiffres et des lettres !'
);
var version=0;
var msie=navigator.appVersion.indexOf("MSIE");
if (msie!=-1){
	temp=navigator.appVersion.split("MSIE");
	ieversion=parseFloat(temp[1]);
}
var firefoxversion = 3;
if (navigator.userAgent.indexOf("Firefox")!=-1) {
	var versionindex=navigator.userAgent.indexOf("Firefox")+8;
	firefoxversion = parseInt(navigator.userAgent.charAt(versionindex));
	//alert("Vous utilisez Firefox "+parseInt(navigator.userAgent.charAt(versionindex)));
}

///************************************* NAVIGATIONS FUNCTIONS ********************************************

// select first top right menu x val
function setActive1(x) {
	zpage=0;
	loadJs("right_menu.php","div_right_menu","","active1="+x);
	if (x==4) {setActive2(x,0);} else {setActive2(x,1);}
}
// select first top right menu x val WITHOUT loading right_menu
function setActive1b(x) {
	loadJs("right_menu.php","div_right_menu","","active1="+x);
}
// select second top right menu y val and open pagex_y.php in center of page
function setActive2(x,y) {
	$("div_right_menu_container2p").hide();
	$("div_right_menu_container2").appear();
	loadJs("right_menu2.php","div_right_menu2","","active1="+x+"&active2="+y);
	if (((x==5)&&(y==3))||((x==1)&&(y==9))||((x==1)&&(y==4))||((x==1)&&(y==5))||((x==1)&&(y==6))||((x==6)&&(y==1))) {
		global_position_x = x;
		global_position_y = y;
		loadJs("page"+x+"_"+y+".php","div_right_content","","");
	}
	else if (x==3) {
		global_position_x = x;
		global_position_y = y;
		loadJs("page"+x+"_"+y+".php","div_right_content","load_videos()","");
	}
	else if ((x==7)&&(y==2)) {
		global_position_x = x;
		global_position_y = y;
		loadJs("page"+x+"_"+y+".php","div_right_content","load_videoem()","");
	}
	else if ((x==7)&&(y==1)) {
		global_position_x = x;
		global_position_y = y;
		loadJs("page"+x+"_"+y+".php","div_right_content","load_videoem()","");
	}
	else if ((x==1)&&(y==7))
		loadJs("page"+x+"_"+y+".php","div_right_content","teaser_tcp()","");
	else
		loadCenter("page"+x+"_"+y+".php");
}
// select second top right PERSONAL menu
function setActive2p(x,y) {
	// condition suivante seulement pour le jeu
	if (!((x==1)&&(y==1)&&(zpage==1))) {
		$("div_right_menu_container2").hide();
		$("div_right_menu_container2p").appear();
	}
	setActive1b(0);
	loadJs("right_menu2p.php","div_right_menu2p","","active1="+x+"&active2="+y);
	// if "Mes clubs"
	if ((x==2)&&(y==1)) 
		loadJs("perso"+x+"_"+y+".php","div_right_content","do_ffgolf_ffgolf_see(0)","");
	// JEU JEU JEU JEU JEU JEU JEU JEU JEU JEU JEU JEU JEU JEU JEU JEU JEU JEU JEU JEU 
	//else if ((x==1)&&(y==1)&&(zpage==1)) {
	//		setActive12b(1,7);
	//		loadJs("teaser.php","div_right_content","teaser_tcp()","");
	//}
	else 
		loadCenter("perso"+x+"_"+y+".php");
}
// select second top right PERSONAL menu WITHOUT loading page center
function setActive2pb(x,y) {
	$("div_right_menu_container2").hide();
	$("div_right_menu_container2p").appear();
	setActive1b(0);
	loadJs("right_menu2p.php","div_right_menu2p","","active1="+x+"&active2="+y);
}
// select first top right menu x val, select second top right menu y val, and open pagex_y.php in center of page
function setActive12(x,y) {
	loadJs("right_menu.php","div_right_menu","","active1="+x);
	$("div_right_menu_container2p").hide();
	$("div_right_menu_container2").appear();
	loadJs("right_menu2.php","div_right_menu2","","active1="+x+"&active2="+y);
	if (x==3) {
		loadJs("page"+x+"_"+y+".php","div_right_content","load_videos()","");
	} else {
		loadCenter("page"+x+"_"+y+".php");
	}
}
// select first top right menu x val, select second top right menu y val
function setActive12b(x,y) {
	loadJs("right_menu.php","div_right_menu","","active1="+x);
	$("div_right_menu_container2p").hide();
	$("div_right_menu_container2").appear();
	loadJs("right_menu2.php","div_right_menu2","","active1="+x+"&active2="+y);
}
// select left menu (member's menu) w val
function setActive3(w) {
	zpage=0;
	if (w!=2) {
		loadJs("left_menu.php","div_left_menu","stime(date_hh,date_mm,date_ss,date_jw,date_dd,date_mo,date_yy)","active3="+w);
	} else {
		loadJs("left_menu.php",'div_left_menu','initFavGolf()',"active3="+w);
	}
	if (w==4) {setActive2p(w,0);} else {setActive2p(w,1);}
}
// select left menu (member's menu) w val without reloading page center
function setActive3b(w) {
	if (w!=2) {
		loadJs("left_menu.php","div_left_menu","stime(date_hh,date_mm,date_ss,date_jw,date_dd,date_mo,date_yy)","active3="+w);
	} else {
		loadJs("left_menu.php","div_left_menu","initFavGolf()","active3="+w);
	}
}

function loadCenter(dapage) {
	global_position_x = 0;
	global_position_y = 0;
	var opt = {
		method: 'post',
		onSuccess: function(t) {
			if ((msie >= 0) || (firefoxversion<3)) {
			//if (navigator.appName.indexOf("Explorer") >= 0) {
				$("div_right_content").hide();
				$("div_right_content").innerHTML = t.responseText;
				$("div_right_content").show();
			} else {
				$("div_right_content").hide();
				$("div_right_content").innerHTML = "<div id=\"div_right_content_in\" style=\"height: 560px; width: 720px; overflow-y: auto; overflow-x: hidden;\">"+t.responseText+"</div>";
				$("div_right_content").appear();
			}
					
			if (msie!=-1) {
				//initFocus();
				parseStylesheets();
			}
			if (dapage=="page0_0.php") {
				loadJs("video.php",'div_right_content_H2','video_tcp()',"");
			}
		},
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);}
	};
	new Ajax.Request(dapage, opt);
}

////************************************  END NAVIGATION FUNCTIONS *******************************************
function loadJs(daurl,dadiv,dafunc,davar) {

		var xhr_object = null;
		if(window.XMLHttpRequest) // Firefox
		xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else { // XMLHttpRequest non supporté par le navigateur
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
			return;
		}
		xhr_object.open("POST", daurl, true);
		xhr_object.onreadystatechange = function () {
			if (xhr_object.readyState == 4) {
				var c = document.getElementById(dadiv);
				c.innerHTML = xhr_object.responseText;
				if (msie!=-1) {
					if (((dafunc=='')||(dafunc==""))&&(daurl!="page0_0.php")) {
						parseStylesheets();
					}
				}
				//maintenant que les données reçu on été placé dans la page,
				//il faut exécuter toutes les balise script :
				if (dafunc!="") {
					var allscript = c.getElementsByTagName('script');
					for(var i=0;i<allscript.length;i++) {
						global.eval(allscript[i].text);
					}
					try {global.eval(dafunc);} catch(err) {}
				}
			}
		};
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		var data = davar;
		xhr_object.send(data);
}
function voidj() {}
//prise en charge du focus par IE
function initFocus(){
	if (msie != -1) {
		if(document.getElementsByTagName("input")){
			for(i=0;i<document.getElementsByTagName("input").length;i++){
				//document.getElementsByTagName("input")[i].onmouseover=iecolour;
				//document.getElementsByTagName("input")[i].onmouseleave=ienone;
				document.getElementsByTagName("input")[i].onblur=ienone;
				document.getElementsByTagName("input")[i].onfocus=iecolour;
			}
		}		
		if(document.getElementsByTagName("textarea")){
			for(i=0;i<document.getElementsByTagName("textarea").length;i++){
				//document.getElementsByTagName("textarea")[i].onmouseover=iecolour;
				//document.getElementsByTagName("textarea")[i].onmouseleave=ienone;
				document.getElementsByTagName("textarea")[i].onblur=ienone;
				document.getElementsByTagName("textarea")[i].onfocus=iecolour;
			}
		}
	}
}
function initFavGolf() {
	Sortable.create("list_fav_golf", {
	    onUpdate: function() {
			var opt = {
				method: 'post',
	            parameters: { data: Sortable.serialize("list_fav_golf") }
			};
			new Ajax.Request("ajax_update_fav_golf_order.php", opt);
	    }
	});
	try {stime(date_hh,date_mm,date_ss,date_jw,date_dd,date_mo,date_yy);} catch(err) {}
}
//Couleur du focus
function iecolour(event){
	this.style.backgroundColor="#e8ffcc";
	this.style.border="#f99b90 1px solid";
}
//Pas de couleur
function ienone(event){
	this.style.backgroundColor="#eeeeee"; 
	this.style.border="#aaaaaa 1px solid";
}
function stime(heure, min, sec, jw, dd, mo, yy) {
		sec++;
		if (sec>59) {min++;sec=0;}
		if (min>59) {heure++;min=0;}
		if (heure>23) {dd++;jw++;heure=0;}
		if (jw>6) {jw=0;}
		if ((dd>28)&&(mo==2)) {mo++;dd=1;}
		if ((dd>30)&&((mo==4)||(mo==6)||(mo==9)||(mo==11))) {mo++;dd=1;}
		if ((dd>31)&&((mo==1)||(mo==3)||(mo==5)||(mo==7)||(mo==8)||(mo==10)||(mo==12))) {mo++;dd=1;}
		if (mo>12) {yy++;mo=1;}
		sec = sec+"";
		min = min+"";
		heure = heure+"";
		dd=dd+"";
		if (heure<10) {
			if ((heure.charAt(0)=="0") && (heure.charAt(1)!="1") && (heure.charAt(1)!="2") && (heure.charAt(1)!="3") && (heure.charAt(1)!="4") && (heure.charAt(1)!="5") && (heure.charAt(1)!="6") && (heure.charAt(1)!="7") && (heure.charAt(1)!="8") && (heure.charAt(1)!="9")) {heure="00";} else if (heure.charAt(0)!="0") {heure="0"+heure;}
		}
		if (min<10) {
			if ((min.charAt(0)=="0") && (min.charAt(1)!="1")&& (min.charAt(1)!="2") && (min.charAt(1)!="3") && (min.charAt(1)!="4") && (min.charAt(1)!="5") && (min.charAt(1)!="6") && (min.charAt(1)!="7") && (min.charAt(1)!="8") && (min.charAt(1)!="9")) {min="00";} else if (min.charAt(0)!="0") {min="0"+min;}
		}
		if (sec<10) {
			if ((sec.charAt(0)=="0") && (sec.charAt(1)!="1") && (sec.charAt(1)!="2") && (sec.charAt(1)!="3") && (sec.charAt(1)!="4") && (sec.charAt(1)!="5") && (sec.charAt(1)!="6") && (sec.charAt(1)!="7") && (sec.charAt(1)!="8") && (sec.charAt(1)!="9")) {sec="00";} else if (sec.charAt(0)!="0") {sec="0"+sec;}
		}
		if (dd<10) {
			if ((dd.charAt(0)=="0") && (dd.charAt(1)!="1") && (dd.charAt(1)!="2") && (dd.charAt(1)!="3") && (dd.charAt(1)!="4") && (dd.charAt(1)!="5") && (dd.charAt(1)!="6") && (dd.charAt(1)!="7") && (dd.charAt(1)!="8") && (dd.charAt(1)!="9")) {dd="00";} else if (dd.charAt(0)!="0") {dd="0"+dd;}
		}
		jours = new Array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
		mois = new Array('','Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre');
		document.getElementById('date_heure').innerHTML=jours[jw]+' '+dd+' '+mois[mo]+' '+yy+' '+heure+":"+min;
		clearTimeout(timer1);
		timer1=setTimeout("stime('"+heure+"', '"+min+"', '"+sec+"', '"+jw+"', '"+dd+"', '"+mo+"', '"+yy+"')",1000);
}
function initRegister() {
	var opt = {
		method: 'post',
		onSuccess: function(t) { $("div_left_menu").innerHTML = t.responseText;},
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText); }
	};
	new Ajax.Request('authenticate.php', opt);
}
function login() {
	if (checkDigit($('fo_login').value)) {
		alert("Votre numéro de téléphone ne doit comporter que des chiffres !");
		return(false);
	}
	$('fo_md5').value=hex_md5($('fo_passwd').value);
	$('fo_passwd').value="";
	loadJs("verifcon.php","div_left_menu","loginRedirect()","fo_login="+$('fo_login').value+"&fo_md5="+$('fo_md5').value);
	return(false);
}
function loginRedirect() {
	//loadJs("authenticate.php","div_left_menu","stime(date_hh,date_mm,date_ss,date_jw,date_dd,date_mo,date_yy)","");
	//setActive2(1,7);
	// If there is a game, put first 2 lines and remove following stuffs :

	if ((global_position_y!=0)&&(global_position_x!=0)) {
		loadJs("authenticate.php","div_left_menu","stime(date_hh,date_mm,date_ss,date_jw,date_dd,date_mo,date_yy)","");
		setActive2(global_position_x,global_position_y);
	} else {
		loadJs("authenticate.php","div_left_menu","stime(date_hh,date_mm,date_ss,date_jw,date_dd,date_mo,date_yy)","");
		zpage=1;
		setActive2p(1,1);
	}
}
function goMeteo() {
	setActive1b(1);
	setActive2(1,5);
}
function deconnex() {
	//setActive12(0,0);
	loadJs("authenticate.php","div_left_menu","gohome()","deconn=1");
}
function gohome() {
	document.location = "index.php";
}
function changeUne(x) {
	$("une_left").hide;
	var opt = {
		method: 'post',
		parameters: {une:x},
		onSuccess: function(t) { $("div_right_content_D").innerHTML = t.responseText; 
		new Effect.Move('une_left', {
		  x: -362, y: 0, mode: 'relative',
		  transition: Effect.Transitions.spring
		});
		},
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);}
	};
	new Ajax.Request('ajax_get_une.php', opt);
}
function initPage() {
	//changeUne(1);
	//loadJs('video.php','div_right_content_H2','video_tcp()','');
	//initFocus();
	try {stime(date_hh,date_mm,date_ss,date_jw,date_dd,date_mo,date_yy);} catch(err) {}
	//$("chargement").hide();
	//$("div_main").show();
	// Preload La Une pics
	preload_image_object1 = new Image();
	preload_image_object1.src = "get_laune.php?i=1";
	preload_image_object2 = new Image();
	preload_image_object2.src = "get_laune.php?i=2";
	preload_image_object3 = new Image();
	preload_image_object3.src = "get_laune.php?i=3";
	preload_image_object4 = new Image();
	preload_image_object4.src = "get_laune.php?i=4";
	preload_image_object5 = new Image();
	preload_image_object5.src = "get_laune.php?i=5";
}
// Load registering page
function modifyregister() {
	setActive2pb(0,0);
	loadJs("register.php","div_right_content","","reg=1");
}
function register() {
	setActive12b(0,0);
	loadCenter('register.php');
}
// Load Rss in center of page
function loadRss(i) {
	setActive12b(3,1);
	loadJs("news_get.php","div_right_content","","i="+i);
}
// Both function for uploading photos
function startCallback() {
    // make something useful before submit (onStart)
	$('div_loader').appear();
    return true;
}
function completeCallback(response) {
    // make something useful after (onComplete)
    // document.getElementById('nr').innerHTML = parseInt(document.getElementById('nr').innerHTML) + 1;
    document.getElementById('r').innerHTML = response;
	$('div_loader').hide();
	var opt = {
		method: 'post',
		parameters: {active3:6},
		onSuccess: function(t) { $("div_left_menu").innerHTML = t.responseText;},
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);}
	};
	new Ajax.Request('left_menu.php', opt);
}
// Delete Photo from album
function delPhoto(x) {
	if (confirm("Etes-vous sûr de vouloir supprimer cette photo de votre album ?")) {
		var opt = {
			method: 'post',
			parameters: {del:x},
			onSuccess: function(t) { $("div_right_content").innerHTML = t.responseText;setActive3b(6);setActive2pb(6,1);},
			onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);}
		};
		new Ajax.Request('perso6_1.php', opt);
	}
}
// Delete Club from bag
function delBag(x) {
	if (confirm("Etes-vous sûr de vouloir supprimer ce club de votre sac ?")) {
		var opt = {
			method: 'post',
			parameters: {del:x},
			onSuccess: function(t) { $("div_right_content").innerHTML = t.responseText; setActive2pb(7,1);$('add_bag').hide();$('show_bag').show();},
			onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);}
		};
		new Ajax.Request('perso7_1.php', opt);
	}
}
function showBag() {
	var opt = {
		method: 'post',
		onSuccess: function(t) { $("div_right_content").innerHTML = t.responseText;setActive2pb(7,1);$('add_bag').hide();$('show_bag').show();parseStylesheets();},
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);}
	};
	new Ajax.Request('perso7_1.php', opt);
}
function addBag() {
	var opt = {
		method: 'post',
		onSuccess: function(t) { $("div_right_content").innerHTML = t.responseText;setActive2pb(7,1);$('show_bag').hide();$('add_bag').show();parseStylesheets();},
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);}
	};
	new Ajax.Request('perso7_1.php', opt);
}
function changeCat(x) {
	var y=x+1;
	for(var ii=0;ii<y;ii++) {
		$('cat'+ii).hide();		
	}
	Effect.SlideDown('cat'+document.catform.elements['dacat'].options[document.catform.elements['dacat'].selectedIndex].value);
	//$('cat'+document.catform.elements['dacat'].options[document.catform.elements['dacat'].selectedIndex].value).show();
}
function changeAlarm() {
	for(var ii=1;ii<6;ii++) {
		$('cat'+ii).hide();		
	}
	$('cat0').show();		
	Effect.SlideDown('cat'+document.catform.elements['dacat'].options[document.catform.elements['dacat'].selectedIndex].value);
	//$('cat'+document.catform.elements['dacat'].options[document.catform.elements['dacat'].selectedIndex].value).show();
}
function regAlarm(x,y,z) {
	loadJs("ajax_reg_alarm.php","div_reg_alarm","setActive3b(4)","x="+x+"&y="+y+"&z="+z);
}
function loadAlarm(x) {
	setActive3b(4);
	setActive2p(4,x);
}
var latch_dept=0;
function changeDpt(x) {
	if (latch_dept!=0) {
		alert("Merci de patienter un instant...");
		return;
	}
	latch_dept=1;
	$('div_golf_dept_desc').hide();
	if (x==0) {
		x=document.deptform.elements['dadept'].options[document.deptform.elements['dadept'].selectedIndex].value;
	}
	var opt = {
		method: 'post',
       	postBody: 'd='+x,
		onSuccess: function(t) { $("div_golf_dept_list").hide();$("div_golf_dept_list").innerHTML = t.responseText;$("div_golf_dept_list").appear();latch_dept=0;},
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);latch_dept=0; }
	};
	new Ajax.Request('ajax_get_golfs_from_dept.php', opt);
	latch_dept=0;
	return;
}
function forgetPassword() {
	fo_login = document.loginform.fo_login.value;
	if (fo_login=="") {
		alert("Afin de recevoir le sms, merci de mettre\nvotre numéro de mobile dans le formulaire\nci-dessus.");
		document.loginform.fo_login.focus();
		return;
	}
	if (checkMobilePhone(fo_login)) {
		alert("Merci de mettre un numéro de mobile valide.");
		document.loginform.fo_login.focus();
		return;
	}
	//  Send sms with password
	if (latch_pw==0) {
		latch_pw=1;
		var opt = {
			method: 'post',
        	postBody: 'login='+fo_login,
			onSuccess: function(t) { 
				var toto=dacheck2(t.responseXML);
				if (toto==222) {
					alert("Votre mot de passe vous a été envoyé par SMS!");
					latch_pw=0;
				}
				else if (toto==111) {
					alert("Un seul envoi de sms avec votre mot de passe par jour!");
					latch_pw=0;
					}
				else {
					alert("Ce n'est pas le numéro d'un membre!");
					latch_pw=0;
				}},
			onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText); latch_pw=0; }
		};
		new Ajax.Request('send_sms_pw.php', opt);
		latch_pw=0;
		return;
	}
}
function go_game() {
	loadJs("page1_7.php","div_right_content","game_tcp()","game=1");
}
function end_game(score) {
	setTimeout("loadJs('game_score_save.php','game_score','setActive3(1)','score="+score+"')",4500);
}
function go_teaser() {
	setActive1b(1);
	setActive2(1,7);
}
function add_golf() {
	setActive1b(0);
	setActive3b(2);
	setActive2pb(2,1);
	loadJs('perso2_1.php','div_right_content','','opt=1')
}
function teaser_tcp() {
	var s2 = new SWFObject("flash/teaser2.swf","ply","720","550","9","#FFFFFF");
	s2.addParam("flashvars","eventid=81");
	s2.write("game_container");
}
function game_tcp() {
	var s2 = new SWFObject("flash/game2.swf","ply","720","550","9","#FFFFFF");
	s2.addParam("flashvars","eventid=81");
	s2.write("game_container");
}
function video_tcp2(_container,_clip) {
	var s3 = new SWFObject('video_player.swf','ply'+_container,'300','220','9','#FFFFFF');
	s3.addVariable('fullscreen','true');
	s3.addParam("allowfullscreen","true");
	s3.addParam("wmode","opaque");
	s3.addVariable("file", _clip+".flv");
	s3.addVariable("image", _clip+".jpg");
	s3.addVariable("skin", "stijl.swf");
	s3.addVariable("stretching", "exactfit");
	s3.addVariable("repeat", "none");
	s3.addVariable("volume", "100");
	s3.addVariable("plugins", "googlytics-1");
	s3.write(_container);
}
function dacheck2(t) {
	var test;
	if (t==null) {
		alert("La connexion internet est momentanément coupée. Merci de réessayer plus tard.");
	} else {
		test = t.getElementsByTagName('access')[0].getAttribute('v');
	}
	latch_pw = 0;
	return(test);
}
// Update newsletter registering status
var latch_nl=0;
function checkNewsletter(f) {
	if (latch_nl!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_nl = 1;
	c_f_lock = 0;
	var dumb=check_form(f,formerrors);
	if (dumb==false) {
		latch_nl=0;
		return(false);
	}

	ch_newsletter = ($("ch_newsletter")) ? $("ch_newsletter").value : "";
	fo_newsletter = "N";
	if ($("fo_newsletter0")) {
		if ($("fo_newsletter0").checked) {
		 	fo_newsletter = "Y";
		}
	}

	//  Register new member
	var opt = {
		method: 'post',
		parameters: {submit:1, ch_newsletter:ch_newsletter, fo_newsletter:fo_newsletter},
		onSuccess: function(t) { $("div_right_content").innerHTML = t.responseText;latch_nl=0; },
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);latch_nl=0; }
	};
	new Ajax.Request('page1_9.php', opt);
	return(false);
}
// Update Alarms status
var latch_alarms=0;
function checkAlarms(f) {
	if (latch_alarms!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_alarms = 1;
	c_f_lock = 0;
	var dumb=check_form(f,formerrors);
	if (dumb==false) {
		latch_alarms=0;
		return(false);
	}

	ch_al_actugolf = ($("ch_al_actugolf")) ? $("ch_al_actugolf").value : "";
	fo_al_actugolf = "N";
	if ($("fo_al_actugolf0")) {
		if ($("fo_al_actugolf0").checked) {
		 	fo_al_actugolf = "Y";
		}
	}
	ch_al_news = ($("ch_al_news")) ? $("ch_al_news").value : "";
	fo_al_news = "N";
	if ($("fo_al_news0")) {
		if ($("fo_al_news0").checked) {
		 	fo_al_news = "Y";
		}
	}

	//  Register new member
	var opt = {
		method: 'post',
		parameters: {submit:1, ch_al_news:ch_al_news, fo_al_news:fo_al_news, ch_al_actugolf:ch_al_actugolf, fo_al_actugolf:fo_al_actugolf},
		onSuccess: function(t) { $("div_right_content").innerHTML = t.responseText;latch_alarms=0;$("div_left_menu").innerHTML="";setActive3b(4); },
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);latch_alarms=0; }
	};
	new Ajax.Request('perso4_1.php', opt);
	return(false);
}

// ***********************************   sendAgenda function   ***********************************
function sendAgenda(f) {
	if (latch_!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_ = 1;
	c_f_lock = 0;
	if (check_form(f,formerrors)==false) {
		latch_=0;
		return(false);
	}

	var mois = ($("mois")) ? $("mois").value : "";
	var an = ($("an")) ? $("an").value : "";

	var lastg  = ($("lastg")) ? $("lastg").value : "";
	var lastd  = ($("lastd")) ? $("lastd").value : "";
	var gstate = ($("gstate")) ? $("gstate").value : "";

	fo_scores_dept = ($("fo_scores_dept")) ? $("fo_scores_dept").value : "";
	ch_scores_dept = ($("ch_scores_dept")) ? $("ch_scores_dept").value : "";
	fo_scores_golfffid = ($("fo_scores_golfffid")) ? $("fo_scores_golfffid").value : "";
	ch_scores_golfffid = ($("ch_scores_golfffid")) ? $("ch_scores_golfffid").value : "";
	var fdate = ($("fdate")) ? $("fdate").value : "";

	var ziparam = "submit=1&lastg="+lastg+"&lastd="+lastd+"&gstate="+gstate+"&fo_scores_dept="+fo_scores_dept+"&ch_scores_dept="+ch_scores_dept+"&fo_scores_golfffid="+fo_scores_golfffid+"&ch_scores_dept="+ch_scores_dept+"&ch_scores_golfffid="+ch_scores_golfffid+"&date="+fdate;

	if (lastd==fo_scores_dept) {
		loadJs("agenda.php","div_agenda_main","loadJs('ajax_calendar.php','div_agenda','Modalbox.hide()','mois="+mois+"&an="+an+"')",ziparam);
	} else {
		loadJs("agenda.php","div_agenda_main","Modalbox.resizeToContent()",ziparam);
	}

	latch_=0;
	return(false);
}
// ***********************************   sendInvitations function   ***********************************
var latch_i=0
function sendInvitations(f) {
	if (latch_i!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_i = 1;
	c_f_lock = 0;
	if (check_form(f,formerrors)==false) {
		latch_i=0;
		return(false);
	}

	var fo_lastname0  = ($("fo_lastname0")) ? $("fo_lastname0").value : "";
	var fo_firstname0  = ($("fo_firstname0")) ? $("fo_firstname0").value : "";
	var fo_email0  = ($("fo_email0")) ? $("fo_email0").value : "";
	var fo_phone0  = ($("fo_phone0")) ? $("fo_phone0").value : "";

	var fo_lastname1  = ($("fo_lastname1")) ? $("fo_lastname1").value : "";
	var fo_firstname1  = ($("fo_firstname1")) ? $("fo_firstname1").value : "";
	var fo_email1  = ($("fo_email1")) ? $("fo_email1").value : "";
	var fo_phone1  = ($("fo_phone1")) ? $("fo_phone1").value : "";

	var fo_lastname2  = ($("fo_lastname2")) ? $("fo_lastname2").value : "";
	var fo_firstname2  = ($("fo_firstname2")) ? $("fo_firstname2").value : "";
	var fo_email2  = ($("fo_email2")) ? $("fo_email2").value : "";
	var fo_phone2  = ($("fo_phone2")) ? $("fo_phone2").value : "";

	var fo_lastname3  = ($("fo_lastname3")) ? $("fo_lastname3").value : "";
	var fo_firstname3  = ($("fo_firstname3")) ? $("fo_firstname3").value : "";
	var fo_email3  = ($("fo_email3")) ? $("fo_email3").value : "";
	var fo_phone3  = ($("fo_phone3")) ? $("fo_phone3").value : "";

	var fo_lastname4  = ($("fo_lastname4")) ? $("fo_lastname4").value : "";
	var fo_firstname4  = ($("fo_firstname4")) ? $("fo_firstname4").value : "";
	var fo_email4  = ($("fo_email4")) ? $("fo_email4").value : "";
	var fo_phone4  = ($("fo_phone4")) ? $("fo_phone4").value : "";

	var ch_lastname0  = ($("ch_lastname0")) ? $("ch_lastname0").value : "";
	var ch_firstname0  = ($("ch_firstname0")) ? $("ch_firstname0").value : "";
	var ch_email0  = ($("ch_email0")) ? $("ch_email0").value : "";
	var ch_phone0  = ($("ch_phone0")) ? $("ch_phone0").value : "";

	var ch_lastname1  = ($("ch_lastname1")) ? $("ch_lastname1").value : "";
	var ch_firstname1  = ($("ch_firstname1")) ? $("ch_firstname1").value : "";
	var ch_email1  = ($("ch_email1")) ? $("ch_email1").value : "";
	var ch_phone1  = ($("ch_phone1")) ? $("ch_phone1").value : "";

	var ch_lastname2  = ($("ch_lastname2")) ? $("ch_lastname2").value : "";
	var ch_firstname2  = ($("ch_firstname2")) ? $("ch_firstname2").value : "";
	var ch_email2  = ($("ch_email2")) ? $("ch_email2").value : "";
	var ch_phone2  = ($("ch_phone2")) ? $("ch_phone2").value : "";

	var ch_lastname3  = ($("ch_lastname3")) ? $("ch_lastname3").value : "";
	var ch_firstname3  = ($("ch_firstname3")) ? $("ch_firstname3").value : "";
	var ch_email3  = ($("ch_email3")) ? $("ch_email3").value : "";
	var ch_phone3  = ($("ch_phone3")) ? $("ch_phone3").value : "";

	var ch_lastname4  = ($("ch_lastname4")) ? $("ch_lastname4").value : "";
	var ch_firstname4  = ($("ch_firstname4")) ? $("ch_firstname4").value : "";
	var ch_email4  = ($("ch_email4")) ? $("ch_email4").value : "";
	var ch_phone4  = ($("ch_phone4")) ? $("ch_phone4").value : "";

	loadJs("perso1_1.php","div_right_content","","submit=1&fo_lastname0="+fo_lastname0+"&fo_firstname0="+fo_firstname0+"&fo_email0="+fo_email0+"&fo_phone0="+fo_phone0+"&fo_lastname1="+fo_lastname1+"&fo_firstname1="+fo_firstname1+"&fo_email1="+fo_email1+"&fo_phone1="+fo_phone1+"&fo_lastname2="+fo_lastname2+"&fo_firstname2="+fo_firstname2+"&fo_email2="+fo_email2+"&fo_phone2="+fo_phone2+"&fo_lastname3="+fo_lastname3+"&fo_firstname3="+fo_firstname3+"&fo_email3="+fo_email3+"&fo_phone3="+fo_phone3+"&fo_lastname4="+fo_lastname4+"&fo_firstname4="+fo_firstname4+"&fo_email4="+fo_email4+"&fo_phone4="+fo_phone4+"&ch_lastname0="+ch_lastname0+"&ch_firstname0="+ch_firstname0+"&ch_email0="+ch_email0+"&ch_phone0="+ch_phone0+"&ch_lastname1="+ch_lastname1+"&ch_firstname1="+ch_firstname1+"&ch_email1="+ch_email1+"&ch_phone1="+ch_phone1+"&ch_lastname2="+ch_lastname2+"&ch_firstname2="+ch_firstname2+"&ch_email2="+ch_email2+"&ch_phone2="+ch_phone2+"&ch_lastname3="+ch_lastname3+"&ch_firstname3="+ch_firstname3+"&ch_email3="+ch_email3+"&ch_phone3="+ch_phone3+"&ch_lastname4="+ch_lastname4+"&ch_firstname4="+ch_firstname4+"&ch_email4="+ch_email4+"&ch_phone4="+ch_phone4);
	latch_i=0;
	return(false);
}

// ***********************************   sendBag function   ***************************************
var latch_bag 	  = 0;
var fo_bag_type  = "";
var fo_bag_mark  = "";
var fo_bag_model = "";
var fo_bag_desc  = "";

function sendBag(f) {
	if (latch_bag!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_bag = 1;
	c_f_lock = 0;
	if (check_form(f,formerrors)==false) {
		latch_bag=0;
		return(false);
	}

	//  Retrieve form params
	fo_bag_type 	= ($("fo_bag_type")) ? $("fo_bag_type").value : "";
	fo_bag_mark 	= ($("fo_bag_mark")) ? $("fo_bag_mark").value : "";
	fo_bag_model 	= ($("fo_bag_model")) ? $("fo_bag_model").value : "";
	fo_bag_desc 	= ($("fo_bag_desc")) ? $("fo_bag_desc").value : "";
	ch_bag_type 	= ($("ch_bag_type")) ? $("ch_bag_type").value : "";
	ch_bag_mark 	= ($("ch_bag_mark")) ? $("ch_bag_mark").value : "";
	ch_bag_model 	= ($("ch_bag_model")) ? $("ch_bag_model").value : "";
	ch_bag_desc 	= ($("ch_bag_desc")) ? $("ch_bag_desc").value : "";

	//  Insert new bag club
	var opt = {
		method: 'post',
		parameters: {submit:1,fo_bag_type:fo_bag_type,fo_bag_model:fo_bag_model,fo_bag_mark:fo_bag_mark,fo_bag_desc:fo_bag_desc,ch_bag_type:ch_bag_type,ch_bag_model:ch_bag_model,ch_bag_mark:ch_bag_mark,ch_bag_desc:ch_bag_desc},
		onSuccess: function(t) { $("div_right_content").hide();$("div_right_content").innerHTML = t.responseText;$("div_right_content").show();latch_bag=0;},
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);latch_bag=0;}
	};
	new Ajax.Request('perso7_1.php', opt);
	return(false);
}

// ***********************************   sendProam function   ***************************************
var latch_pam 	  = 0;

var fo_firstname1 = "";
var fo_lastname1  = "";
var fo_phone1     = "";
var fo_email1     = "";
var fo_firstname2 = "";
var fo_lastname2  = "";
var fo_phone2     = "";
var fo_email2     = "";

function sendProam(f) {
	if (latch_pam!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_pam = 1;
	c_f_lock = 0;
	if (check_form(f,formerrors)==false) {
		latch_pam=0;
		return(false);
	}

	//  Retrieve form params
	fo_firstname1= ($("fo_firstname1"))?$("fo_firstname1"  ).value : "";
	fo_lastname1 = ($("fo_lastname1"))?$("fo_lastname1"    ).value : "";
	fo_phone1    = ($("fo_phone1"))?$("fo_phone1"          ).value : "";
	fo_email1    = ($("fo_email1"))?$("fo_email1"          ).value : "";
	fo_firstname2= ($("fo_firstname2"))?$("fo_firstname2"  ).value : "";
	fo_lastname2 = ($("fo_lastname2"))?$("fo_lastname2"    ).value : "";
	fo_phone2    = ($("fo_phone2"))?$("fo_phone2"          ).value : "";
	fo_email2    = ($("fo_email2"))?$("fo_email2"          ).value : "";

	ch_firstname1= ($("ch_firstname1"))?$("ch_firstname1"  ).value : "";
	ch_lastname1 = ($("ch_lastname1"))?$("ch_lastname1"    ).value : "";
	ch_phone1    = ($("ch_phone1"))?$("ch_phone1"          ).value : "";
	ch_email1    = ($("ch_email1"))?$("ch_email1"          ).value : "";
	ch_firstname2= ($("ch_firstname2"))?$("ch_firstname2"  ).value : "";
	ch_lastname2 = ($("ch_lastname2"))?$("ch_lastname2"    ).value : "";
	ch_phone2    = ($("ch_phone2"))?$("ch_phone2"          ).value : "";
	ch_email2    = ($("ch_email2"))?$("ch_email2"          ).value : "";


	//  Insert new bag club
	var opt = {
		method: 'post',
		parameters: {submit:1,fo_firstname1:fo_firstname1,fo_lastname1:fo_lastname1,fo_phone1:fo_phone1,fo_email1:fo_email1,fo_firstname2:fo_firstname2,fo_lastname2:fo_lastname2,fo_phone2:fo_phone2,fo_email2:fo_email2,ch_firstname1:ch_firstname1,ch_lastname1:ch_lastname1,ch_phone1:ch_phone1,ch_email1:ch_email1,ch_firstname2:ch_firstname2,ch_lastname2:ch_lastname2,ch_phone2:ch_phone2,ch_email2:ch_email2},
		onSuccess: function(t) { $("div_right_content").hide();$("div_right_content").innerHTML = t.responseText;$("div_right_content").show();latch_pam=0;},
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);latch_pam=0;}
	};
	new Ajax.Request('page1_7.php', opt);
	return(false);
}

// ***********************************   sendFirsttimer function   ***************************************
var latch_ft 	  = 0;
var fo_phonefix  = "";
var fo_howinternet  = "";

function sendFirsttimer(f) {
	if (latch_ft!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_ft = 1;
	c_f_lock = 0;
	if (check_form(f,formerrors)==false) {
		latch_ft=0;
		return(false);
	}

	fo_phonefix 	= ($("fo_phonefix")) ? $("fo_phonefix").value : "";
	fo_howinternet 	= ($("fo_howinternet")) ? $("fo_howinternet").value : "";
	ch_phonefix 	= ($("ch_phonefix")) ? $("ch_phonefix").value : "";
	ch_howinternet 	= ($("ch_howinternet")) ? $("ch_howinternet").value : "";
	
	loadJs("ajax_firsttimer.php","div_ft","","submit=1&fo_phonefix="+fo_phonefix+"&ch_phonefix="+ch_phonefix+"&fo_howinternet="+fo_howinternet+"&ch_howinternet="+ch_howinternet);
	latch_ft=0;
	return(false);
}
// ***********************************   sendScores function   ***************************************
var latch_ = 0;
var   fo_scores_dept =          "";
var   fo_scores_date =          "";
var   fo_scores_golfffid =     "";
var   fo_scores_terrainid =    "";
var   fo_scores_desc =         "";
var   fo_scores_hole1 =        "";
var   fo_scores_hole2 =        "";
var   fo_scores_hole3 =        "";
var   fo_scores_hole4 =        "";
var   fo_scores_hole5 =        "";
var   fo_scores_hole6 =        "";
var   fo_scores_hole7 =        "";
var   fo_scores_hole8 =        "";
var   fo_scores_hole9 =        "";
var   fo_scores_hole10 =       "";
var   fo_scores_hole11 =       "";
var   fo_scores_hole12 =       "";
var   fo_scores_hole13 =       "";
var   fo_scores_hole14 =       "";
var   fo_scores_hole15 =       "";
var   fo_scores_hole16 =       "";
var   fo_scores_hole17 =       "";
var   fo_scores_hole18 =       "";
var   fo_scores_formule =       "";
var   fo_scores_color =       "";

function sendScores(f) {
	if (latch_!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_ = 1;
	c_f_lock = 0;
	if (check_form(f,formerrors)==false) {
		latch_=0;
		return(false);
	}

	var lastt = ($("lastt")) ? $("lastt").value : "";
	var lastg = ($("lastg")) ? $("lastg").value : "";
	var lastd = ($("lastd")) ? $("lastd").value : "";

	fo_scores_dept = ($("fo_scores_dept")) ? $("fo_scores_dept").value : "";
	fo_scores_golfffid = ($("fo_scores_golfffid")) ? $("fo_scores_golfffid").value : "";
	fo_scores_terrainid = ($("fo_scores_terrainid")) ? $("fo_scores_terrainid").value : "";
	fo_scores_formule = ($("fo_scores_formule")) ? $("fo_scores_formule").value : "";
	ch_scores_formule = ($("ch_scores_formule")) ? $("ch_scores_formule").value : "";

	if ((lastd==fo_scores_dept)&&(lastg==fo_scores_golfffid)&&(lastt==fo_scores_terrainid)) {
		for(var i=1;i<19;i++) {
			if ($("fo_scores_hole"+i)) {
				if ($("fo_scores_hole"+i).value=="") {
					alert("Merci de remplir le nombre de coups pour tous les trous !");
					latch_=0;
					return(false);
				}
				if (checkDigit($("fo_scores_hole"+i).value)) {
					alert("Le nombre de coups doit être un nombre !");
					latch_=0;
					return(false);
				}
				if (checkDigit($("fo_scores_putt"+i).value)) {
					alert("Le nombre de putts doit être un nombre !");
					latch_=0;
					return(false);
				}
				if (fo_scores_formule=='2') {
					if ($("fo_scores_hole"+i).value=='0') {
						alert("En stroke play, le nombre de coups ne peut pas être 0 !");
						latch_=0;
						return(false);
					}
				}
			}
		}
	}
	
	var gstate = ($("gstate")) ? $("gstate").value : "";
	fo_scores_date = ($("fo_scores_date")) ? $("fo_scores_date").value : "";
	fo_scores_desc = ($("fo_scores_desc")) ? $("fo_scores_desc").value : "";
	ch_scores_dept = ($("ch_scores_dept")) ? $("ch_scores_dept").value : "";
	ch_scores_date = ($("ch_scores_date")) ? $("ch_scores_date").value : "";
	ch_scores_golfffid = ($("ch_scores_golfffid")) ? $("ch_scores_golfffid").value : "";
	ch_scores_terrainid = ($("ch_scores_terrainid")) ? $("ch_scores_terrainid").value : "";
	ch_scores_desc = ($("ch_scores_desc")) ? $("ch_scores_desc").value : "";

	fo_scores_color = ($("fo_scores_color")) ? $("fo_scores_color").value : "";
	ch_scores_color = ($("ch_scores_color")) ? $("ch_scores_color").value : "";

	fo_scores_hole1 = ($("fo_scores_hole1")) ? $("fo_scores_hole1").value : "";
	fo_scores_hole2 = ($("fo_scores_hole2")) ? $("fo_scores_hole2").value : "";
	fo_scores_hole3 = ($("fo_scores_hole3")) ? $("fo_scores_hole3").value : "";
	fo_scores_hole4 = ($("fo_scores_hole4")) ? $("fo_scores_hole4").value : "";
	fo_scores_hole5 = ($("fo_scores_hole5")) ? $("fo_scores_hole5").value : "";
	fo_scores_hole6 = ($("fo_scores_hole6")) ? $("fo_scores_hole6").value : "";
	fo_scores_hole7 = ($("fo_scores_hole7")) ? $("fo_scores_hole7").value : "";
	fo_scores_hole8 = ($("fo_scores_hole8")) ? $("fo_scores_hole8").value : "";
	fo_scores_hole9 = ($("fo_scores_hole9")) ? $("fo_scores_hole9").value : "";
	fo_scores_hole10 = ($("fo_scores_hole10")) ? $("fo_scores_hole10").value : "";
	fo_scores_hole11 = ($("fo_scores_hole11")) ? $("fo_scores_hole11").value : "";
	fo_scores_hole12 = ($("fo_scores_hole12")) ? $("fo_scores_hole12").value : "";
	fo_scores_hole13 = ($("fo_scores_hole13")) ? $("fo_scores_hole13").value : "";
	fo_scores_hole14 = ($("fo_scores_hole14")) ? $("fo_scores_hole14").value : "";
	fo_scores_hole15 = ($("fo_scores_hole15")) ? $("fo_scores_hole15").value : "";
	fo_scores_hole16 = ($("fo_scores_hole16")) ? $("fo_scores_hole16").value : "";
	fo_scores_hole17 = ($("fo_scores_hole17")) ? $("fo_scores_hole17").value : "";
	fo_scores_hole18 = ($("fo_scores_hole18")) ? $("fo_scores_hole18").value : "";
	ch_scores_hole1 = ($("ch_scores_hole1")) ? $("ch_scores_hole1").value : "";
	ch_scores_hole2 = ($("ch_scores_hole2")) ? $("ch_scores_hole2").value : "";
	ch_scores_hole3 = ($("ch_scores_hole3")) ? $("ch_scores_hole3").value : "";
	ch_scores_hole4 = ($("ch_scores_hole4")) ? $("ch_scores_hole4").value : "";
	ch_scores_hole5 = ($("ch_scores_hole5")) ? $("ch_scores_hole5").value : "";
	ch_scores_hole6 = ($("ch_scores_hole6")) ? $("ch_scores_hole6").value : "";
	ch_scores_hole7 = ($("ch_scores_hole7")) ? $("ch_scores_hole7").value : "";
	ch_scores_hole8 = ($("ch_scores_hole8")) ? $("ch_scores_hole8").value : "";
	ch_scores_hole9 = ($("ch_scores_hole9")) ? $("ch_scores_hole9").value : "";
	ch_scores_hole10 = ($("ch_scores_hole10")) ? $("ch_scores_hole10").value : "";
	ch_scores_hole11 = ($("ch_scores_hole11")) ? $("ch_scores_hole11").value : "";
	ch_scores_hole12 = ($("ch_scores_hole12")) ? $("ch_scores_hole12").value : "";
	ch_scores_hole13 = ($("ch_scores_hole13")) ? $("ch_scores_hole13").value : "";
	ch_scores_hole14 = ($("ch_scores_hole14")) ? $("ch_scores_hole14").value : "";
	ch_scores_hole15 = ($("ch_scores_hole15")) ? $("ch_scores_hole15").value : "";
	ch_scores_hole16 = ($("ch_scores_hole16")) ? $("ch_scores_hole16").value : "";
	ch_scores_hole17 = ($("ch_scores_hole17")) ? $("ch_scores_hole17").value : "";
	ch_scores_hole18 = ($("ch_scores_hole18")) ? $("ch_scores_hole18").value : "";

	fo_scores_putt1 = ($("fo_scores_putt1")) ? $("fo_scores_putt1").value : "";
	fo_scores_putt2 = ($("fo_scores_putt2")) ? $("fo_scores_putt2").value : "";
	fo_scores_putt3 = ($("fo_scores_putt3")) ? $("fo_scores_putt3").value : "";
	fo_scores_putt4 = ($("fo_scores_putt4")) ? $("fo_scores_putt4").value : "";
	fo_scores_putt5 = ($("fo_scores_putt5")) ? $("fo_scores_putt5").value : "";
	fo_scores_putt6 = ($("fo_scores_putt6")) ? $("fo_scores_putt6").value : "";
	fo_scores_putt7 = ($("fo_scores_putt7")) ? $("fo_scores_putt7").value : "";
	fo_scores_putt8 = ($("fo_scores_putt8")) ? $("fo_scores_putt8").value : "";
	fo_scores_putt9 = ($("fo_scores_putt9")) ? $("fo_scores_putt9").value : "";
	fo_scores_putt10 = ($("fo_scores_putt10")) ? $("fo_scores_putt10").value : "";
	fo_scores_putt11 = ($("fo_scores_putt11")) ? $("fo_scores_putt11").value : "";
	fo_scores_putt12 = ($("fo_scores_putt12")) ? $("fo_scores_putt12").value : "";
	fo_scores_putt13 = ($("fo_scores_putt13")) ? $("fo_scores_putt13").value : "";
	fo_scores_putt14 = ($("fo_scores_putt14")) ? $("fo_scores_putt14").value : "";
	fo_scores_putt15 = ($("fo_scores_putt15")) ? $("fo_scores_putt15").value : "";
	fo_scores_putt16 = ($("fo_scores_putt16")) ? $("fo_scores_putt16").value : "";
	fo_scores_putt17 = ($("fo_scores_putt17")) ? $("fo_scores_putt17").value : "";
	fo_scores_putt18 = ($("fo_scores_putt18")) ? $("fo_scores_putt18").value : "";
	ch_scores_putt1 = ($("ch_scores_putt1")) ? $("ch_scores_putt1").value : "";
	ch_scores_putt2 = ($("ch_scores_putt2")) ? $("ch_scores_putt2").value : "";
	ch_scores_putt3 = ($("ch_scores_putt3")) ? $("ch_scores_putt3").value : "";
	ch_scores_putt4 = ($("ch_scores_putt4")) ? $("ch_scores_putt4").value : "";
	ch_scores_putt5 = ($("ch_scores_putt5")) ? $("ch_scores_putt5").value : "";
	ch_scores_putt6 = ($("ch_scores_putt6")) ? $("ch_scores_putt6").value : "";
	ch_scores_putt7 = ($("ch_scores_putt7")) ? $("ch_scores_putt7").value : "";
	ch_scores_putt8 = ($("ch_scores_putt8")) ? $("ch_scores_putt8").value : "";
	ch_scores_putt9 = ($("ch_scores_putt9")) ? $("ch_scores_putt9").value : "";
	ch_scores_putt10 = ($("ch_scores_putt10")) ? $("ch_scores_putt10").value : "";
	ch_scores_putt11 = ($("ch_scores_putt11")) ? $("ch_scores_putt11").value : "";
	ch_scores_putt12 = ($("ch_scores_putt12")) ? $("ch_scores_putt12").value : "";
	ch_scores_putt13 = ($("ch_scores_putt13")) ? $("ch_scores_putt13").value : "";
	ch_scores_putt14 = ($("ch_scores_putt14")) ? $("ch_scores_putt14").value : "";
	ch_scores_putt15 = ($("ch_scores_putt15")) ? $("ch_scores_putt15").value : "";
	ch_scores_putt16 = ($("ch_scores_putt16")) ? $("ch_scores_putt16").value : "";
	ch_scores_putt17 = ($("ch_scores_putt17")) ? $("ch_scores_putt17").value : "";
	ch_scores_putt18 = ($("ch_scores_putt18")) ? $("ch_scores_putt18").value : "";

	ch_scores_drive1 = ($("ch_scores_drive1")) ? $("ch_scores_drive1").value : "";
	ch_scores_drive2 = ($("ch_scores_drive2")) ? $("ch_scores_drive2").value : "";
	ch_scores_drive3 = ($("ch_scores_drive3")) ? $("ch_scores_drive3").value : "";
	ch_scores_drive4 = ($("ch_scores_drive4")) ? $("ch_scores_drive4").value : "";
	ch_scores_drive5 = ($("ch_scores_drive5")) ? $("ch_scores_drive5").value : "";
	ch_scores_drive6 = ($("ch_scores_drive6")) ? $("ch_scores_drive6").value : "";
	ch_scores_drive7 = ($("ch_scores_drive7")) ? $("ch_scores_drive7").value : "";
	ch_scores_drive8 = ($("ch_scores_drive8")) ? $("ch_scores_drive8").value : "";
	ch_scores_drive9 = ($("ch_scores_drive9")) ? $("ch_scores_drive9").value : "";
	ch_scores_drive10 = ($("ch_scores_drive10")) ? $("ch_scores_drive10").value : "";
	ch_scores_drive11 = ($("ch_scores_drive11")) ? $("ch_scores_drive11").value : "";
	ch_scores_drive12 = ($("ch_scores_drive12")) ? $("ch_scores_drive12").value : "";
	ch_scores_drive13 = ($("ch_scores_drive13")) ? $("ch_scores_drive13").value : "";
	ch_scores_drive14 = ($("ch_scores_drive14")) ? $("ch_scores_drive14").value : "";
	ch_scores_drive15 = ($("ch_scores_drive15")) ? $("ch_scores_drive15").value : "";
	ch_scores_drive16 = ($("ch_scores_drive16")) ? $("ch_scores_drive16").value : "";
	ch_scores_drive17 = ($("ch_scores_drive17")) ? $("ch_scores_drive17").value : "";
	ch_scores_drive18 = ($("ch_scores_drive18")) ? $("ch_scores_drive18").value : "";

	ch_scores_greg1 = ($("ch_scores_greg1")) ? $("ch_scores_greg1").value : "";
	ch_scores_greg2 = ($("ch_scores_greg2")) ? $("ch_scores_greg2").value : "";
	ch_scores_greg3 = ($("ch_scores_greg3")) ? $("ch_scores_greg3").value : "";
	ch_scores_greg4 = ($("ch_scores_greg4")) ? $("ch_scores_greg4").value : "";
	ch_scores_greg5 = ($("ch_scores_greg5")) ? $("ch_scores_greg5").value : "";
	ch_scores_greg6 = ($("ch_scores_greg6")) ? $("ch_scores_greg6").value : "";
	ch_scores_greg7 = ($("ch_scores_greg7")) ? $("ch_scores_greg7").value : "";
	ch_scores_greg8 = ($("ch_scores_greg8")) ? $("ch_scores_greg8").value : "";
	ch_scores_greg9 = ($("ch_scores_greg9")) ? $("ch_scores_greg9").value : "";
	ch_scores_greg10 = ($("ch_scores_greg10")) ? $("ch_scores_greg10").value : "";
	ch_scores_greg11 = ($("ch_scores_greg11")) ? $("ch_scores_greg11").value : "";
	ch_scores_greg12 = ($("ch_scores_greg12")) ? $("ch_scores_greg12").value : "";
	ch_scores_greg13 = ($("ch_scores_greg13")) ? $("ch_scores_greg13").value : "";
	ch_scores_greg14 = ($("ch_scores_greg14")) ? $("ch_scores_greg14").value : "";
	ch_scores_greg15 = ($("ch_scores_greg15")) ? $("ch_scores_greg15").value : "";
	ch_scores_greg16 = ($("ch_scores_greg16")) ? $("ch_scores_greg16").value : "";
	ch_scores_greg17 = ($("ch_scores_greg17")) ? $("ch_scores_greg17").value : "";
	ch_scores_greg18 = ($("ch_scores_greg18")) ? $("ch_scores_greg18").value : "";

	fo_scores_drive1 = "0";
	if ($("fo_scores_drive10")) {
		if ($("fo_scores_drive10").checked) {
			fo_scores_drive1 = "1";
		}
	}
	fo_scores_drive2 = "0";
	if ($("fo_scores_drive20")) {
		if ($("fo_scores_drive20").checked) {
			fo_scores_drive2 = "1";
		}
	}
	fo_scores_drive3 = "0";
	if ($("fo_scores_drive30")) {
		if ($("fo_scores_drive30").checked) {
			fo_scores_drive3 = "1";
		}
	}
	fo_scores_drive4 = "0";
	if ($("fo_scores_drive40")) {
		if ($("fo_scores_drive40").checked) {
			fo_scores_drive4 = "1";
		}
	}
	fo_scores_drive5 = "0";
	if ($("fo_scores_drive50")) {
		if ($("fo_scores_drive50").checked) {
			fo_scores_drive5 = "1";
		}
	}
	fo_scores_drive6 = "0";
	if ($("fo_scores_drive60")) {
		if ($("fo_scores_drive60").checked) {
			fo_scores_drive6 = "1";
		}
	}
	fo_scores_drive7 = "0";
	if ($("fo_scores_drive70")) {
		if ($("fo_scores_drive70").checked) {
			fo_scores_drive7 = "1";
		}
	}
	fo_scores_drive8 = "0";
	if ($("fo_scores_drive80")) {
		if ($("fo_scores_drive80").checked) {
			fo_scores_drive8 = "1";
		}
	}
	fo_scores_drive9 = "0";
	if ($("fo_scores_drive90")) {
		if ($("fo_scores_drive90").checked) {
			fo_scores_drive9 = "1";
		}
	}
	fo_scores_drive10 = "0";
	if ($("fo_scores_drive100")) {
		if ($("fo_scores_drive100").checked) {
			fo_scores_drive10 = "1";
		}
	}
	fo_scores_drive11 = "0";
	if ($("fo_scores_drive110")) {
		if ($("fo_scores_drive110").checked) {
			fo_scores_drive11 = "1";
		}
	}
	fo_scores_drive12 = "0";
	if ($("fo_scores_drive120")) {
		if ($("fo_scores_drive120").checked) {
			fo_scores_drive12 = "1";
		}
	}
	fo_scores_drive13 = "0";
	if ($("fo_scores_drive130")) {
		if ($("fo_scores_drive130").checked) {
			fo_scores_drive13 = "1";
		}
	}
	fo_scores_drive14 = "0";
	if ($("fo_scores_drive140")) {
		if ($("fo_scores_drive140").checked) {
			fo_scores_drive14 = "1";
		}
	}
	fo_scores_drive15 = "0";
	if ($("fo_scores_drive150")) {
		if ($("fo_scores_drive150").checked) {
			fo_scores_drive15 = "1";
		}
	}
	fo_scores_drive16 = "0";
	if ($("fo_scores_drive160")) {
		if ($("fo_scores_drive160").checked) {
			fo_scores_drive16 = "1";
		}
	}
	fo_scores_drive17 = "0";
	if ($("fo_scores_drive170")) {
		if ($("fo_scores_drive170").checked) {
			fo_scores_drive17 = "1";
		}
	}
	fo_scores_drive18 = "0";
	if ($("fo_scores_drive180")) {
		if ($("fo_scores_drive180").checked) {
			fo_scores_drive18 = "1";
		}
	}


	fo_scores_greg1 = "0";
	if ($("fo_scores_greg10")) {
		if ($("fo_scores_greg10").checked) {
			fo_scores_greg1 = "1";
		}
	}
	fo_scores_greg2 = "0";
	if ($("fo_scores_greg20")) {
		if ($("fo_scores_greg20").checked) {
			fo_scores_greg2 = "1";
		}
	}
	fo_scores_greg3 = "0";
	if ($("fo_scores_greg30")) {
		if ($("fo_scores_greg30").checked) {
			fo_scores_greg3 = "1";
		}
	}
	fo_scores_greg4 = "0";
	if ($("fo_scores_greg40")) {
		if ($("fo_scores_greg40").checked) {
			fo_scores_greg4 = "1";
		}
	}
	fo_scores_greg5 = "0";
	if ($("fo_scores_greg50")) {
		if ($("fo_scores_greg50").checked) {
			fo_scores_greg5 = "1";
		}
	}
	fo_scores_greg6 = "0";
	if ($("fo_scores_greg60")) {
		if ($("fo_scores_greg60").checked) {
			fo_scores_greg6 = "1";
		}
	}
	fo_scores_greg7 = "0";
	if ($("fo_scores_greg70")) {
		if ($("fo_scores_greg70").checked) {
			fo_scores_greg7 = "1";
		}
	}
	fo_scores_greg8 = "0";
	if ($("fo_scores_greg80")) {
		if ($("fo_scores_greg80").checked) {
			fo_scores_greg8 = "1";
		}
	}
	fo_scores_greg9 = "0";
	if ($("fo_scores_greg90")) {
		if ($("fo_scores_greg90").checked) {
			fo_scores_greg9 = "1";
		}
	}
	fo_scores_greg10 = "0";
	if ($("fo_scores_greg100")) {
		if ($("fo_scores_greg100").checked) {
			fo_scores_greg10 = "1";
		}
	}
	fo_scores_greg11 = "0";
	if ($("fo_scores_greg110")) {
		if ($("fo_scores_greg110").checked) {
			fo_scores_greg11 = "1";
		}
	}
	fo_scores_greg12 = "0";
	if ($("fo_scores_greg120")) {
		if ($("fo_scores_greg120").checked) {
			fo_scores_greg12 = "1";
		}
	}
	fo_scores_greg13 = "0";
	if ($("fo_scores_greg130")) {
		if ($("fo_scores_greg130").checked) {
			fo_scores_greg13 = "1";
		}
	}
	fo_scores_greg14 = "0";
	if ($("fo_scores_greg140")) {
		if ($("fo_scores_greg140").checked) {
			fo_scores_greg14 = "1";
		}
	}
	fo_scores_greg15 = "0";
	if ($("fo_scores_greg150")) {
		if ($("fo_scores_greg150").checked) {
			fo_scores_greg15 = "1";
		}
	}
	fo_scores_greg16 = "0";
	if ($("fo_scores_greg160")) {
		if ($("fo_scores_greg160").checked) {
			fo_scores_greg16 = "1";
		}
	}
	fo_scores_greg17 = "0";
	if ($("fo_scores_greg170")) {
		if ($("fo_scores_greg170").checked) {
			fo_scores_greg17 = "1";
		}
	}
	fo_scores_greg18 = "0";
	if ($("fo_scores_greg180")) {
		if ($("fo_scores_greg180").checked) {
			fo_scores_greg18 = "1";
		}
	}

	var ziparam = "submit=1&lastt="+lastt+"&lastg="+lastg+"&lastd="+lastd+"&gstate="+gstate+"&fo_scores_date="+fo_scores_date+"&ch_scores_date="+ch_scores_date+"&fo_scores_dept="+fo_scores_dept+"&fo_scores_golfffid="+fo_scores_golfffid+"&fo_scores_terrainid="+fo_scores_terrainid+"&fo_scores_desc="+fo_scores_desc+"&fo_scores_hole1="+fo_scores_hole1+"&fo_scores_hole2="+fo_scores_hole2+"&fo_scores_hole3="+fo_scores_hole3+"&fo_scores_hole4="+fo_scores_hole4+"&fo_scores_hole5="+fo_scores_hole5+"&fo_scores_hole6="+fo_scores_hole6+"&fo_scores_hole7="+fo_scores_hole7+"&fo_scores_hole8="+fo_scores_hole8+"&fo_scores_hole9="+fo_scores_hole9+"&fo_scores_hole10="+fo_scores_hole10+"&fo_scores_hole11="+fo_scores_hole11+"&fo_scores_hole12="+fo_scores_hole12+"&fo_scores_hole13="+fo_scores_hole13+"&fo_scores_hole14="+fo_scores_hole14+"&fo_scores_hole15="+fo_scores_hole15+"&fo_scores_hole16="+fo_scores_hole16+"&fo_scores_hole17="+fo_scores_hole17+"&fo_scores_hole18="+fo_scores_hole18+"&ch_scores_dept="+ch_scores_dept+"&ch_scores_golfffid="+ch_scores_golfffid+"&ch_scores_terrainid="+ch_scores_terrainid+"&ch_scores_desc="+ch_scores_desc+"&ch_scores_hole1="+ch_scores_hole1+"&ch_scores_hole2="+ch_scores_hole2+"&ch_scores_hole3="+ch_scores_hole3+"&ch_scores_hole4="+ch_scores_hole4+"&ch_scores_hole5="+ch_scores_hole5+"&ch_scores_hole6="+ch_scores_hole6+"&ch_scores_hole7="+ch_scores_hole7+"&ch_scores_hole8="+ch_scores_hole8+"&ch_scores_hole9="+ch_scores_hole9+"&ch_scores_hole10="+ch_scores_hole10+"&ch_scores_hole11="+ch_scores_hole11+"&ch_scores_hole12="+ch_scores_hole12+"&ch_scores_hole13="+ch_scores_hole13+"&ch_scores_hole14="+ch_scores_hole14+"&ch_scores_hole15="+ch_scores_hole15+"&ch_scores_hole16="+ch_scores_hole16+"&ch_scores_hole17="+ch_scores_hole17+"&ch_scores_hole18="+ch_scores_hole18+"&ch_scores_formule="+ch_scores_formule+"&ch_scores_color="+ch_scores_color+"&fo_scores_formule="+fo_scores_formule+"&fo_scores_color="+fo_scores_color;
	ziparam = ziparam + "&fo_scores_putt1="+fo_scores_putt1+"&fo_scores_putt2="+fo_scores_putt2+"&fo_scores_putt3="+fo_scores_putt3+"&fo_scores_putt4="+fo_scores_putt4+"&fo_scores_putt5="+fo_scores_putt5+"&fo_scores_putt6="+fo_scores_putt6+"&fo_scores_putt7="+fo_scores_putt7+"&fo_scores_putt8="+fo_scores_putt8+"&fo_scores_putt9="+fo_scores_putt9+"&fo_scores_putt10="+fo_scores_putt10+"&fo_scores_putt11="+fo_scores_putt11+"&fo_scores_putt12="+fo_scores_putt12+"&fo_scores_putt13="+fo_scores_putt13+"&fo_scores_putt14="+fo_scores_putt14+"&fo_scores_putt15="+fo_scores_putt15+"&fo_scores_putt16="+fo_scores_putt16+"&fo_scores_putt17="+fo_scores_putt17+"&fo_scores_putt18="+fo_scores_putt18+"&ch_scores_putt1="+ch_scores_putt1+"&ch_scores_putt2="+ch_scores_putt2+"&ch_scores_putt3="+ch_scores_putt3+"&ch_scores_putt4="+ch_scores_putt4+"&ch_scores_putt5="+ch_scores_putt5+"&ch_scores_putt6="+ch_scores_putt6+"&ch_scores_putt7="+ch_scores_putt7+"&ch_scores_putt8="+ch_scores_putt8+"&ch_scores_putt9="+ch_scores_putt9+"&ch_scores_putt10="+ch_scores_putt10+"&ch_scores_putt11="+ch_scores_putt11+"&ch_scores_putt12="+ch_scores_putt12+"&ch_scores_putt13="+ch_scores_putt13+"&ch_scores_putt14="+ch_scores_putt14+"&ch_scores_putt15="+ch_scores_putt15+"&ch_scores_putt16="+ch_scores_putt16+"&ch_scores_putt17="+ch_scores_putt17+"&ch_scores_putt18="+ch_scores_putt18;
	ziparam = ziparam + "&fo_scores_drive1="+fo_scores_drive1+"&fo_scores_drive2="+fo_scores_drive2+"&fo_scores_drive3="+fo_scores_drive3+"&fo_scores_drive4="+fo_scores_drive4+"&fo_scores_drive5="+fo_scores_drive5+"&fo_scores_drive6="+fo_scores_drive6+"&fo_scores_drive7="+fo_scores_drive7+"&fo_scores_drive8="+fo_scores_drive8+"&fo_scores_drive9="+fo_scores_drive9+"&fo_scores_drive10="+fo_scores_drive10+"&fo_scores_drive11="+fo_scores_drive11+"&fo_scores_drive12="+fo_scores_drive12+"&fo_scores_drive13="+fo_scores_drive13+"&fo_scores_drive14="+fo_scores_drive14+"&fo_scores_drive15="+fo_scores_drive15+"&fo_scores_drive16="+fo_scores_drive16+"&fo_scores_drive17="+fo_scores_drive17+"&fo_scores_drive18="+fo_scores_drive18+"&ch_scores_drive1="+ch_scores_drive1+"&ch_scores_drive2="+ch_scores_drive2+"&ch_scores_drive3="+ch_scores_drive3+"&ch_scores_drive4="+ch_scores_drive4+"&ch_scores_drive5="+ch_scores_drive5+"&ch_scores_drive6="+ch_scores_drive6+"&ch_scores_drive7="+ch_scores_drive7+"&ch_scores_drive8="+ch_scores_drive8+"&ch_scores_drive9="+ch_scores_drive9+"&ch_scores_drive10="+ch_scores_drive10+"&ch_scores_drive11="+ch_scores_drive11+"&ch_scores_drive12="+ch_scores_drive12+"&ch_scores_drive13="+ch_scores_drive13+"&ch_scores_drive14="+ch_scores_drive14+"&ch_scores_drive15="+ch_scores_drive15+"&ch_scores_drive16="+ch_scores_drive16+"&ch_scores_drive17="+ch_scores_drive17+"&ch_scores_drive18="+ch_scores_drive18;
	ziparam = ziparam + "&fo_scores_greg1="+fo_scores_greg1+"&fo_scores_greg2="+fo_scores_greg2+"&fo_scores_greg3="+fo_scores_greg3+"&fo_scores_greg4="+fo_scores_greg4+"&fo_scores_greg5="+fo_scores_greg5+"&fo_scores_greg6="+fo_scores_greg6+"&fo_scores_greg7="+fo_scores_greg7+"&fo_scores_greg8="+fo_scores_greg8+"&fo_scores_greg9="+fo_scores_greg9+"&fo_scores_greg10="+fo_scores_greg10+"&fo_scores_greg11="+fo_scores_greg11+"&fo_scores_greg12="+fo_scores_greg12+"&fo_scores_greg13="+fo_scores_greg13+"&fo_scores_greg14="+fo_scores_greg14+"&fo_scores_greg15="+fo_scores_greg15+"&fo_scores_greg16="+fo_scores_greg16+"&fo_scores_greg17="+fo_scores_greg17+"&fo_scores_greg18="+fo_scores_greg18+"&ch_scores_greg1="+ch_scores_greg1+"&ch_scores_greg2="+ch_scores_greg2+"&ch_scores_greg3="+ch_scores_greg3+"&ch_scores_greg4="+ch_scores_greg4+"&ch_scores_greg5="+ch_scores_greg5+"&ch_scores_greg6="+ch_scores_greg6+"&ch_scores_greg7="+ch_scores_greg7+"&ch_scores_greg8="+ch_scores_greg8+"&ch_scores_greg9="+ch_scores_greg9+"&ch_scores_greg10="+ch_scores_greg10+"&ch_scores_greg11="+ch_scores_greg11+"&ch_scores_greg12="+ch_scores_greg12+"&ch_scores_greg13="+ch_scores_greg13+"&ch_scores_greg14="+ch_scores_greg14+"&ch_scores_greg15="+ch_scores_greg15+"&ch_scores_greg16="+ch_scores_greg16+"&ch_scores_greg17="+ch_scores_greg17+"&ch_scores_greg18="+ch_scores_greg18;
	loadJs("perso5_2.php","div_right_content","docalend()",ziparam);
	latch_=0;
	return(false);
}

// ***********************************   sendMatchplay function   ***************************************
var latch_ = 0;
var   fo_mp_dept =          "";
var   fo_mp_date =          "";
var   fo_mp_golfffid =     "";
var   fo_mp_terrainid =    "";

function sendMatchplay(f) {
	if (latch_!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_ = 1;
	c_f_lock = 0;
	if (check_form(f,formerrors)==false) {
		latch_=0;
		return(false);
	}

	fo_mp_dept = ($("fo_mp_dept")) ? $("fo_mp_dept").value : "";

	fo_mp_dept = ($("fo_mp_dept")) ? $("fo_mp_dept").value : "";
	fo_mp_date = ($("fo_mp_date")) ? $("fo_mp_date").value : "";
	fo_mp_golfffid = ($("fo_mp_golfffid")) ? $("fo_mp_golfffid").value : "";
	ch_mp_dept = ($("ch_mp_dept")) ? $("ch_mp_dept").value : "";
	ch_mp_date = ($("ch_mp_date")) ? $("ch_mp_date").value : "";
	ch_mp_golfffid = ($("ch_mp_golfffid")) ? $("ch_mp_golfffid").value : "";
	var gstate = ($("gstate")) ? $("gstate").value : "";
	var lastg = ($("lastg")) ? $("lastg").value : "";
	var lastd = ($("lastd")) ? $("lastd").value : "";
	
	var zdiv = (zpage==1)?"div_mp":"div_right_content";
	
	loadJs("page6_1.php",zdiv,"","submit=1&lastg="+lastg+"&lastd="+lastd+"&gstate="+gstate+"&ch_mp_dept="+ch_mp_dept+"&fo_mp_dept="+fo_mp_dept+"&fo_mp_golfffid="+fo_mp_golfffid+"&ch_mp_golfffid="+ch_mp_golfffid);
	latch_=0;
	return(false);
}

// ***********************************   searchContact function   ***************************************
var latch_c = 0;
var fo_cmobile  = "";

function sendContact(f) {
	if (latch_c!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_c = 1;
	c_f_lock = 0;
	if (check_form(f,formerrors)==false) {
		latch_c=0;
		return(false);
	}

	fo_cmobile = ($("fo_cmobile")) ? $("fo_cmobile").value : "";
	ch_cmobile = ($("ch_cmobile")) ? $("ch_cmobile").value : "";

	var opt = {
		method: 'post',
		parameters: {submit:1,fo_cmobile:fo_cmobile,ch_cmobile:ch_cmobile},
		onSuccess: function(t) { $("div_contacts").innerHTML = t.responseText;latch_c=0;},
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);latch_c=0;}
	};
	new Ajax.Request('perso3_1.php', opt);
	return(false);
}

function askContact(cid) {
	if (latch_c!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_c = 1;
	loadJs("perso3_1.php","div_contacts_ask","","ask=1&cid="+cid);
	latch_c=0;
}

function acceptMember(cid,rep) {
	if (latch_c!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_c = 1;
	loadJs("perso3_1.php","div_right_content","setActive3(3)","rep="+rep+"&cid="+cid);
	latch_c=0;
}

// ***********************************   Registering function   ***************************************
var latch_pw 	   = 0;
var latch_register = 0;
var latch_sms      = 0;
var register_state = 0;
var fo_lastname    = "";
var fo_firstname   = "";
var fo_address 	   = "";
var fo_zipcode 	   = "";
var fo_city 	   = "";
var fo_countrycode = "";
//var fo_birthdate   = "";
var fo_jour ="";
var fo_mois ="";
var fo_annee ="";
var fo_phone 	   = "";
var fo_email 	   = "";
var fo_password1   = "";
var fo_password2   = "";
var fo_licence 	   = "";
var fo_title	   = "";
var fo_newsletter  = "";
var fo_check1      = "";
var fo_check2      = "";
var smscode		   = "";

function sendRegister(f) {
	if (latch_register!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_register = 1;
	c_f_lock = 0;
	var dumb=true;
	//if (register_state!=1) {
		dumb=check_form(f,formerrors);
	//}

	if (dumb==false) {
		latch_register=0;
		return(false);
	}

	//  Retrieve form params
	fo_lastname 	= ($("fo_lastname")) ? $("fo_lastname").value : "";
	fo_firstname 	= ($("fo_firstname")) ? $("fo_firstname").value : "";
	fo_address 		= ($("fo_address")) ? $("fo_address").value : "";
	fo_zipcode 		= ($("fo_zipcode")) ? $("fo_zipcode").value : "";
	fo_city 		= ($("fo_city")) ? $("fo_city").value : "";
	fo_countrycode 	= ($("fo_countrycode")) ? $("fo_countrycode").value : "";
	//fo_birthdate 	= ($("fo_birthdate")) ? $("fo_birthdate").value : "";
	fo_jour 		= ($("fo_jour")) ? $("fo_jour").value : "";
	fo_mois 		= ($("fo_mois")) ? $("fo_mois").value : "";
	fo_annee 		= ($("fo_annee")) ? $("fo_annee").value : "";
	fo_phone 		= ($("fo_phone")) ? $("fo_phone").value : "";
	fo_email 		= ($("fo_email")) ? $("fo_email").value : "";
	fo_password1 	= ($("fo_password1")) ? $("fo_password1").value : "";
	fo_password2 	= ($("fo_password2")) ? $("fo_password2").value : "";
	fo_licence 		= ($("fo_licence")) ? $("fo_licence").value : "";
	fo_phonefix 	= ($("fo_phonefix")) ? $("fo_phonefix").value : "";
	fo_howinternet 	= ($("fo_howinternet")) ? $("fo_howinternet").value : "";
	fo_title = "f";
	if ($("fo_title0")) {
		if ($("fo_title0").checked) {
			fo_title = "M";
		}
	}
	if ($("fo_title1")) {
		if ($("fo_title1").checked) {
			fo_title = "F";
		}
	}
	fo_newsletter = "N";
	if ($("fo_newsletter0")) {
		if ($("fo_newsletter0").checked) {
			fo_newsletter = "Y";
		}
	}
	fo_check1 = "0";
	if ($("fo_check10")) {
		if ($("fo_check10").checked) {
			fo_check1 = "1";
		}
	}
	fo_check2 = "0";
	if ($("fo_check20")) {
		if ($("fo_check20").checked) {
			fo_check2 = "1";
		}
	}

	ch_lastname 	= ($("ch_lastname")) ? $("ch_lastname").value : "";
	ch_firstname 	= ($("ch_firstname")) ? $("ch_firstname").value : "";
	ch_address 		= ($("ch_address")) ? $("ch_address").value : "";
	ch_zipcode 		= ($("ch_zipcode")) ? $("ch_zipcode").value : "";
	ch_city 		= ($("ch_city")) ? $("ch_city").value : "";
	ch_countrycode 	= ($("ch_countrycode")) ? $("ch_countrycode").value : "";
//	ch_birthdate 	= ($("ch_birthdate")) ? $("ch_birthdate").value : "";
ch_jour 		= ($("ch_jour")) ? $("ch_jour").value : "";
ch_mois 		= ($("ch_mois")) ? $("ch_mois").value : "";
ch_annee 		= ($("ch_annee")) ? $("ch_annee").value : "";
	ch_phone 		= ($("ch_phone")) ? $("ch_phone").value : "";
	ch_email 		= ($("ch_email")) ? $("ch_email").value : "";
	ch_password1 	= ($("ch_password1")) ? $("ch_password1").value : "";
	ch_password2 	= ($("ch_password2")) ? $("ch_password2").value : "";
	ch_licence 		= ($("ch_licence")) ? $("ch_licence").value : "";
	ch_title 		= ($("ch_title")) ? $("ch_title").value : "";
	ch_newsletter 	= ($("ch_newsletter")) ? $("ch_newsletter").value : "";
	ch_check1 		= ($("ch_check1")) ? $("ch_check1").value : "";
	ch_check2 		= ($("ch_check2")) ? $("ch_check2").value : "";
	ch_phonefix 	= ($("ch_phonefix")) ? $("ch_phonefix").value : "";
	ch_howinternet 	= ($("ch_howinternet")) ? $("ch_howinternet").value : "";

	//  Send sms with code
	if ((latch_sms==0)&&(register_state==0)) {
		latch_sms = 1;
		var opt = {
			method: 'post',
        	postBody: 'phone='+fo_phone,
			onSuccess: function(t) { if (dacheck(t.responseXML)) {popup('popUpDiv'); document.frm.dacode.focus(); register_state=1;}else {alert("Ce numéro de téléphone est déjà inscrit!");latch_sms=0;}},
			onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText); latch_register=0; latch_sms=0; }
		};
		new Ajax.Request('send_sms_code.php', opt);
		latch_register=0;
		return(false);
	}


	//  Check if sms code is correct
	var dacode=document.frm.dacode.value.toUpperCase();
	if (hex_md5(dacode)!=smscode) {
		alert("Ce n'est pas le bon code !");
		document.frm.dacode.focus();
		latch_register=0;
		return(false);
	}
	
	//  Close check sms code window (facultative)
	popup('popUpDiv');
	
	//  Register new member
	var opt = {
		method: 'post',
		parameters: {submit:1, dacode:dacode, ch_lastname:ch_lastname, ch_firstname:ch_firstname, ch_title:ch_title, ch_address:ch_address, ch_zipcode:ch_zipcode, ch_city:ch_city, ch_countrycode:ch_countrycode, ch_phone:ch_phone, ch_email:ch_email, ch_password1:ch_password1, ch_password2:ch_password2, ch_licence:ch_licence, ch_newsletter:ch_newsletter, ch_check1:ch_check1, ch_check2:ch_check2, fo_lastname:fo_lastname, fo_firstname:fo_firstname, fo_title:fo_title, fo_address:fo_address, fo_zipcode:fo_zipcode, fo_city:fo_city, fo_countrycode:fo_countrycode, fo_phone:fo_phone, fo_email:fo_email, fo_password1:fo_password1, fo_password2:fo_password2, fo_licence:fo_licence, fo_newsletter:fo_newsletter, "fo_check1[]":fo_check1, "fo_check2[]":fo_check2,fo_phonefix:fo_phonefix,ch_phonefix:ch_phonefix,fo_howinternet:fo_howinternet,ch_howinternet:ch_howinternet,fo_jour:fo_jour,fo_mois:fo_mois,fo_annee:fo_annee,ch_jour:ch_jour,ch_mois:ch_mois,ch_annee:ch_annee},
		onSuccess: function(t) { $("div_right_content").innerHTML = t.responseText;latch_register=0;latch_sms=0;register_state=0;$("div_left_menu").innerHTML="";setActive3b(1); },
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);latch_register=0;latch_sms=0;register_state=0; }
	};
	new Ajax.Request('register.php', opt);
	return(false);
}

function dacheck(t) {
	//  Retrieve sms code
	if (t==null) {
		alert("La connexion internet est momentanément coupée. Merci de réessayer plus tard.");
	} else {
		smscode = t.getElementsByTagName('access')[0].getAttribute('v');
	}
	latch_sms = 0;
	if (smscode==000) {
		return(false);
	} else {
		return(true);
	}
}


// ***********************************   CSS Popup functions   ***************************************
function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	var version=0;
	if (msie!=-1){
	temp=navigator.appVersion.split("MSIE");
	version=parseFloat(temp[1]);
	}
	if ((msie==-1)||((msie!=-1)&&(version>=7))) {
		popUpDiv_height=blanket_height/2-150;//150 is half popup's height
	} else {
		popUpDiv_height=100;//150 is half popup's height		
	}
	popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-150;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
	//alert(parseFloat(navigator.appVersion));
	var version=0;
	if (msie!=-1) {
	temp=navigator.appVersion.split("MSIE");
	version=parseFloat(temp[1]);
	}
	if ((msie==-1)||((msie!=-1)&&(version>=7))) {
		blanket_size(windowname);
	}
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}

// ************** Index FFG ************************
var latch_2_1 = 0;
function checkIndex(f) {
	if (latch_2_1!=0) {
		alert("Merci de patienter un instant...");
		return(false);
	}
	latch_2_1 = 1;
	c_f_lock = 0;
	var dumb=check_form(f,formerrors);
	if (dumb==false) {
		latch_2_1=0;
		return(false);
	}
	$("result_2_1").innerHTML="";
	$('pleasewait_2_1').appear();

	ch_licence 		= ($("ch_licence")) ? $("ch_licence").value : "";
	fo_licence 		= ($("fo_licence")) ? $("fo_licence").value : "";

	var opt = {
		method: 'post',
		parameters: {submit:1, fo_licence:fo_licence, ch_licence:ch_licence},
		onSuccess: function(t) { $("result_2_1").innerHTML = t.responseText;latch_2_1=0; $('pleasewait_2_1').hide();},
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);latch_2_1=0; $('pleasewait_2_1').hide();}
	};
	new Ajax.Request('page2_1.php',opt);
	return(false);
}

// ******************* Google map **************************
var baseIcon = new GIcon();
baseIcon.iconSize=new GSize(12,20);
baseIcon.shadowSize=new GSize(20,22);
baseIcon.iconAnchor=new GPoint(6,20);
baseIcon.infoWindowAnchor=new GPoint(5,1);
var iconred = new GIcon(baseIcon, 'http://labs.google.com/ridefinder/images/mm_20_red.png', null, 'http://labs.google.com/ridefinder/images/mm_20_shadow.png');
var icongre = new GIcon(baseIcon, 'http://labs.google.com/ridefinder/images/mm_20_green.png', null, 'http://labs.google.com/ridefinder/images/mm_20_shadow.png');
var iconblu = new GIcon(baseIcon, 'http://labs.google.com/ridefinder/images/mm_20_blue.png', null, 'http://labs.google.com/ridefinder/images/mm_20_shadow.png');


function createMarker(latlng,icon,infos) {
	var m = new GMarker(latlng,icon);
	GEvent.addListener(m, 'click', function() { 
		m.openInfoWindowHtml(infos); 
	});
	return m;
}
function do_vsgolf_back() {
	$('div_golf_dept_desc').hide();
	$('div_golf_dept').show();
}
function do_vsgolf_esfr2golfs_see(gi) {
	var na = $('loc_'+gi).getAttribute("na");  // tr - 2 td - inner td - inner a
	var ad = $('loc_'+gi).getAttribute("ad");
	//var zi = $('loc_'+gi).childNodes[2].firstChild.nodeValue;
	//var ci = $('loc_'+gi).childNodes[3].firstChild.nodeValue;
	var zi = $('loc_'+gi).getAttribute("zi");
	var ci = $('loc_'+gi).getAttribute("ci");
	var ph = $('loc_'+gi).getAttribute("ph");
	var fa = $('loc_'+gi).getAttribute("fa");
	var si = $('loc_'+gi).getAttribute("si");
	var nt = $('loc_'+gi).getAttribute("nt");
	var st = $('loc_'+gi).getAttribute("st");
	var co = $('loc_'+gi).getAttribute("co");
	var rp = $('loc_'+gi).getAttribute("rp");

	var la = $('loc_'+gi).getAttribute("la");
	var lo = $('loc_'+gi).getAttribute("lo");

	var s = "<div id=\"map_canvas_container\"><div id=\"map_canvas\"></div><div id=\"map_canvas_legend\"></div></div>";

	$('div_golf_dept').hide();
	$('div_golf_dept_desc').hide();
	$('div_golf_dept_desc').innerHTML=s;

	var map;
	if (GBrowserIsCompatible()) {
		var point = new GLatLng(la,lo);
		map = new GMap2(document.getElementById("map_canvas"),{ size: new GSize(380,530) } );
		map.removeMapType(G_HYBRID_MAP);
		map.setCenter(point, 11);
		map.addControl(new GLargeMapControl());
		var mapControl = new GMapTypeControl();
		map.addControl(mapControl);
		map.addOverlay(createMarker(point,icongre,"<b>"+na+"</b><br/>"+ad+"<br/>"+zi+" "+ci));
	}
	
	var le = "";
	//le+="<a href=\"javascript:do_vsgolf_back()\">[Cliquez ici pour revenir à l'écran précédent]</a><br /><br />";
	//le+="<a href=\"javascript:favoriteg("+gi+",0)\">[Cliquez ici pour ajouter ce golf à mes favoris]</a><br /><br /><br />";
	le+="<input type=\"button\" class=\"submit\" value=\"Revenir à l'écran précédent\" onclick=\"javascript:do_vsgolf_back()\"><br /><br />";
	le+="<input type=\"button\" class=\"submit\" value=\"Ajouter ce Golf à mes parcours\" onclick=\"javascript:favoriteg("+gi+",0)\"><br /><br />";
	le+="<h1> "+na+"</h1>";
	le+="<br /><b>Adresse :</b> "+ad;
	le+="<br /><b>Code postal :</b> "+zi;
	le+="<br /><b>Ville :</b> "+ci;
	if (ph!="") {
		le+="<br /><br /><b>Tél :</b> "+ph;
	}
	if (fa!="") {
		le+="<br /><b>Fax :</b> "+fa;
	}
	//if (si!="") {
		//le+="<br /><b>Site Internet :</b> <a target=\"_dagolf\" href=\""+si+"\">"+si+"</a>";
	//}
	le+="<br /><br /><b>Nombre de trous :</b> "+nt;
	le+="<br /><b>Stages :</b> "+st;
	le+="<br /><b>Cours individuels :</b> "+co;
	le+="<br /><b>Restaurant sur place :</b> "+rp;
	//le+="<hr />";
	$('map_canvas_legend').innerHTML=le;
	$('div_golf_dept_desc').appear();
}
var latch_fav_golf=0;
function favoriteg(gi,de) {
	if (latch_fav_golf==1) {
		alert("Merci de patienter...");
		return;
	}
	latch_fav_golf=1;
	var txtbtn = "Etes-vous sûr ?";
	if (de==1) {
		txtbtn = "Etes-vous sûr de vouloir supprimer ce Golf de vos parcours ?";
	} else {
		txtbtn = "Etes-vous sûr de vouloir ajouter ce Golf à vos parcours ?";
	}
	if (confirm(txtbtn)) {
		var opt = {
			method: 'post',
        	postBody: 'gi='+gi+'&del='+de,
			onSuccess: function(t) {
				if (t==null) {
					alert("La connexion internet est momentanément coupée. Merci de réessayer plus tard.");
					latch_fav_golf=0;
				} else {
					var tt=t.responseXML.getElementsByTagName('access')[0].getAttribute('v');
					if (tt=="0") {
						$("div_golf_dept_desc").innerHTML = "<br /><b>Vous avez déjà 3 Golfs dans vos parcours ! Supprimez-en un pour pouvoir en ajouter un nouveau !</b>";
					}
					else if (tt=="1") {
						$("div_golf_dept_desc").innerHTML = "<br /><b>Ce Golf fait déjà partie de vos parcours !</b>";
					}
					else if (tt=="2") {
						setActive3b(2);
						$("div_golf_dept_desc").innerHTML = "<br /><b>Ce Golf a bien été ajouté à vos parcours !</b>";
					}
					else if (tt=="4") {
						setActive3b(2);
						setActive1b(0);
						setActive2pb(2,1);
						loadJs("right_menu2p.php","div_right_menu2","","active1=2&active2=1");
						var opt = {
							method: 'post',
							onSuccess: function(t) { 
								$("div_right_content").innerHTML = t.responseText;
								$("div_golf_dept").innerHTML = "<br /><b>Ce Golf a bien été supprimé de vos parcours !</b>";
								
								if (msie!=-1) {
									//initFocus();
									parseStylesheets();
								}
							},
							onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);}
						};
						new Ajax.Request("perso2_1.php", opt);
					}
					latch_fav_golf=0;
				}
			},
			onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);}
		};
		new Ajax.Request('ajax_add_favorite_golfs.php', opt);
	}
	latch_fav_golf=0;
}
function do_ffgolf_ffgolf_see(i) {
	setActive3b(2);
	setActive1b(0);
	setActive2pb(2,1);
	loadJs("right_menu2p.php","div_right_menu2","","active1=2&active2=1");
	$("div_right_content").hide();
	var opt = {
		method: 'post',
		parameters: {i:i},
		onSuccess: function(t) {
			response_ffgolf_ffgolf_see(t.responseXML);
			if (msie!=-1) {
				//initFocus();
				parseStylesheets();
			}
		},
		onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText);} //latchingStop(); }
	};
	new Ajax.Request('ajax_ffgolf_ffgolf_get.php', opt);
}

function response_ffgolf_ffgolf_see(t) {
	if (t==null) {
		alert("Erreur !");
	}

	else {
		var s = "";
		var stitle = "";
		var stoptou=0;
		var na="";
		var ad="";
		var zi="";
		var ci="";
		var la="";
		var lo="";

		// is ok ?
		//
		var isok	= new Object();
		var xml		= t.getElementsByTagName('v');
		if (xml.length>0) {	
			for (i=0; i<xml.length; i++) {
				if (xml[i].getAttribute('z')=="1")
					stoptou=1;
			}
		}

		// Les ligues
		//
		var ligues	= new Object();
		var xml		= t.getElementsByTagName('l');
		if (xml.length>0) {	
			for (i=0; i<xml.length; i++) {
				ligues[xml[i].getAttribute('i')]=xml[i].getAttribute('n');
			}
		}

		// Le Golf
		//
		var type = new Object();
		type[""] = "-";
		type["1"] = "9 trous ou plus";
		type["2"] = "Compact";
		type["3"] = "Golf Compact";
		type["4"] = "Golf Pitch & Putt";

		//s+= "<br />";
		var xml = t.getElementsByTagName('g');
		if (xml.length>0) {
			for (i=0; i<xml.length; i++) {
				//s+="&nbsp;&nbsp;&nbsp;<a href=\"javascript:del2favoriteg("+xml[i].getAttribute('golf_ffid')+")\">[Supprimer de vos favoris]</a><br />";
				var golf_ffid = xml[i].getAttribute('golf_ffid');
				//stitle+= "<h1>Informations complètes sur le "+xml[i].getAttribute('name')+"</h1><br />";
				var sgolf = xml[i].getAttribute('name');
				s+="<table class=\"formtable2\"><tr><td><img src=\"pictures/corner_tl.gif\" border=\"0\" alt=\"\" /></td><td align=\"right\"><img src=\"pictures/corner_tr.gif\" border=\"0\" alt=\"\" /></td></tr>";
				na = xml[i].getAttribute('name');
				s+="<tr class=\"re\"><td width=\"80\">&nbsp;&nbsp;<b>Nom :</b></td><td width=\"360\">&nbsp;&nbsp;<h1>"+na+"</h1>&nbsp;&nbsp;</td></tr>";
				//s+="<tr><td>&nbsp;&nbsp;<b>Nom commun</b></td><td>&nbsp;&nbsp;"+xml[i].getAttribute('shortname')+"&nbsp;&nbsp;</td></tr>";
				ad = xml[i].getAttribute('adresse');
				s+="<tr><td>&nbsp;&nbsp;<b>Adresse :</b></td><td>&nbsp;&nbsp;"+ad+"&nbsp;&nbsp;</td></tr>";
				zi = xml[i].getAttribute('zipcode');
				s+="<tr class=\"re\"><td>&nbsp;&nbsp;<b>CP :</b></td><td>&nbsp;&nbsp;"+zi+"&nbsp;&nbsp;</td></tr>";
				ci = xml[i].getAttribute('city');
				s+="<tr><td>&nbsp;&nbsp;<b>Ville :</b></td><td>&nbsp;&nbsp;"+ci+"&nbsp;&nbsp;</td></tr>";
				lo = xml[i].getAttribute('longitude');
				la = xml[i].getAttribute('latitude');
				s+="<tr class=\"re\"><td>&nbsp;&nbsp;<b>Tél :</b></td><td>&nbsp;&nbsp;"+xml[i].getAttribute('phone')+"&nbsp;&nbsp;</td></tr>";
				s+="<tr><td>&nbsp;&nbsp;<b>Fax :</b></td><td>&nbsp;&nbsp;"+xml[i].getAttribute('fax')+"&nbsp;&nbsp;</td></tr>";
				s+="<tr class=\"re\"><td>&nbsp;&nbsp;<b>Web :</b></td><td>&nbsp;&nbsp;<a href=\""+xml[i].getAttribute('site_web_club')+"\" target=\"_zgolf\">"+xml[i].getAttribute('site_web_club')+"</a>&nbsp;&nbsp;</td></tr>";
				s+="<tr><td>&nbsp;&nbsp;<b>Ouvert :</b></td><td>&nbsp;&nbsp;"+xml[i].getAttribute('periode_ouverture')+"&nbsp;&nbsp;</td></tr>";
				s+="<tr class=\"re\"><td>&nbsp;&nbsp;<b>Fermé :</b></td><td>&nbsp;&nbsp;"+xml[i].getAttribute('periode_fermeture')+"&nbsp;&nbsp;</td></tr>";
				s+="<tr><td><img src=\"pictures/corner_bl.gif\" border=\"0\" alt=\"\" /></td><td align=\"right\"><img src=\"pictures/corner_br.gif\" border=\"0\" alt=\"\" /></td></tr></table>";
				var meteo_cities_id = xml[i].getAttribute('meteoid');
			}
		}

		// Get météo
		var opt = {
			method: 'post',
			parameters: {city_code:meteo_cities_id},
			onSuccess: function(t) {
				var tmp_resp = t.responseText;
				var tmp_resp2 = "<br /><a href=\"golf_info.php?golf_ffid="+golf_ffid+"\" title=\"Informations complémentaires sur "+sgolf+"\" onclick=\"Modalbox.show(this.href, {title: this.title, width: 740}); return false;\">Cliquez ici pour obtenir les informations complémentaires sur ce Golf</a>";
				if (tmp_resp!="")
					tmp_resp="<br /><div style=\"position:relative;top:0px;left:0px;width:710px;height: 210px;padding:0px 0px;margin:0px;\"><div style=\"position: absolute;top: 0px;left: 0px;width: 460px;height: 210px;padding: 0px 0px;margin: 0px;font: normal 12px Verdana, Arial, Helvetica, sans-sherif;color: #666;background-color: white;\">"+s+tmp_resp2+"</div><div style=\"position: absolute;top: 0px;left: 460px;width: 228px;height: 210px;padding: 0px 10px;margin: 0px;border:#AAA 1px solid;\">"+tmp_resp+"</div></div>";
				var tmp_map = "";
				if ((la!=0)&&(lo!=0)) {
					tmp_map="<br /><div style=\"position:relative;top:0px;left:0px;width:710px;height:15px;padding:0px 0px;margin:0px;\"><div style=\"position: absolute;top: 0px;left: 0px;width: 360px;height: 15px;padding: 0px 0px;margin: 0px;font: normal 12px Verdana, Arial, Helvetica, sans-sherif;color: #666;background-color: white;\"><b>PLAN/SATELLITE</b><br /></div><div style=\"position: absolute;top: 0px;left: 360px;width: 350px;height: 15px;padding: 0px 0px;margin: 0px;border:0px;\"><b>TRAFFIC</b><br /></div></div>";
					tmp_map=tmp_map+"<div id=\"map_canvas2_container\"><div id=\"map_canvas2\"></div><div id=\"map_canvas2_legend\"><img src=\"http://sfrgolf.v-trafic.com/carte/getmap.aspx?la="+la+"&lo="+lo+"&d=10&w=350&h=290&q=90\" width=\"350\" heigth=\"290\" border=\"0\" alt=\"\"></div></div>";
				}
				if (stoptou==0) {
					$('div_right_content').innerHTML=tmp_resp+tmp_map;

					if ((la!=0)&&(lo!=0)) {
						var map;
						if (GBrowserIsCompatible()) {
							var point = new GLatLng(la,lo);
							map = new GMap2(document.getElementById("map_canvas2"),{ size: new GSize(350,290) } );
							map.removeMapType(G_HYBRID_MAP);
							map.setCenter(point, 11);
							map.addControl(new GLargeMapControl());
							var mapControl = new GMapTypeControl();
							map.addControl(mapControl);
							map.addOverlay(createMarker(point,icongre,"<b>"+na+"</b><br/>"+ad+"<br/>"+zi+" "+ci));
						}
					}

				}
				$("div_right_content").show();
			},
			onFailure: function(t) { alert('Error ' + t.status + ' -- ' + t.statusText); }
		};
		new Ajax.Request('ajax_get_city_meteo2.php', opt);

	}
	//latchingStop();
}


function getAllTerrain(xml,a) {
	var t = "";
	var count = xml.length;
	for (i=0; i<count; i++) {
		t+="<td>"+xml[i].getAttribute(a)+"</td>";
	}
	return t;
}


function getAllTerrainType(xml,a) {
	var type = new Object();
	type[""] = "-";
	type["1"] = "18 trous";
	type["2"] = "9 trous";
	type["3"] = "Golf Compact";
	type["4"] = "Golf Pitch & Putt";
	type["5"] = "Parcours Compact";

	var t = "";
	var count = xml.length;
	for (i=0; i<count; i++) {
		t+="<td>"+type[xml[i].getAttribute(a)]+"</td>";
	}
	return t;
}

function getBool2Text(a) {
	return (a=="1") ? "Oui" : "Non";
}

function getAllTerrainBool(xml,a) {
	var t = "";
	var count = xml.length;
	for (i=0; i<count; i++) {
		t+="<td>"+getBool2Text(xml[i].getAttribute(a))+"</td>";
	}
	return t;
}
