document.writeln("<script language='javascript'>");
document.writeln("var array_lieu_autre=[];");
document.writeln("var objLieu;");
document.writeln("function lieu(id,typelieu, nom,littoral, golf, thalasso,montagne)");
document.writeln("{");
document.writeln("	this.id = id;");
document.writeln("	this.nom = nom;");
document.writeln("	this.littoral = littoral;");
document.writeln("	this.golf = golf;");
document.writeln("	this.thalasso = thalasso;");
document.writeln("	this.montagne = montagne;");
document.writeln("	this.typelieu=typelieu;");
document.writeln("	this.peres=[];");
document.writeln("}");
document.writeln("function getTypeLieu(lngLieuId)");
document.writeln("{");
document.writeln("	var i,j,k;");
document.writeln("	var objPays,objRegion,objZT;");
document.writeln("	var array_lieu = getArrayLieu();");
document.writeln("	if(lngLieuId==0 || lngLieuId=='')");
document.writeln("		return 0;");
document.writeln("	else");
document.writeln("	{");
document.writeln("		for (i=0; i<array_lieu.length; i++)");
document.writeln("		{");
document.writeln("			objPays = array_lieu[i];");
document.writeln("			if(objPays.id==lngLieuId)");
document.writeln("				return objPays.typelieu;");
document.writeln("		}");
document.writeln("	}");
document.writeln("	return 0;");
document.writeln("}");
document.writeln("function getArrayLieu()");
document.writeln("{");
document.writeln("	return array_lieu_autre;");
document.writeln("}");
document.writeln("function addLieu(strType,id,typelieu, nom,littoral, golf, thalasso,montagne)");
document.writeln("{");
document.writeln("	var i,j;");
document.writeln("	var objPays,objRegion;");
document.writeln("	var array_lieu = getArrayLieu();");
document.writeln("	var objLieu;");
document.writeln("	objLieu = new lieu(id,typelieu, nom,littoral, golf, thalasso,montagne);");
document.writeln("	array_lieu[array_lieu.length] = objLieu;");
document.writeln("	return objLieu;");
document.writeln("}");
document.writeln("function on_change_pays()");
document.writeln("{");
document.writeln("	var i,nbStation=0;");
document.writeln("	var pays_id;");
document.writeln("	var array_lieu = getArrayLieu();");
document.writeln("	var select_pays = document.getElementById('pays');");
document.writeln("	var select_lieu = document.getElementById('lieu');");
document.writeln("	var objLieu;");
document.writeln("	clear_select(select_lieu);");
document.writeln("	pays_id = select_pays.value;");
document.writeln("	// genere les station de l'activite");
document.writeln("	for (i=0; i<array_lieu.length; i++)");
document.writeln("	{");
document.writeln("		objLieu = array_lieu[i];");
document.writeln("		if(isFils(objLieu,pays_id))");
document.writeln("		{");
document.writeln("			select_lieu[nbStation] = new Option(objLieu.nom,objLieu.id);");
document.writeln("			nbStation++;");
document.writeln("		}");
document.writeln("	}");
document.writeln("}");
document.writeln("function fillPays()");
document.writeln("{");
document.writeln("	var i;");
document.writeln("	var array_lieu = getArrayLieu();");
document.writeln("	var select_pays = document.getElementById('pays');");
document.writeln("	var objLieu;");
document.writeln("	clear_select(select_pays);");
document.writeln("	// genere les station de l'activite");
document.writeln("	for(i=0; i<array_lieu.length; i++)");
document.writeln("	{");
document.writeln("		objLieu = array_lieu[i];");
document.writeln("		if(objLieu.typelieu==2)");
document.writeln("			select_pays[select_pays.length] = new Option(objLieu.nom,objLieu.id);");
document.writeln("	}");
document.writeln("	select_pays.selectedIndex=0;");
document.writeln("	on_change_pays();");
document.writeln("}");
document.writeln("function isFils(objLieu,lngPereId)");
document.writeln("{");
document.writeln("	var i;");
document.writeln("	for(i=0;i<objLieu.peres.length;i++)");
document.writeln("	{");
document.writeln("		if(objLieu.peres[i]==lngPereId)");
document.writeln("			return true;");
document.writeln("	}");
document.writeln("	return false;");
document.writeln("}");
document.writeln("// vide select completement");
document.writeln("function clear_select(select)");
document.writeln("{	");
document.writeln("	if(select!=null)");
document.writeln("		while (select.length > 0) select.options[0] = null;");
document.writeln("}");
document.writeln("function valide_form(strform,strLang)");
document.writeln("{");
document.writeln("	var form= document.getElementById(strform);");
document.writeln("	var date= form.date_debut;");
document.writeln("	var err='';");
document.writeln("	if (form.lieu) {");
document.writeln("	 if (form.lieu.value=='') {");
document.writeln("		switch(strLang)");
document.writeln("		{");
document.writeln("			case 'fr':");
document.writeln("				err='Veuillez indiquer votre destination de manière plus précise.';");
document.writeln("				break;");
document.writeln("			default:");
document.writeln("				err='Error';");
document.writeln("		}");
document.writeln("	 }");
document.writeln("	}");
document.writeln("	if(date.value=='')");
document.writeln("	{");
document.writeln("		switch(strLang)");
document.writeln("		{");
document.writeln("			case 'fr':");
document.writeln("				err='Veuillez saisir une date.';");
document.writeln("				break;");
document.writeln("			default:");
document.writeln("				err='Error';");
document.writeln("		}");
document.writeln("	}");
document.writeln("	else");
document.writeln("	{");
document.writeln("		if(!IsDate(date.value, 'yyyy-mm-dd'))");
document.writeln("		{");
document.writeln("			switch(strLang)");
document.writeln("			{");
document.writeln("				case 'fr':");
document.writeln("					err='Veuillez saisir une date valide.';");
document.writeln("					break;");
document.writeln("				default:");
document.writeln("					err='Error';");
document.writeln("			}");
document.writeln("		}");
document.writeln("		else");
document.writeln("		{");
document.writeln("			if(DateDiff('d', new Date(),str2Date(date.value, 'yyyy-mm-dd'))<4)");
document.writeln("			{");
document.writeln("				switch(strLang)");
document.writeln("				{");
document.writeln("					case 'fr':");
document.writeln("						err=\"La date que vous avez choisi est trop proche d'aujourd'hui.\";");
document.writeln("						break;");
document.writeln("					default:");
document.writeln("						err='Error';");
document.writeln("				}");
document.writeln("			}");
document.writeln("		}");
document.writeln("	}");
document.writeln("	if(err!='')");
document.writeln("		alert(err)");
document.writeln("	else");
document.writeln("		form.submit();");
document.writeln("}");
document.writeln("//IsDate");
document.writeln("//Verifie qu'une date existe");
document.writeln("function IsDate (strVal, strFormat)");
document.writeln("{	  ");
document.writeln("	var dd, mm, yyyy;  ");
document.writeln("	switch (strFormat)");
document.writeln("	{");
document.writeln("		// fr  ");
document.writeln("		case 'dd/mm/yyyy' :");
document.writeln("			dd = strVal.substr(0, 2);");
document.writeln("			mm = strVal.substr(3, 2);");
document.writeln("			yyyy = strVal.substr(6, 4);");
document.writeln("			return DateExiste(dd,mm,yyyy);   ");
document.writeln("		// us   ");
document.writeln("		case 'yyyy-mm-dd' :	 ");
document.writeln("			yyyy = strVal.substr(0, 4);	");
document.writeln("			mm = strVal.substr(5, 2);");
document.writeln("			dd = strVal.substr(8, 2);");
document.writeln("			return DateExiste(dd,mm,yyyy);   ");
document.writeln("	} ");
document.writeln("}	");
document.writeln("//DateExiste");
document.writeln("//Verifie qu'une date existe");
document.writeln("function DateExiste (day,month,year) ");
document.writeln("{	");
document.writeln("    var today = new Date();  ");
document.writeln("    if(!year)	return false;");
document.writeln("					  ");
document.writeln("	if(!month) return false;");
document.writeln("	");
document.writeln("    if (!day) return false;");
document.writeln("    var test = new Date(year,month-1,day);");
document.writeln("    if ( (test.getFullYear() == year) &&   ");
document.writeln("         (month == test.getMonth()+1) &&");
document.writeln("         (day == test.getDate()) ) ");
document.writeln("        return true;   ");
document.writeln("    else	 ");
document.writeln("        return false;	");
document.writeln("}	");
document.writeln("// chaine --> date ");
document.writeln("function str2Date(strVal, strFormat)");
document.writeln("{	");
document.writeln("	var dd, mm, yyyy;");
document.writeln("	switch (strFormat)");
document.writeln("	{			");
document.writeln("		// fr  ");
document.writeln("		case 'dd/mm/yyyy' :");
document.writeln("			dd = strVal.substr(0, 2);");
document.writeln("			mm = strVal.substr(3, 2);");
document.writeln("			yyyy = strVal.substr(6, 4);	");
document.writeln("			return new Date(yyyy, mm - 1, dd);");
document.writeln("		// us   ");
document.writeln("		case 'yyyy-mm-dd' :");
document.writeln("			yyyy = strVal.substr(0, 4);");
document.writeln("			mm = strVal.substr(5, 2);");
document.writeln("			dd = strVal.substr(8, 2);");
document.writeln("			return new Date(yyyy, mm - 1, dd);");
document.writeln("	}  ");
document.writeln("} ");
document.writeln("// DateDiff");
document.writeln("function DateDiff(strType,datVal1, datVal2)  ");
document.writeln("{	 ");
document.writeln("	var seconde = 1000;	");
document.writeln("	var minute	= 60;");
document.writeln("	var heure	= 60;");
document.writeln("	var jour	= 24;");
document.writeln("	var intDuree=0;	");
document.writeln("	switch(strType)");
document.writeln("	{  ");
document.writeln("		case 'd':");
document.writeln("			intDuree = ((datVal2 - datVal1)/ (seconde*minute*heure*jour));");
document.writeln("			break;");
document.writeln("		case 'h':");
document.writeln("			intDuree = ((datVal2 - datVal1)/ (seconde*minute*heure*jour));   ");
document.writeln("			break;   ");
document.writeln("		case 'm':  ");
document.writeln("			intDuree = ((datVal2 - datVal1)/ (seconde*minute));	");
document.writeln("			break;");
document.writeln("		case 's':  ");
document.writeln("			intDuree = ((datVal2 - datVal1)/ (seconde)); ");
document.writeln("			break;   ");
document.writeln("	}  ");
document.writeln("	intDuree = Math.round(intDuree); ");
document.writeln("	return intDuree;  ");
document.writeln("}	   ");
document.writeln("objLieu = addLieu(3,2,2,'FRANCE',0,0,0,0);objLieu = addLieu(3,3472,1,'REGION SUD OUEST',0,0,0,0);objLieu.peres[objLieu.peres.length]=2;");
document.writeln("fillPays();");
document.writeln("</script>");

