var info_bulle = 0;
var ajaxParamsTab = new Array();

function popup_alert(texte)
{
	
	var w = 300;
	var h = 120;
	var titre = "Alerte Oceanes";

	win = new Window({className: "alphacube",  title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update("<br>"+texte+"<br><br><div align='center' class='alert_buttons'><input type='button' value='Fermer ' onclick='Dialog.okCallback()'/></div>");
	win.showCenter();
}

function Info_bulle(id,table)
{
	var url = 'ajax/infobulle.php';
	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "&table="+table+"&id="+id+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_infobulle});
			

}
function Info_bulle_S(id,table)
{
	var url = 'ajax/infobulle.php';
	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "&table="+table+"&id="+id+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_infobulle_S});
}
function ajax_response_infobulle_S(transport)
{
	var w = 400;
	var h = 250;
	var titre = "Info Oceanes";


	win = new Window({className: "alphacube",  title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(transport.responseText);
	win.showCenter();
	
}
function ajax_response_infobulle(transport)
{
	
	
	if(info_bulle == 0)
	{
		info_bulle = 1;
	}
	else
	{
		Windows.closeAll();
		
	}
	
	var w = 400;
	var h = 250;
	var titre = "Info Oceanes";


	win = new Window({className: "alphacube",  title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(transport.responseText);
	win.showCenter();
	
}
/*-----------------------------------------------------------------------------*/
function popup_wait()
{
	var w = 300;
	var h = 100;
	var titre = "Veuillez patienter";


	win = new Window({className: "alphacube",  title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update("<br>Veuillez patienter pendant le chargement de la vidéo<br><br>");
	win.showCenter();
	setTimeout("Dialog.okCallback()",5000);

}
/*-----------------------------------------------------------------------------*/
function valider_inscription_newsletter()
{


	if(! document.getElementById('email_input').value)
	{
	 		popup_alert("Veuillez saisir votre adresse email.")
	 		return ;

	}

	if(document.getElementById('confirm').checked == false)
	{
	 		popup_alert("Pour valider votre inscription, veuillez cocher la case de confirmation.")
			return ;
	}

	if(document.getElementById('confirm').checked == true && ! document.getElementById('email_input').value)
	{
		popup_alert("Pour valider votre inscription, veuillez saisir votre adresse email.")
			return ;
	}


	if(document.getElementById('confirm').checked == true && document.getElementById('email_input').value)
	{
			if(validemail("email_input"))
			{
				var url = 'verif_email_newsletter.php';

				var parametre = new String();

				parametre = "email="+document.getElementById('email_input').value;
				
				new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: parametre+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_newsletter});

			}
	}
}
function ajax_response_newsletter(transport)
{
	//var regExpBeginning = /^\s+/;

	
	//reponse.replace(regExpBeginning, "");
	var tableau=transport.responseText.split('|');

 
	var reponse = tableau[1];
	
	
	
	if(reponse =="OK")
	{
		document.formulaire.submit();

	}
	else
		popup_alert("L'adresse mail saisie est déjà présente dans notre base de données.\nVeuillez en saisir une autre.")

}
/*-----------------------------------------------------------------------------*/

function Popup_image(w,h,titre,image,repertoire)
{
	if(repertoire != null)
		var photo = "<img src='images/upload/"+repertoire+"/"+image+"'>";
	else
		var photo = "<img src='"+image+"'>";

	if(h>500)
	{
		h=480;
		var temp2= new Number(w);
		var temp = new Number(temp2+20);
	}
	else
		var temp =w;


	win = new Window({className: "alphacube", title: titre, width:temp, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(photo);
	win.showCenter();
}
/*-----------------------------------------------------------------------------*/
function Popup_texte(w,h,titre,texte)
{
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(texte);
	win.showCenter();
}
/*-----------------------------------------------------------------------------*/
function Oubli_Passe()
{
	var url = 'ajax/content_oubli_passe.php';

	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "trompeCache="+new Date().getTime(), onComplete: ajax_response_mot_passe});

}

function ajax_response_mot_passe(transport)
{

	var w =320;
	var h=180;
	
	var tableau=transport.responseText.split('|');

 	var titre = tableau[0];
	var texte = tableau[1];
	
	
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(texte);
	win.showCenter();
}

function Envoi_mot_passe()
{
	//alert($('email').value);
	Dialog.okCallback();
	var url = 'ajax/envoi_passe.php';

	var parametre = new String();

	parametre = "email="+$('email').value;


	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: parametre+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_envoi_passe});
	
}
function ajax_response_envoi_passe(transport)
{
	
	
	var tableau=transport.responseText.split('|');
	var titre = tableau[0];
	var texte = tableau[1];
	
	var w =320;
	var h=100;
	
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(texte);
	win.showCenter();
	
}
/*-----------------------------------------------------------------------------*/
function Popup_infos(id_pays,titre,flag)
{
	var url = 'info_popup_pays.php';

	var parametre = new String();

	parametre = "id_pays="+id_pays+"&titre="+titre+"&flag="+flag;


	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: parametre+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_infos});

}
function ajax_response_infos(transport)
{
//alert("In ajax_response_infos");
	var w =470;
	var h=515;
	var chaine = new String(transport.responseText);
	var reg=new RegExp("[|]+", "g");
	var tableau=chaine.split(reg);
	var titre = tableau[0];
	
	//alert("Just before new Window");
	// Modif SPL 20100708 : Ancienne version Prototype
	//win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	//win.getContent().update(tableau[1]);
	//win.showCenter();
	
	// Nouvelle version jQuery
	jQuery.noConflict();
	jQuery(document).ready(function() {
		jQuery('#info_popin').jqm().jqDrag('#handle');
		jQuery('#info_popin_title').empty().append(tableau[0]);
		jQuery('#info_popin_content').empty().append(tableau[1]);
		jQuery('#info_popin').jqmShow();
	});
	//alert("Just after new Window");
}
/*-----------------------------------------------------------------------------*/
function Popup_zoom_pays(id_voyage,id_pays)
{
	var url = 'zoom_voyage.php';

	var parametre = new String();




	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "id_voyage="+id_voyage+"&id_pays="+id_pays+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_zoom});

}
function ajax_response_zoom(transport)
{

	var w =470;
	var h=370;
	var titre = '&nbsp;'
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(transport.responseText);
	win.showCenter();

}
/*-----------------------------------------------------------------------------*/

function controle_choix(nom_argument,id_voyage)
{
	//alert(document.getElementById(nom_argument).checked)
	if(document.getElementById(nom_argument).checked == false)
	{
	 		var add = new Number(document.form_resultat.nb_voyage.value);
	 		document.form_resultat.nb_voyage.value= add - 1;

	 		if(document.form_resultat.choix_1.value == id_voyage)
	 			document.form_resultat.choix_1.value = 0;
				
	  		if( document.form_resultat.choix_2.value == id_voyage)
	 			document.form_resultat.choix_2.value = 0;
				
	 		if( document.form_resultat.choix_3.value == id_voyage)
	 			document.form_resultat.choix_3.value = 0;
				
			//alert("choix1:"+document.form_resultat.choix_1.value+"choix2:"+document.form_resultat.choix_2.value+"choix3:"+document.form_resultat.choix_3.value)
	
	}
	else
	{
		var add = new Number(document.form_resultat.nb_voyage.value);
		if(add >= 3 )
		{
			popup_alert("Vous ne pouvez pas comparer plus de 3 voyages.")
			document.getElementById(nom_argument).checked = false;
		}
		else
		{
			//alert(document.getElementById(nom_argument).checked)
		  if(document.getElementById(nom_argument).checked == true)
		  {
			var add = new Number(document.form_resultat.nb_voyage.value);
				document.form_resultat.nb_voyage.value= add +1;
	
				if(document.form_resultat.choix_1.value=="" || document.form_resultat.choix_1.value==0)
					document.form_resultat.choix_1.value = id_voyage;
				else if(document.form_resultat.choix_2.value=="" || document.form_resultat.choix_2.value==0)
					document.form_resultat.choix_2.value = id_voyage;
				else if(document.form_resultat.choix_3.value=="" || document.form_resultat.choix_3.value==0)
					document.form_resultat.choix_3.value = id_voyage;
		  }
		}
	}
	//alert(document.form_resultat.nb_voyage.value);
	//alert("hchoix1:"+document.form_resultat.choix_1.value+"choix2:"+document.form_resultat.choix_2.value+"choix3:"+document.form_resultat.choix_3.value)

}

function Popup_comparaison()
{
	var url = 'comparaison.php';

	var parametre = new String();
	var nb = new Number(0);
	if(document.forms["form_resultat"] != null)
	{
		//alert("&choix_1="+document.form_resultat.choix_1.value)
		//alert("&choix_2="+document.form_resultat.choix_2.value)
		//alert("&choix_3="+document.form_resultat.choix_3.value)
		if(document.form_resultat.choix_1.value != "" && document.form_resultat.choix_1.value!="0")
		{
		 //			alert(" :: >"+document.form_resultat.choix_1.value)
		 			parametre = "&choix_1="+document.form_resultat.choix_1.value;
		 
					
		}
		if(document.form_resultat.choix_2.value!="" && document.form_resultat.choix_2.value!="0" && document.form_resultat.choix_2.value!=document.form_resultat.choix_3.value  && document.form_resultat.choix_2.value!=document.form_resultat.choix_1.value)
		{
		 			parametre += "&choix_2="+document.form_resultat.choix_2.value;
		 
					
		}
		if(document.form_resultat.choix_3.value!="" && document.form_resultat.choix_3.value!="0")
		{
		 			parametre += "&choix_3="+document.form_resultat.choix_3.value;
		 
					
		}
		nb = document.form_resultat.nb_voyage.value;
		//alert(parametre)
		//alert(nb)
	
	if(nb>1)
	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "&nb="+nb+parametre+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_comparaison_publish});
	else
		popup_alert("Vous devez au moins séléctionner 2 voyages.");

	}
}
function ajax_response_comparaison_publish(transport)
{

	var w =670;
	var h=480;
	var titre = 'Comparer plusieurs voyages'
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(transport.responseText);
	win.showCenter();

}
/*-----------------------------------------------------------------------------*/
function openInfoDialog(w,h,titre,image,repertoire) 
{ 
	Dialog.info("Test of info panel, it will close <br>in 3s ...", {className: "alphacube", width:250, height:100, showProgress: true}); 
	timeout=3; 
	setTimeout(infoTimeout(w,h,titre,image,repertoire), 1000) 
} 
function infoTimeout(w,h,titre,image,repertoire) 
{ 
	timeout--; 
		
	if (timeout >0) 
	{ 
		Dialog.setInfoMessage("Test of info panel, it will close <br>in " + timeout + "s ...") 
		setTimeout(infoTimeout(w,h,titre,image,repertoire), 1000) 
	} 
	else 
	{
		Dialog.closeInfo() 
		
			
	}
} 	

function Popup_video(w,h,titre,image,repertoire)
{
	//var timeout; 
	//openInfoDialog(w,h,titre,image,repertoire);
	
	
	if(repertoire != null)
			var video = repertoire+"/"+image;
		else
			var video = image;
		
		
	
		win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	
		//var content = "<script type=\"text/javascript\">		if(hasRightVersion) { 				AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','640','height','480','src','"+image+"','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','"+image+"','flashVars','' ); 		}else{				document.write(\"Ce site nécessite le player Flash version 7 minimum : <br><a href='http://www.macromedia.com/go/getflash/' target='_blank'>cliquez ici pour le télécharger</a>\");		}</script> <noscript><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"640\" height=\"480\">		  <param name=\"movie\" value=\""+image+"\" />		  <param name=\"quality\" value=\"high\" />		  <embed src=\""+image+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"640\" height=\"480\"></embed>		</object></noscript>";
		if(hasRightVersion)
		{
		//	var content = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"640\" height=\"480\">		  <param name=\"movie\" value=\""+video+"\" />		  <param name=\"quality\" value=\"high\" />		  <embed src=\""+video+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+w+"\" height=\""+h+"\"></embed>		</object>";
		
			var content = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"640\" height=\"480\">		  <param name=\"movie\" value=\"http://www.oceanes.com/flash/loader_video.swf?video="+video+"\" />		  <param name=\"quality\" value=\"high\" />		  <embed src=\"http://www.oceanes.com/flash/loader_video.swf?video="+video+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+w+"\" height=\""+h+"\"></embed>		</object>";
		}
		else
		{
			var content = "Ce site nécessite le player Flash version 7 minimum : <br><a href='http://www.macromedia.com/go/getflash/' target='_blank'>cliquez ici pour le télécharger</a>\"";
		}
	
	
	
		win.getContent().update(content);
		win.showCenter();
}
/*-----------------------------------------------------------------------------*/
// Selection des animaux préférés
function GetSelectedItem()
{
	var selectList = document.getElementById("animaux");
  var selectIndex = selectList.selectedIndex;
  if(document.getElementById("animaux").value)
  {
  	//document.location.href=selectList.options.value;
  	document.location.href=document.getElementById("animaux").value
  }

}

// verifie la validite d'un email
function validemail(champ)
{

 test = document.formulaire.elements[""+champ+""].value;
 valeur = test.indexOf("@");
 valeur2 = test.lastIndexOf(".");
 valeur3 = valeur2 + 1;
 longueur = test.length;
 ext = test.substring(valeur3,longueur);
 ok=0;
 temp = ext.length;
 if ( temp==2 || temp==3 )
    { ok=1; }
 else
    { ok=0; }
 if ( valeur2 == (valeur + 1) )
     { ok=0; }
 if (valeur==0)
     { ok=0; }
 if (valeur==-1 || valeur2==-1 || ok==0)
    { popup_alert(get_trad_champ("email"));
      return false; }
 else
    { return true; }

}

// verifie les champs obligatoire d'un formulaire
valider_formulaire = function () {
	var tab = valider_formulaire.arguments;

	taille = tab.length;

	for (i=0;i<taille;i++) {
		if (tab[i]=="email") {
			if (!validemail(tab[i])) {
				return 0;
			}
		}else{
			if ((document.formulaire.elements[tab[i]].value=="") || (document.formulaire.elements[tab[i]].value==" ")) {
				str_temp = tab[i].replace(/_/g," ");
				popup_alert(get_trad_champ(str_temp));
				return 0;
			}
		}
	}

	document.formulaire.submit();
}
// test les champs obligatoire d'un formulaire et colorise en rouge les bordures des champs en erreur
// un select dont l'option 0 est sélectionné est considéré en erreur
// pour un champ date calendrier, on colorise le div correspondant (nom_champ_date+_display)
// le premier arg est l'objet formulaire, le second une chaine "nom_champ1,nom_champ2,..."
function verif_and_color_formulaire(objForm,args){
	tab = args.split(",")
	var all_right = true;
	var alertcolor="#1397e9";
	// alert("uu");
	for (i=0;i<tab.length;i++)
	{			
				if(objForm.elements[tab[i]] == null)
				{
					//popup_alert("information de déboguage : "+tab[i] + " n'existe pas");
				}
				else
				{						
										if(objForm.elements[tab[i]].type!="radio")
										{
											objForm.elements[tab[i]].style.border="0px solid";
											objForm.elements[tab[i]].style.background="#d9dbdd";
										}

											// si c'est un champ date on colorise le div caché
										if(objForm.elements[tab[i]].name.indexOf("date") > -1)
										{
											if (objForm.elements[tab[i]].value == "")
											{		
													// document.getElementById(tab[i]+"_display").style.color=alertcolor;
													document.getElementById(tab[i]+"_display").innerHTML="<img src='images/divers/alerte.gif'>";
													all_right = false;
													
											}

										}
										// si c'est un champ téléphone
										if(objForm.elements[tab[i]].name.indexOf("_tel") > -1 || objForm.elements[tab[i]].name.indexOf("mobile") > -1)
										{
											var tmpval = objForm.elements[tab[i]].value;
											tmpval = replace_all(tmpval," ","");
											
											if (( ! /^[0-9]{5}/g.test(tmpval)) && ( ! /^\+[0-9]{6}/g.test(tmpval)) && ( ! /^\+\([0-9]{2}\)[0-9]{4}/g.test(tmpval)))
											{
												objForm.elements[tab[i]].style.border="2px solid "+alertcolor;	
												all_right = false;
											}

										}
										if(objForm.elements[tab[i]].name.indexOf("email") > -1)
										{
											if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,10})+$/.test(objForm.elements[tab[i]].value)))
											{
													objForm.elements[tab[i]].style.border="2px solid "+alertcolor;
													all_right = false;
											}
										}
										
										if(objForm.elements[tab[i]].type=="select-one")
										{		
													if(objForm.elements[tab[i]].selectedIndex==0)
													{	
														objForm.elements[tab[i]].style.border="2px solid "+alertcolor;
														objForm.elements[tab[i]].style.background= alertcolor;
														all_right = false;
													}

										}
										if(objForm.elements[tab[i]].type=="checkbox")
										{
											if(objForm.elements[tab[i]].checked == false)
											{

													document.getElementById(tab[i]+"_display").innerHTML="<img src='images/divers/alerte.gif'>";
													all_right = false;
											}
										}
										if ((objForm.elements[tab[i]].value=="") || (objForm.elements[tab[i]].value==" "))
										{
												objForm.elements[tab[i]].style.border="2px solid "+alertcolor;
												all_right = false;
										}
				}
		}
		return all_right;
}
function empechechar()
{
	if( event.keyCode < 48 || event.keyCode > 57 )
 	{
 		popup_alert(get_trad_champ("numeric") );
   		event.returnValue = false;
   	}
}

// fonction qui fait apparaitre le sablier sur soumission de formulaire un peu long..

// Variable témoin de la validation effectuée ou pas
var deja = 0;

function valider(nom_form) {
	// Si on n'a pas déjà validé
	if ( deja == 0 ) {

		// On marque qu'on valide
		deja = 1;

		// On affecte le style 'sablier' au corps de la page
		document.body.className = 'sablier';

		// On lance la soumission du formulaire
		eval('document.'+nom_form+'.submit()');
	} /*else {
		popup_alert('Le formulaire est déjà validé, veuillez patienter.'); */
}

function show_sablier()
{
	document.body.className = 'sablier';
}

choix_thema = function ()
{
	var tab_thema_espece = choix_thema.arguments;

	var is_thema_espece = false;
	for (i=0; i<tab_thema_espece.length;i++)
	{
		if (document.getElementById("thematique").value == tab_thema_espece[i])
			is_thema_espece = true;
	}

	if (is_thema_espece)
	{
		document.getElementById("div_espece").style.display = "block";
	}
	else
	{
		document.getElementById("espece").value="0";
		document.getElementById("div_espece").style.display = "none";
	}
}

function valider_recherche_rapide()
{
	//Il faut au moins choisir un critère
	var nb_critere = 0;
	if (document.getElementById("periode").value>0)
		nb_critere++;
	if (document.getElementById("thematique").value>0)
		nb_critere++;
	if (document.getElementById("destination").value>0)
		nb_critere++;
	//if (document.getElementById("budget").value>0)
		//nb_critere++;
	var tab_type_voyage = document.getElementsByName("type_voyage") ;
	for (i=0; i<tab_type_voyage.length; i++)
	{
		if (tab_type_voyage[i].checked) nb_critere++;

	}

	if (nb_critere==0){
		popup_alert(get_trad_lib("lib_un_critere"));
	}
	else
		document.form_recherche_rapide.submit();
}

function valider_recherche_multi()
{
	//Il faut au moins choisir un critère
	var nb_critere = 0;
	if (document.form_recherche_multi.type_voyage.value>0)
		nb_critere++;
	if (document.form_recherche_multi.mois_saison.value>0)
		nb_critere++;
	if (document.getElementById("mois_saison").value!="")
		nb_critere++;
//	if (document.getElementById("date_deb").value!="")
//		nb_critere++;
//	if (document.getElementById("date_fin").value!="")
//		nb_critere++;
	if (document.form_recherche_multi.thematique.value>0)
		nb_critere++;
	if (document.getElementById("non_plongeur").checked==true)
		nb_critere++;
	if (document.getElementById("en_famille").checked==true)
		nb_critere++;
	if (document.form_recherche_multi.destination.value>0)
		nb_critere++;
	if (document.form_recherche_multi.budget.value>0)
		nb_critere++;

	if (nb_critere==0){
		popup_alert(get_trad_lib("lib_un_critere"));
	}
	else
		document.form_recherche_multi.submit();
}

function change_pag(page)
{
	document.getElementById("P").value = page;
	document.form_resultat.submit();
}

function compare_voyage()
{
	var nb_choisi = 0;
	if(document.forms["form_resultat"] != null)
	{
		for (i=0; i<tab_checkbox.length; i++)
		{
			if (document.getElementById("check_voyage_"+tab_checkbox[i]).checked)
			{
				nb_choisi++;
				if (nb_choisi<=3)
					document.getElementById("choix_"+nb_choisi).value = tab_checkbox[i];
			}
			if (nb_choisi>3)
			{
				popup_alert(get_trad_lib("lib_choix_3_voyage"));
			}
		}
	}
}

function change_tri()
{
		document.form_resultat.submit();
}

function openImage(id_image) {
		window.open('popup_image.php?id_image='+id_image+'','Photos','width=600,height=400,scrollbars=no' );
}
function openVideo(id_video) {
		window.open('popup_video.php?id_video='+id_video+'','Videos','width=640,height=480,scrollbars=no' );
}
function openDiaporama(image) {
		window.open('popup_diaporama.php?image='+image+'','Diaporama','width=600,height=400,scrollbars=no' );
}
Array.prototype.in_array = function(val) {
   for (var i in this) {
      if (this[i] == val) return true;
   }
   return false;
};
addDays = function(d, j)
{
 return new Date(d.getTime() + (1000 * 60 * 60 * 24 * j));
}
function replace_all(str,chr,chr2){
	var str = str.replace(chr,chr2);
	while(/ /g.test(str))
		str = str.replace(chr,chr2); 
	str = str.replace(chr,chr2); 
	return str;
	
}

/*--Evolutions 2008 TLY 07/07/2008 Lot1 page intermédiaire dans le processus commande, lorsqu'on sort de la saisie du nb des plongeurs*/

function OnlyNumber(e) 
{ 
	// if aEvent is null, means the Internet Explorer event model, 
	// so get window.event. 
	var IE5 = false; 
	
	if (!e) var e = window.event; 
	if (e.keyCode) { IE5= true; code = e.keyCode;} 
	else if (e.which) code = e.which ; 
	
	//test du code 
	if (code < 48 || code > 57) 
	{ 
		if(IE5) e.returnValue = false; 
		else e.preventDefault(); 
	}	 
} 


function mod(divisee,base) {
	// Created 1997 by Brian Risk.  http://members.aol.com/brianrisk
	return Math.round(divisee - (Math.floor(divisee/base)*base));
}


Number.prototype.isMultipleOf = function(n) { return ( this/n == Math.round(this/n) )};

function verif_saisie_forfaits(id1,id2,nb_mod,lib_err){
	
	var nb1 = document.getElementById(id1).value;			
	var nb2 = document.getElementById(id2).value;			
	
	if (nb1 == "" && !(parseInt(nb2).isMultipleOf(nb_mod)) )	document.getElementById(id2).value = "" ;
	else {				
		if (nb1 != "" && !(parseInt(nb1).isMultipleOf(nb_mod))){			
			document.getElementById(id2).value = nb_mod - mod(nb1,nb_mod);				//popup_alert(lib_err); 		
		}
		else {						
			if (!(parseInt(nb2).isMultipleOf(nb_mod))) 	document.getElementById(id2).value = "" ;
		}
	}
}


function onKeyup_saisie_forfaits(f_s,f_sn,f_d,f_dn,f_t,f_tn,f_tot,id_tarifs)
{

		var nb_forf_1_pl = document.getElementById('nb_forf_1_pl').value;
		var nb_forf_2_pl = document.getElementById('nb_forf_2_pl').value;
		var nb_forf_3_pl = document.getElementById('nb_forf_3_pl').value;
		var nb_forf_1_non_pl = document.getElementById('nb_forf_1_non_pl').value;
		var nb_forf_2_non_pl = document.getElementById('nb_forf_2_non_pl').value;
		var nb_forf_3_non_pl = document.getElementById('nb_forf_3_non_pl').value;
		
		if (nb_forf_1_pl == "") nb_forf_1_pl = 0;
		if (nb_forf_2_pl == "") nb_forf_2_pl = 0;
		if (nb_forf_3_pl == "") nb_forf_3_pl = 0;
		if (nb_forf_1_non_pl == "") nb_forf_1_non_pl = 0;
		if (nb_forf_2_non_pl == "") nb_forf_2_non_pl = 0;
		if (nb_forf_3_non_pl == "") nb_forf_3_non_pl = 0;
		
		if (parseFloat(nb_forf_1_pl) > 1) f_s = f_s.replace(/forfait/, 'forfaits');
		if (parseFloat(nb_forf_2_pl) > 1) f_d = f_d.replace(/forfait/, 'forfaits');
		if (parseFloat(nb_forf_3_pl) > 1) f_t = f_t.replace(/forfait/, 'forfaits');
		if (parseFloat(nb_forf_1_non_pl) > 1) f_sn = f_sn.replace(/forfait/, 'forfaits');
		if (parseFloat(nb_forf_2_non_pl) > 1) f_dn = f_dn.replace(/forfait/, 'forfaits');
		if (parseFloat(nb_forf_3_non_pl) > 1) f_tn = f_tn.replace(/forfait/, 'forfaits');		
					
		var tarif_1_pl = document.getElementById('id_tarif_forfait_1_pl').value;
		var tarif_2_pl = document.getElementById('id_tarif_forfait_2_pl').value;
		var tarif_3_pl = document.getElementById('id_tarif_forfait_3_pl').value;		
		var tarif_1_non_pl = document.getElementById('id_tarif_forfait_1_non_pl').value;
		var tarif_2_non_pl = document.getElementById('id_tarif_forfait_2_non_pl').value;
		var tarif_3_non_pl = document.getElementById('id_tarif_forfait_3_non_pl').value;		
				
		var tot1 = parseFloat(nb_forf_1_pl)*parseFloat(tarif_1_pl);
		var tot2 = parseFloat(nb_forf_2_pl)*parseFloat(tarif_2_pl);
		var tot3 = parseFloat(nb_forf_3_pl)*parseFloat(tarif_3_pl);		
		var tot11 = parseFloat(nb_forf_1_non_pl)*parseFloat(tarif_1_non_pl);
		var tot22 = parseFloat(nb_forf_2_non_pl)*parseFloat(tarif_2_non_pl);
		var tot33 = parseFloat(nb_forf_3_non_pl)*parseFloat(tarif_3_non_pl);
		var total = tot1+tot2+tot3+tot11+tot22+tot33;		
		
		
		if (total != 0) {
			var chaine_total ="<table width=\"100%\" cellspacing=\"1\" cellpadding=\"0\" border=\"0\">";
			if (tot1 != 0) chaine_total +="<tr><td style=\"width:200px;\">"+nb_forf_1_pl+"&nbsp;"+f_s+"&nbsp;</td><td style=\"width:40px;text-align:right;\">"+ tot1 +"€</td></tr>";
			if (tot11 != 0) chaine_total +="<tr><td style=\"width:200px;\">"+nb_forf_1_non_pl+"&nbsp;"+f_sn+"&nbsp;</td><td style=\"width:40px;text-align:right;\">"+ tot11 +"€</td></tr>";
			if (tot2 != 0) chaine_total +="<tr><td style=\"width:200px;\">"+nb_forf_2_pl+"&nbsp;"+f_d+"&nbsp;</td><td style=\"width:40px;text-align:right;\">"+ tot2 +"€</td></tr>";
			if (tot22 != 0) chaine_total +="<tr><td style=\"width:200px;\">"+nb_forf_2_non_pl+"&nbsp;"+f_dn+"&nbsp;</td><td style=\"width:40px;text-align:right;\">"+ tot22 +"€</td></tr>";
			if (tot3 != 0) chaine_total +="<tr><td style=\"width:200px;\">"+nb_forf_3_pl+"&nbsp;"+f_t+"&nbsp;</td><td style=\"width:40px;text-align:right;\">"+ tot3 +"€</td></tr>";
			if (tot33 != 0) chaine_total +="<tr><td style=\"width:200px;\">"+nb_forf_3_non_pl+"&nbsp;"+f_tn+"&nbsp;</td><td style=\"width:40px;text-align:right;\">"+ tot33 +"€</td></tr>";
						   chaine_total +="<tr><td colspan=\"2\">";
								chaine_total +="<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
									chaine_total +="<tbody><tr><td width=\"100%\" valign=\"middle\" height=\"2\" bgcolor=\"#212121\" align=\"right\"/></tr></tbody>";
								chaine_total +="</table>";
								chaine_total +="</td>";
			    		 chaine_total +="</tr>";							
	    					chaine_total +="<tr><td style=\"width:300px;text-align:right;padding-right:15px;\">"+f_tot+"</td><td style=\"width:40px;text-align:right;\">"+total+"€</td></tr>";
	    	chaine_total +="</table>";
	    	document.getElementById('bloc_total').innerHTML = chaine_total;	
	    	document.getElementById('bloc_repartition_des_participants').style.display = 'block';
//	    	document.getElementById('bloc_supp_hebergement_entete').style.display = 'block';
		}
		else {
			document.getElementById('bloc_total').innerHTML = "";			
			document.getElementById('id_nb_participants').value = "";
			document.getElementById('bloc_repartition_des_participants').style.display = 'none';
			//document.getElementById('bloc_supp_hebergement_entete').style.display = 'none';
		}
				
	var getparams = "nb1="+nb_forf_1_pl;
	getparams += "&nb11="+nb_forf_1_non_pl;
	getparams += "&nb2="+nb_forf_2_pl;
	getparams += "&nb22="+nb_forf_2_non_pl;
	getparams += "&nb3="+nb_forf_3_pl;
	getparams += "&nb33="+nb_forf_3_non_pl;
	getparams += "&id_tarifs="+id_tarifs;
	
/*	getparams += "&chambre="+ch;
	getparams += "&type_forfait="+type_forf;
	getparams += "&m="+m;
	getparams += "&mme="+mme;
	getparams += "&enf="+enf;
	getparams += "&datenaiss="+datenaiss;
	getparams += "&niv_plongee="+niv_plongee;
	getparams += "&nom="+nom;
	getparams += "&prenom="+prenom;
	getparams += "&cliquer_date="+cliquer_date;*/
			
	var url = 'ajax/generation_participant.php';
		new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: getparams+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_participants});
}

function ajax_response_participants(transport)
{
	//alert(transport.responseText)
	
	var tmp_tab = new Array();
	ajaxRespVar = true;
	tmp_tab = transport.responseText.split("|");
	if(transport.responseText.indexOf('ok') > -1){
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){				
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];				
			}
				
		}
	}	
				
	//alert(ajaxParamsTab["nb_participants"]);
	document.getElementById('id_nb_participants').value = "";
	document.getElementById('id_nb_participants').value = ajaxParamsTab["nb_participants"];			
	document.getElementById('bloc_details_plongeur').innerHTML = "";
	document.getElementById('bloc_details_plongeur').innerHTML = ajaxParamsTab["bloc_details_plongeur"];
	eval(ajaxParamsTab["cal_setup"]);
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function show_hidden_div(id){
		
	if (document.getElementById(id).style.display == "block") 
		document.getElementById(id).style.display = "none";
	else
		document.getElementById(id).style.display = "block";
	
}
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------verif code client ------------------------------------------
//--------------------------------------------------------------------------------------------------------
var result_verif_code_client;
function verif_code_client(id_inscrits,id_code_client){
	
	document.getElementById(id_code_client).style.border = "0px solid";	
	
	var getparams = "code_client="+document.getElementById(id_code_client).value;
		getparams += "&id_inscrits="+id_inscrits;
		getparams += "&id_code_client="+id_code_client;
	
	var url = 'ajax/verif_code_client.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: getparams+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_verif_code_client});	
}

function ajax_response_verif_code_client(transport)
{		
	var tmp_tab = new Array();
	ajaxRespVar = true;
	tmp_tab = transport.responseText.split("|");
	if(transport.responseText.indexOf('ok') > -1){
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){								
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];				
			}				
		}
	}		
	result_verif_code_client = ajaxParamsTab["reponse"];
	
	if (ajaxParamsTab["reponse"] == "no"){						
		popup_alert("Code client invalide");	
		var alertcolor="#1397e9";	
		document.getElementById(ajaxParamsTab["id_code_client"]).style.border="2px solid "+ alertcolor;					
	}
	
	
}

//--------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------- ------------------------------------------
//--------------------------------------------------------------------------------------------------------

function EnregistrerAvis(objForm,id_hebergement,id_inscrits,code_client,id_code_client,note,id_commentaires,lib_js_invalid_fields){

	verif_code_client(id_inscrits,id_code_client);
	if ( result_verif_code_client == "yes" ) {
	
		var alertcolor="#1397e9";
		var commentaires = document.getElementById(id_commentaires).value ;	
		var id_code_client = "id_code_client_"+id_hebergement ;
		
		document.getElementById(id_commentaires).style.border = "0px solid";
		document.getElementById(id_code_client).style.border = "0px solid";
		//alert(Base64.decode(Base64.encode(commentaires)));
		//commentaires = commentaires.replace("€","sigle_euro");
		commentaires = JSReplace(commentaires,"€","sigle_euro");
		
		if(commentaires == "" || code_client == "" ) {
			if(commentaires == "") 		document.getElementById(id_commentaires).style.border="2px solid "+ alertcolor;				
			if (code_client == "") 		document.getElementById(id_code_client).style.border="2px solid "+ alertcolor;				
			popup_alert(lib_js_invalid_fields);		
		}			
		else {
			var getparams = "id_hebergement="+id_hebergement;
			getparams += "&id_inscrits="+id_inscrits;
			getparams += "&code_client="+code_client+"|"+note;
			getparams += "&commentaires="+Base64.encode(commentaires);
			// alert(getparams+"&trompeCache="+new Date().getTime());
			var url = 'ajax/EnregistrerAvis.php';
				new Ajax.Request(
				url, {asynchronous:false,method: 'post',  parameters: getparams+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_enregistrer_avis});	
		}		
	}	
	
	// GPE
	// 2010-09-17
	//document.getElementById("id_bloc_comments_"+id_hebergement).style.display = "none";
	document.getElementById("id_bloc_saisir_comment_"+id_hebergement).style.display = "none";
}

function ajax_response_enregistrer_avis(transport)
{	
	if ( transport.responseText.indexOf('ok') > -1)
		popup_alert("Votre avis a bien été enregistré mais il ne sera publié sur le site qu'après validation de l'administrateur");	
	else if( transport.responseText.indexOf('ko') > -1)
	{
		popup_alert("Une erreur est survenue lors de l'enregistrement de votre avis");
	}
	else{
		popup_alert(transport.responseText);
		
	}
}


//-----------------------------------------------------------------------------
function login_ajax(id_login,id_pwd,lib_js_invalid_fields)
{
	// les champs à contrôler pour une nouvelle inscription
	var alertcolor="#1397e9";
	var login = document.getElementById(id_login).value ;	
	var pwd = document.getElementById(id_pwd).value ;	
	
	document.getElementById(id_login).style.border = "0px solid";
	document.getElementById(id_pwd).style.border = "0px solid";
	
	if (login == "") {
		document.getElementById(id_login).style.border="2px solid "+ alertcolor;						
	}
	
	if (pwd == "") {			
			document.getElementById(id_pwd).style.border="2px solid "+ alertcolor;				
	}
	
	if (login == "" || pwd == "")  {
		popup_alert(lib_js_invalid_fields);		
	}
	else {		
		
	var	getparams = "login="+login;
		getparams += "&pwd="+pwd;			
		
		var url = 'ajax/login.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: getparams+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_login_ajax});			
	}	
}

function ajax_response_login_ajax(transport)
{		
	var tmp_tab = new Array();
	ajaxRespVar = true;
	tmp_tab = transport.responseText.split("|");
	if(transport.responseText.indexOf('ok') > -1){
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){								
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];				
			}				
		}
	}		
	
	if (ajaxParamsTab["reponse"] != "no"){				
		
		document.getElementById('id_welcome').innerHTML = ajaxParamsTab["div_html"] ; 			
		popup_alert("Identification réussie");					
		document.getElementById('id_login_bloc').style.display = 'none';		
		document.getElementById('id_lien_liste').style.display = 'block';				
		document.getElementById('id_lien_liste').innerHTML = ajaxParamsTab["div_lien_mariage"];
	}
	else
		 popup_alert("Authentification échouée : votre identifiant ou mot de passe n'est pas valide");	
}


function rech_mariage_ajax (lib_js_invalid_fields){
	
	// les champs à contrôler pour une nouvelle inscription
	var alertcolor="#1397e9";	
	var date_ceremonie_display = document.getElementById('date_ceremonie_display').innerHTML ;	
	var nom_mariage = document.getElementById('id_nom_mariage').value ;	
		
	document.getElementById('date_ceremonie_display').style.border = "0px solid";
	document.getElementById('id_nom_mariage').style.border = "0px solid";
		
	if (date_ceremonie_display == "" && nom_mariage == "")  {
		popup_alert(lib_js_invalid_fields);
		document.getElementById('date_ceremonie_display').style.border="2px solid "+ alertcolor;		
		document.getElementById('id_nom_mariage').style.border="2px solid "+ alertcolor;
	}
	else {		
			
		var	getparams = "date_ceremonie_display="+date_ceremonie_display;
			getparams += "&nom_mariage="+nom_mariage;			
		
		var url = 'ajax/rech_liste_mariage.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: getparams+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_liste_mariage_ajax});			
			
		if (date_ceremonie_display == "") date_ceremonie_display = "non mentionné";
		if (nom_mariage == "") nom_mariage = "non mentionné";
		
		document.getElementById('id_date_rech').innerHTML = date_ceremonie_display  ;
		document.getElementById('id_nom_rech').innerHTML = nom_mariage;
	}	
	
}

function ajax_response_liste_mariage_ajax(transport)
{		
	var tmp_tab = new Array();
	ajaxRespVar = true;
	tmp_tab = transport.responseText.split("|");
	if(transport.responseText.indexOf('ok') > -1){
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){								
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];				
			}				
		}
	}		
	
	if (ajaxParamsTab["reponse"] != "no"){				
		
		document.getElementById('id_rech_content').innerHTML = ajaxParamsTab["bloc_res"] ;
		document.getElementById('id_liste_mariage').style.display = 'none';
		document.getElementById('id_res_rech').style.display = 'block';		
	}
	else
		 popup_alert("Votre recherche ne correspond à aucun mariage");	
}

//-------------------------------------------------------------------------------------------------------
function voir_fiche_mariage_ajax (id_liste_mariage){
		
	var	getparams = "id_liste_mariage="+id_liste_mariage;			
	
	var url = 'ajax/voir_fiche_mariage.php';
		new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: getparams+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_fiche_mariage_ajax});				
	
}


function ajax_response_fiche_mariage_ajax(transport)
{		
	var tmp_tab = new Array();
	ajaxRespVar = true;
	tmp_tab = transport.responseText.split("|");
	if(transport.responseText.indexOf('ok') > -1){
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){								
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];				
			}				
		}
	}		
	
	if (ajaxParamsTab["reponse"] != "no"){						
		document.getElementById('id_fiche_mariage').innerHTML = ajaxParamsTab["bloc_res"] ;
		document.getElementById('id_fiche_mariage').style.display = 'block';		
		document.getElementById('id_liste_mariage').style.display = 'none';
		document.getElementById('id_res_rech').style.display = 'none';		
	}
	else
		 popup_alert("Votre recherche ne correspond à aucun mariage");	

}

//----------------------------------------------------------------------------------------------------------
// inscription ventes privées
//----------------------------------------------------------------------------------------------------------

function inscription_VIP_ajax (email_parrain){
	
	if (email_parrain == "" )
		popup_alert("Veuillez saisir l'email de votre parrain");	
	else
	{
		var	getparams = "email_parrain="+email_parrain;				
		var url = 'ajax/inscription_VIP.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: getparams+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_inscription_VIP_ajax});
	}
}

function ajax_response_inscription_VIP_ajax(transport)
{		
	var tmp_tab = new Array();
	ajaxRespVar = true;
	tmp_tab = transport.responseText.split("|");
	if(transport.responseText.indexOf('ok') > -1){
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){								
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];				
			}				
		}
	}		
	
	if (ajaxParamsTab["reponse"] != "no")						
		 popup_alert("Votre inscription a bien été enregistrée, pour accéder aux ventes privées, veuillez cliquer sur le bouton \"Accéder à mon espace privé\"");	
	else
		 popup_alert("L'email de ce parrain n'existe pas");	
}

//-------------------------------------------------------------------------------------------------------
//Redirection vers l'espace ventes privées
//-------------------------------------------------------------------------------------------------------
function redirect_espace_VIP_ajax()
{
	var url = 'ajax/verif_membre_VIP.php';
	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "trompeCache="+new Date().getTime(), onComplete: ajax_response_redirect_espace_VIP_ajax});
}

function ajax_response_redirect_espace_VIP_ajax(transport)
{		
	var tmp_tab = new Array();
	ajaxRespVar = true;
	tmp_tab = transport.responseText.split("|");
	if(transport.responseText.indexOf('ok') > -1){
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){								
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];				
			}
		}
	}
	
	if (ajaxParamsTab["reponse"] != "no")	
		window.location.href = document.getElementById("id_lien_ventes_vip").href;	
	else
	 	popup_alert("Cet espace est seulement réservé aux membres VIP d'océanes");
}
//-------------------------------------------------------------------------------------------------------
// Redirection vers la fiche voyage ventes privées
//------------------------------------------------------------------------------------------------------
var vip_id_voyage ;
function fiche_voyage_ventes_privees_ajax(id_voyage)
{	
	vip_id_voyage = id_voyage;
	var url = 'ajax/fiche_voyage_ventes_privees.php';
	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "trompeCache="+new Date().getTime(), onComplete: ajax_response_fiche_voyage_ventes_privees_ajax});
}

function ajax_response_fiche_voyage_ventes_privees_ajax(transport)
{		
	var tmp_tab = new Array();
	ajaxRespVar = true;
	tmp_tab = transport.responseText.split("|");
	if(transport.responseText.indexOf('ok') > -1){
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){								
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];				
			}
		}
	}
	id_fiche = "id_lien_fiche_voyage_ventes_privees_" + vip_id_voyage	
	if (ajaxParamsTab["reponse"] == "yes")	
		window.location.href = document.getElementById(id_fiche).href;			
}

//------------------------------------------------------------------------------------------------------
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;   
}
   
function verif_form_participation_mariage(lib_js_invalid_fields){
	
	var alertcolor="#1397e9";		
	var nom = document.getElementById('id_nom').value ;	
	var prenom = document.getElementById('id_prenom').value ;	
	var adresse = document.getElementById('id_adresse').value ;	
	var cp = document.getElementById('id_cp').value ;	
	var ville = document.getElementById('id_ville').value ;	
	var msg = document.getElementById('id_msg').value ;	
	var montant = document.getElementById('id_montant').value ;	
	var email = document.getElementById('id_email').value ;	

	document.getElementById('id_nom').style.border = "0px solid";
	document.getElementById('id_prenom').style.border = "0px solid";
	document.getElementById('id_adresse').style.border = "0px solid";
	document.getElementById('id_cp').style.border = "0px solid";
	document.getElementById('id_ville').style.border = "0px solid";
	document.getElementById('id_msg').style.border = "0px solid";
	document.getElementById('id_montant').style.border = "0px solid";	
	document.getElementById('id_email').style.border = "0px solid";		
		
	var verif 	= /^[a-zA-Z.0-9_-]+@[a-zA-Z.0-9_-]{2,}[.][a-zA-Z]{2,3}$/;   			
	
	if (nom == "")  {		
		document.getElementById('id_nom').style.border="2px solid "+ alertcolor;	
	}	
	if (prenom == "")  {		
		document.getElementById('id_prenom').style.border="2px solid "+ alertcolor;		
	}	
	if (adresse == "")  {		
		document.getElementById('id_adresse').style.border="2px solid "+ alertcolor;		
	}	
	if (cp == "")  {		
		document.getElementById('id_cp').style.border="2px solid "+ alertcolor;		
	}
	if (ville == "")  {		
		document.getElementById('id_ville').style.border="2px solid "+ alertcolor;		
	}
	if (msg == "")  {		
		document.getElementById('id_msg').style.border="2px solid "+ alertcolor;		
	}
	if (montant == "")  {		
		document.getElementById('id_montant').style.border="2px solid "+ alertcolor;		
	}
	if (email == "" || (verif.exec(email)==null ))  {		
		document.getElementById('id_email').style.border="2px solid "+ alertcolor;		
	}
		
	if (nom == "" || prenom == "" || adresse == "" || cp == "" || ville == "" || msg == "" || montant == "" || email == "")  {			
		popup_alert(lib_js_invalid_fields);					
		return false;	
	}
	else {		
		bool_test = false;
		if (verif.exec(email)==null)	{			
			txt_err = "email invalide\n"; 
			bool_test = true; 
		}		
				
		if (!(IsNumeric(montant)))	{
			txt_err += "Montant incorrect\n"; 
			bool_test = true; 
		}	
					
		if (bool_test) {			
			popup_alert(txt_err);				
			return false;
		} 
		else {					
			return true;
		}
	}	
}

function js_paiement_ch (lib_js_invalid_fields,url){
	
	if (verif_form_participation_mariage(lib_js_invalid_fields)){					
			
			document.forms['form_mode_paiement'].choix[0].checked = true;
			document.forms['form_mode_paiement'].choix[1].checked = false;
			document.forms['form_mode_paiement'].choix[2].checked = false;									
			edition_mail_mariage_ajax();			
			document.location.href=url;
			return false;
	}
	else {			
		
			return false;			
	}			
		
}

function js_paiement_vir (lib_js_invalid_fields,url){
	
	if (verif_form_participation_mariage(lib_js_invalid_fields)){					
			document.forms['form_mode_paiement'].choix[0].checked = false;
			document.forms['form_mode_paiement'].choix[1].checked = true;
			document.forms['form_mode_paiement'].choix[2].checked = false;			
			edition_mail_mariage_ajax();			
			document.location.href=url;
	}
	else {			
			return false;
	}			
}	
	
function edition_mail_mariage_ajax(){
	
	var nom = document.getElementById('id_nom').value ;	
	var prenom = document.getElementById('id_prenom').value ;	
	var adresse = document.getElementById('id_adresse').value ;	
	var cp = document.getElementById('id_cp').value ;	
	var ville = document.getElementById('id_ville').value ;	
	var msg = document.getElementById('id_msg').value ;		
	var montant = parseFloat(document.getElementById('id_montant').value);
	var email_dest = document.getElementById('id_email').value;
	var id_liste_mariage = document.getElementById('id_liste_mariage').value;	
	
	if (document.forms['form_mode_paiement'].choix[0].checked) 	mode_paiement = document.forms['form_mode_paiement'].choix[0].value;
	if (document.forms['form_mode_paiement'].choix[1].checked) 	mode_paiement = document.forms['form_mode_paiement'].choix[1].value;
	if (document.forms['form_mode_paiement'].choix[2].checked) 	mode_paiement = document.forms['form_mode_paiement'].choix[2].value;
	
	var	getparams = "montant="+montant;
		getparams += "&mode_paiement="+mode_paiement;		
		getparams += "&email_dest="+email_dest;
		getparams += "&nom="+nom;
		getparams += "&prenom="+prenom;
		getparams += "&adresse="+adresse;
		getparams += "&cp="+cp;
		getparams += "&ville="+ville;
		getparams += "&msg="+msg;
		getparams += "&id_liste_mariage="+id_liste_mariage;		
	
	var url = 'ajax/edition_email_participant_mariage.php';
	new Ajax.Request(
	url, {asynchronous:false,method: 'get',  parameters: getparams+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_edition_mail_mariage_ajax});
	
}

function ajax_response_edition_mail_mariage_ajax(transport)
{		
	var tmp_tab = new Array();
	ajaxRespVar = true;
	tmp_tab = transport.responseText.split("|");
	if(transport.responseText.indexOf('ok') > -1){
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){								
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];				
			}
		}
	}		
	
//	if (ajaxParamsTab["reponse"] != "yes")//		 popup_alert("email enregistré");	
}


function envoyer_mail_contact_ajax(lib_js_invalid_fields){
	
	var alertcolor="#1397e9";		
	var email_demandeur = document.getElementById('id_email_demandeur').value ;	
	var SelectedIndex = document.getElementById('id_type_question').selectedIndex ; 
	var type_question = document.getElementById('id_type_question').options[SelectedIndex].value ;	
	var sujet = document.getElementById('id_sujet').value ;	
	var msg = document.getElementById('id_msg').value ;	
	
	document.getElementById('id_email_demandeur').style.border = "0px solid";
	document.getElementById('id_type_question').style.border = "0px solid";
	document.getElementById('id_sujet').style.border = "0px solid";
	document.getElementById('id_msg').style.border = "0px solid";	

	bool_test = false;
	
	var verif 	= /^[a-zA-Z.0-9_-]+@[a-zA-Z.0-9_-]{2,}[.][a-zA-Z]{2,3}$/;   			
	if (type_question == "")  {		
		document.getElementById('id_type_question').style.border="2px solid "+ alertcolor;	
	}
	if (sujet == "")  {		
		document.getElementById('id_sujet').style.border="2px solid "+ alertcolor;		
	}
	if (msg == "")  {		
		document.getElementById('id_msg').style.border="2px solid "+ alertcolor;		
	}
	
	if (email_demandeur == "" || (verif.exec(email_demandeur)==null ))  {		
		document.getElementById('id_email_demandeur').style.border="2px solid "+ alertcolor;		
	}
		
	if (type_question == "" || sujet == "" || msg == "" || email_demandeur == "" )  {			
		popup_alert(lib_js_invalid_fields);					
		bool_test = true; 
	}
	else {		
		
		if (verif.exec(email_demandeur)==null)	{			
			txt_err = "email demandeur invalide\n"; 
			bool_test = true; 
		}	
					
		if (bool_test) {			
			popup_alert(txt_err);							
		} 
		else {											
			var	getparams = "email_demandeur="+email_demandeur ;
		     	getparams += "&email_dest="+type_question;
		     	getparams += "&sujet="+sujet;
		     	getparams += "&msg="+msg;
				
			var url = 'ajax/send_email_contact.php';
			new Ajax.Request(
					url, {asynchronous:false,method: 'get',  parameters: getparams+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_send_mail_contact_ajax});
		}
	}		
}

function ajax_response_send_mail_contact_ajax(transport){
	var tmp_tab = new Array();
	ajaxRespVar = true;
	tmp_tab = transport.responseText.split("|");
	if(transport.responseText.indexOf('ok') > -1){
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){								
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];				
			}				
		}
	}		
	
	if (ajaxParamsTab["reponse"] == "yes")		 popup_alert("Votre e-mail a été envoyé à Océanes.");	
	else popup_alert("Problème technique : votre e-mail n'a pas été envoyé à Océanes.");
}

function envoyer_mail_ami_ajax(lib_js_invalid_fields,url){
	
	var alertcolor="#1397e9";		
	var nom = document.getElementById('id_nom').value ;	
	var prenom = document.getElementById('id_prenom').value ;		
	var msg = document.getElementById('id_msg').value ;	
	var email1 = document.getElementById('id_email1').value ;	
	var email2 = document.getElementById('id_email2').value ;	
	var email3 = document.getElementById('id_email3').value ;	
	var code = document.getElementById('id_code').value ;	
	
	document.getElementById('id_nom').style.border = "0px solid";
	document.getElementById('id_prenom').style.border = "0px solid";
	document.getElementById('id_email1').style.border = "0px solid";
	document.getElementById('id_code').style.border = "0px solid";

	bool_test = false;
	
	var verif 	= /^[a-zA-Z.0-9_-]+@[a-zA-Z.0-9_-]{2,}[.][a-zA-Z]{2,3}$/;   			
	
	if (nom == "")  {		
		document.getElementById('id_nom').style.border="2px solid "+ alertcolor;	
	}	
	if (prenom == "")  {		
		document.getElementById('id_prenom').style.border="2px solid "+ alertcolor;	
	}	
	
	/**if (msg == "")  {		
		document.getElementById('id_msg').style.border="2px solid "+ alertcolor;		
	}	*/
	if (email1 == "" || (verif.exec(email1)==null ))  {		
		document.getElementById('id_email1').style.border="2px solid "+ alertcolor;		
	}
	if (code == "")  {		
		document.getElementById('id_code').style.border="2px solid "+ alertcolor;	
	}
		
	if ( nom == "" || prenom == ""  || email1 == ""  || code =="" )  {
		popup_alert(lib_js_invalid_fields);					
		bool_test = true; 
	}
	else {		
		
		if (verif.exec(email1)==null)	{			
			txt_err = "email d'un ami invalide\n"; 
			bool_test = true; 
		}			
		
		if (bool_test) {			
			popup_alert(txt_err);							
		} 
		else {											
			var	getparams = "nom="+nom ;
				getparams += "&prenom="+prenom ;
		     	getparams += "&email1="+email1;
		     	getparams += "&email2="+email2;
		     	getparams += "&email3="+email3;		     	
		     	getparams += "&msg="+msg;
		     	getparams += "&url="+url;
		     	getparams += "&code="+code;
		    
			var url = 'ajax/send_email_ami.php';
			new Ajax.Request(
					url, {asynchronous:false,method: 'get',  parameters: getparams+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_send_mail_ami_ajax});
		}
	}		
}

function ajax_response_send_mail_ami_ajax(transport){
	var tmp_tab = new Array();
	ajaxRespVar = true;
	tmp_tab = transport.responseText.split("|");
	if(transport.responseText.indexOf('ok') > -1){
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){								
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];				
			}				
		}
	}		
	
	if (ajaxParamsTab["reponse"] == "yes")	popup_alert("Envoi effectué.");	
	else { popup_alert("code incorrect."); }
	
}


function valider_participation_mariage_ajax(lib_js_invalid_fields){
	
	var alertcolor="#1397e9";		
	var nom = document.getElementById('id_nom').value ;	
	var prenom = document.getElementById('id_prenom').value ;		
	var adresse = document.getElementById('id_adresse').value ;		
	var cp = document.getElementById('id_cp').value ;		
	var ville = document.getElementById('id_ville').value ;			
	var msg = document.getElementById('id_msg').value ;	
	var montant = document.getElementById('id_montant').value ;	
	var email = document.getElementById('id_email').value ;		
	
	
	document.getElementById('id_nom').style.border = "0px solid";
	document.getElementById('id_prenom').style.border = "0px solid";
	document.getElementById('id_adresse').style.border = "0px solid";
	document.getElementById('id_cp').style.border = "0px solid";	
	document.getElementById('id_ville').style.border = "0px solid";
	document.getElementById('id_msg').style.border = "0px solid";
	document.getElementById('id_montant').style.border = "0px solid";
	document.getElementById('id_email').style.border = "0px solid";
	
	bool_test = false;
	
	var verif 	= /^[a-zA-Z.0-9_-]+@[a-zA-Z.0-9_-]{2,}[.][a-zA-Z]{2,3}$/;   			
	
	if (nom == "")  {		
		document.getElementById('id_nom').style.border="2px solid "+ alertcolor;	
	}	
	if (prenom == "")  {		
		document.getElementById('id_prenom').style.border="2px solid "+ alertcolor;	
	}		
	if (adresse == "")  {		
		document.getElementById('id_adresse').style.border="2px solid "+ alertcolor;	
	}	
	if (cp == "")  {		
		document.getElementById('id_cp').style.border="2px solid "+ alertcolor;	
	}
	if (ville == "")  {		
		document.getElementById('id_ville').style.border="2px solid "+ alertcolor;	
	}	
	if (msg == "")  {		
		document.getElementById('id_msg').style.border="2px solid "+ alertcolor;		
	}	
	if (montant == "" || montant == 0 )  {		
		document.getElementById('id_montant').style.border="2px solid "+ alertcolor;		
	}
	if (email == "" || (verif.exec(email)==null ))  {		
		document.getElementById('id_email').style.border="2px solid "+ alertcolor;		
	}
		
	if ( nom == "" || prenom == ""  || email == ""  || adresse =="" ||   cp  =="" || ville =="" || msg =="" || montant =="" || montant == 0  )  {
		popup_alert(lib_js_invalid_fields);					
		bool_test = true; 
	}
	else {		
		
		if (verif.exec(email)==null)	{			
			txt_err = "email invalide\n"; 
			bool_test = true; 
		}			
		
		if (bool_test) {			
			popup_alert(txt_err);							
		} 
		else {											
			var	getparams = "nom="+nom ;
				getparams += "&prenom="+prenom ;
				getparams += "&adresse="+adresse ;
				getparams += "&cp="+cp ;
				getparams += "&ville="+ville ;
				getparams += "&msg="+msg ;				
		     	getparams += "&montant="+montant;
		     	getparams += "&email="+email;	     	
		    
			var url = 'ajax/liste_participants_mariage_CB.php';
			new Ajax.Request(
					url, {asynchronous:false,method: 'get',  parameters: getparams+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_valider_participation_mariage_ajax});
		}
	}		
}

function ajax_response_valider_participation_mariage_ajax(transport){
	var tmp_tab = new Array();
	ajaxRespVar = true;
	tmp_tab = transport.responseText.split("|");
	if(transport.responseText.indexOf('ok') > -1){
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){								
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];				
			}				
		}
	}			
	
	document.getElementById('id_paiement_liste_mariage_choix').style.display = 'block';	
	document.getElementById('id_valider_form').style.display = 'none';			
	document.getElementById('id_atos_bloc').innerHTML = ajaxParamsTab["atos_bloc"];
	
}




var Base64 = {

    // private property
    _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

    // public method for encoding
    encode : function (input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;

        input = Base64._utf8_encode(input);

        while (i < input.length) {

            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);

            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;

            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }

            output = output +
            this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
            this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

        }

        return output;
    },

    // public method for decoding
    decode : function (input) {
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;

        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

        while (i < input.length) {

            enc1 = this._keyStr.indexOf(input.charAt(i++));
            enc2 = this._keyStr.indexOf(input.charAt(i++));
            enc3 = this._keyStr.indexOf(input.charAt(i++));
            enc4 = this._keyStr.indexOf(input.charAt(i++));

            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;

            output = output + String.fromCharCode(chr1);

            if (enc3 != 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 != 64) {
                output = output + String.fromCharCode(chr3);
            }

        }

        output = Base64._utf8_decode(output);

        return output;

    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}

function JSReplace(inStr, Pattern, Par){
	while(inStr.indexOf(Pattern) >= 0){
	inStr = inStr.replace(Pattern, Par);
	};
	
	return inStr;
};

