/*----------moteur vol-----------*/
function changeActionVOL()
{
var VilleDepart1 = document.RechercheVol.VilleDepart.value;
var VilleArrivee1= document.RechercheVol.VilleArrivee.value;
var VilleDepart1=VilleDepart1.toLowerCase();
var VilleArrivee1=VilleArrivee1.toLowerCase();
var action='vols/'+VilleDepart1+'-'+VilleArrivee1;
document.RechercheVol.action = action;
document.RechercheVol.submit();
}
/*----------moteur vol-----------*/

function changeActionVoyages(frmName,thm_moteur)
{ /***IdLocalite,IdTheme****/
var frm =document[frmName];
var VilleDepart1 = frm.VilleDepart.value;
var IdLocalite12 = trim(frm.IdLocalite.value);
var IdTheme12 = frm.Theme.value;
var IdLocalite1=frm.IdLocalite.options[frm.IdLocalite.selectedIndex].text;
var IdTheme1=frm.Theme.options[frm.Theme.selectedIndex].text;
var IdTheme1 = trim(IdTheme1);
var Duree12 = frm.flex.value;
var Duree1=frm.flex.options[frm.flex.selectedIndex].text;
var Duree1 = trim(Duree1); 
if  (Duree1 == '+ou- 3 jours' ) Duree1='plus.ou.moins.3.jours';
if  (Duree1 == '+ou- 1 semaine' ) Duree1='1.semaine';
if  (Duree1 == '+ou- 2 semaines' ) Duree1='2.semaines.et.plus';
if (VilleDepart1 == ' ')
var villeDep ='';
else
var villeDep ='/'+VilleDepart1;
if (Duree12 == 0)
var Dure ='';
else
var Dure ='/'+Duree1;
if (IdLocalite12 == 0)
var local ='';
else
var IdLocalite1 = IdLocalite1.toString().replace(/^\s*/, '');
var local ='/'+trim(IdLocalite1);
if (IdTheme12 == 0)
var thm ='';
else
var thm ='/'+IdTheme1;
frm.isapi_localite.value= local;
frm.isapi_villedep.value= villeDep;
frm.isapi_theme.value= thm;
frm.isapi_duree.value= Dure;
var local2=ReplaceAll(local,'-','','All');
var local2 = trim(local2.toString().replace(/^\s*/, ''));
var local2=local2.toLowerCase();

var thm=thm.toLowerCase();
var thm=trim(thm.toString().replace(/^\s*/, ''));
var villeDep=villeDep.toLowerCase();
var Dure=Dure.toLowerCase();
if (thm_moteur =='')
{
var action='voyages'+theme_moteur+''+thm+''+trim(local2)+''+villeDep+'';
}
else
{
var theme_moteur='/'+thm_moteur;
var action='voyages'+theme_moteur+''+thm+''+trim(local2)+''+villeDep+'';
}
frm.action = action;
frm.submit();
}
/*------------------replace all--------------------*/
 function ReplaceAll(s,sb1,sb2,sc)
 {
		if(!sc || sc.toUpperCase() != "ALL")
		{
			sc = "i";
		}
		
		 else 
			{
			sc ="gi";
			} 	
		var re = new RegExp(sb1,sc);
		return s.replace(re,sb2);
	}


function trim(sString) {
    while (sString.substring(0,1) == ' ' || sString.substring(0,1) == '\t' || sString.substring(0,1) == '\r' || sString.substring(0,1) == '\n')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ' || sString.substring(sString.length-1, sString.length) == '\t' || sString.substring(sString.length-1, sString.length) == '\r' || sString.substring(sString.length-1, sString.length) == '\n')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}
