/***** NE JAMAIS MODIFIER CETTE PAGE SANS L'AVIS DES RESPONSABLES AFFILIATION ET TECHNIQUE *****/
/**********************************/
/* FONCTIONS DE GESTION DES DATES */
/**********************************/
// abbrévations : A (aller) / R (retour) / V (vols) / H (hôtels) / C (voitures) / S (séjours) / D (day) / M (month) / Y (year)
function fmtNb(n){ return n<10?'0'+n:''+n; } // formate un nombre à deux chiffres
function getInterval(jds){ //intervale à prévoir entre aujourd'hui et la date de départ (selon jour de la semaine)
 switch(jds){
  case 1:return 4; // LUNDI
  case 2:return 3; // MARDI
  case 3:return 9; // MERCREDI
  case 4:return 8; // JEUDI
  case 5:return 7; // VENDREDI
  case 6:return 6; // SAMEDI
	}
	return 5; // DIMANCHE
}
function createDOptions(sD){ // crée le sélecteur des jours
	var i=1,resHTML='';
	do{resHTML+='<option value="'+fmtNb(i)+'"'+(i==sD?' selected="selected"':'')+'>'+fmtNb(i)+'</option>';
	}while(++i<=31);
	return resHTML;
}
function createMYOptions(sM,sY){ // crée le sélecteur des mois / années
 var i=0,resHTML='',tmpM,tmpY,tmpPfx,dateTmp=new Date(dateA.getTime());dateTmp.setDate(1);
	do{tmpM=dateTmp.getMonth();tmpY=dateTmp.getFullYear();tmpPfx=tmpM<9?'0':'';dateTmp.setMonth(tmpM+1);
  resHTML+='<option value="'+tmpPfx+(tmpM+1)+'/'+tmpY+'"'+((tmpM==sM&&tmpY==sY)?' selected="selected"':'')+'>'+tmpPfx+(tmpM+1)+'/'+tmpY+'</option>';
 }while(++i<12);
	return resHTML;
}
// implémentation des sélecteurs en fonction de la date
var interval=getInterval(new Date().getDay());
var dateA=new Date(); dateA.setDate(dateA.getDate()+interval);
var selectDA=createDOptions(dateA.getDate());
var selectMYA=createMYOptions(dateA.getMonth(),dateA.getFullYear());
var dateR_V=new Date(); dateR_V.setDate(dateR_V.getDate()+interval+7);
var selectDR_V=createDOptions(dateR_V.getDate());
var selectMYR_V=createMYOptions(dateR_V.getMonth(),dateR_V.getFullYear());
/*********************************************/
/* FONCTIONS DE VERIFICATION DES FORMULAIRES */
/*********************************************/
function trim(v){ return v.replace(/(^\s+|\s+$)/g,''); } // retire les espaces avant et après les données
function accent(v){ // corrige les caractères spéciaux
 v=v.replace(/á|â|à|ä|ã/g,'a');
 v=v.replace(/é|ê|è|ë/g,'e');
 v=v.replace(/í|î|ì|ï/g,'i');
 v=v.replace(/ó|ô|ò|ö|õ/g,'o');
 v=v.replace(/ú|û|ù|ü/g,'u');
 v=v.replace(/ç/g,'c');
 v=v.replace(/ñ/g,'n');
 v=v.toLowerCase();
 v=v.replace(/st(e)?( |-)/g,'saint$1 ');
 return v.replace(/-|_|'| +/g,' ');
}
function verifyMEV(){
	var f=document.getElementById('formMEV');
	if(f.departAller.tagName.toLowerCase()=="input"){ try{ f.departAller.value=accent(f.departAller.value.replace(/^\s+/g,'').replace(/\s+$/g,'')); }catch(e){} }
	if(f.arriveeAller.tagName.toLowerCase()=="input"){ try{ f.arriveeAller.value=accent(f.arriveeAller.value.replace(/^\s+/g,'').replace(/\s+$/g,'')); }catch(e){} }
}
/************************************/
/* FONCTIONS DE GESTION DES CALQUES */
/************************************/
function selectTypeAS(){ document.getElementById('returnDate').style.visibility='hidden'; } // on cache le div de la date du vol retour
function selectTypeAR(){ document.getElementById('returnDate').style.visibility='visible'; } // on affiche le div de la date du vol retour
/**************/
/* STYLES CSS */
/**************/
document.write('<style type=\"text/css\">');
document.write('  #formMEV               { position:relative; width:430px; height:150px; margin:0; padding:0; border:0; font-size:10px;}');
document.write('    #formMEV input       { font-size:9px; text-transform:uppercase; }');
document.write('    #formMEV label       { cursor:pointer; }');
document.write('    #formMEV select      { font-size:9px; font-weight:normal; text-transform:none; }');
document.write('      .formMEVleft       { float:left; text-align:left; }');
document.write('      .formMEVright      { float:right; text-align:left; }');
document.write('      .marginTop         { margin-top:10px; font-weight:bold; text-transform:uppercase; }');
document.write('      .typeDeVol         { width:430px; text-align:right; }');
document.write('      .inputShort        { width:20px; }');
document.write('      .inputLong         { width:144px; }');
document.write('      .selectSmall       { width:45px; }');
document.write('      .selectMedium      { width:75px; }');
document.write('      .selectLong        { width:149px; }');
document.write('      .calendrier        { cursor:pointer; }');
document.write('      .formMEVnormal     { font-weight:normal; text-transform:none; }');
document.write('      .formMEVvalidation { position:absolute; left:0; bottom:0; width:430px; text-align:center; }');
document.write('      .calendrier    { width:25px; height:18px; background-image:url(http://www.easyvols.org/base/img/mev/results_calendrier.gif); background-repeat:no-repeat; }');
document.write('      .formMEVsubmit { width:141px; height:30px; background-image:url(http://www.americas-fr.com/images/rechercher.gif); background-repeat:no-repeat; }');
document.write('</style>');
/***************/
/* FORMULAIRES */
/***************/
document.write('<form id=\"formMEV\" action=\"http://www.easyvols.org/partners/mev/results.jsp\" onsubmit=\"javascript:verifyMEV();\" target=\"_blank\">');
document.write('<input type=\"hidden\" name=\"clientId\" id=\"eaClientId\" value=\"1\" />');
document.write('<div class=\"marginTop typeDeVol\">type de vol : <label for=\"typeAS\"><input type=\"radio\" name=\"type\" id=\"typeAS\" value=\"0\" onclick=\"JavaScript:selectTypeAS()\" /> aller simple</label> <label for=\"typeAR\"><input type=\"radio\" name=\"type\" id=\"typeAR\" value=\"1\" checked=\"checked\" onclick=\"JavaScript:selectTypeAR()\" /> aller retour</label></div>');
document.write('<div class=\"formMEVleft\">');
document.write('<div class=\"marginTop\" style=\"margin-left:8px;\">départ : <input name=\"departAller\" type=\"text\" tabindex=\"1\" class=\"inputLong\" /></div>');
document.write('<div class=\"marginTop\" style=\"margin-left:3px;\">arrivée : <input name=\"arriveeAller\" type=\"text\" tabindex=\"2\" class=\"inputLong\" /></div>');
document.write('<div class=\"marginTop\" style=\"margin-left:0px;\">place(s) : ');
document.write('<select name=\"paxAdultes\" id=\"paxAdultes\" tabindex=\"7\" class=\"selectSmall\">');
document.write('<option value=\"01\">01</option>');
document.write('<option value=\"02\">02</option>');
document.write('<option value=\"03\">03</option>');
document.write('<option value=\"04\">04</option>');
document.write('<option value=\"05\">05</option>');
document.write('<option value=\"06\">06</option>');
document.write('<option value=\"07\">07</option>');
document.write('<option value=\"08\">08</option>');
document.write('<option value=\"09\">09</option>');
document.write('<option value=\"10\">10</option>');
document.write('</select> <span class=\"formMEVnormal\">adulte(s)</span>');
document.write('</div>');
document.write('</div>');
document.write('<div class=\"formMEVright\">');
document.write('<div class=\"marginTop\" style=\"margin-left:8px;\">aller : <select name=\"jourAller\" id=\"jourAller\" tabindex=\"3\" class=\"selectSmall\">'+selectDA+'</select> <select name=\"moisAller\" id=\"moisAller\" tabindex=\"4\" class=\"selectMedium\">'+selectMYA+'</select> <img class=\"calendrier\" src=\"http://www.easyvols.org/base/img/spacer.gif\" alt=\"choisissez votre date\" align=\"absmiddle\" onclick=\"javascript:window.open(\'http://www.easyvols.org/formulaire/calendriers/mevAller.html\',\'calendar\',\'directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,width=200,height=170\')\" /></div>');
document.write('<div class=\"marginTop\" style=\"margin-left:0px;\" id=\"returnDate\">retour : <select name=\"jourRetour\" id=\"jourRetour\" tabindex=\"5\" class=\"selectSmall\">'+selectDR_V+'</select> <select name=\"moisRetour\" id=\"moisRetour\" tabindex=\"6\" class=\"selectMedium\">'+selectMYR_V+'</select> <img class=\"calendrier\" src=\"http://www.easyvols.org/base/img/spacer.gif\" alt=\"choisissez votre date\" align=\"absmiddle\" onclick=\"javascript:window.open(\'http://www.easyvols.org/formulaire/calendriers/mevRetour.html\',\'calendar\',\'directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,width=200,height=170\')\" /></div>');
document.write('<div class=\"marginTop\" style=\"margin-left:51px;\">');
document.write('<select name=\"paxEnfants\" id=\"paxEnfants\" tabindex=\"8\" class=\"selectSmall\">');
document.write('<option value=\"00\">00</option>');
document.write('<option value=\"01\">01</option>');
document.write('<option value=\"02\">02</option>');
document.write('<option value=\"03\">03</option>');
document.write('<option value=\"04\">04</option>');
document.write('<option value=\"05\">05</option>');
document.write('<option value=\"06\">06</option>');
document.write('<option value=\"07\">07</option>');
document.write('<option value=\"08\">08</option>');
document.write('<option value=\"09\">09</option>');
document.write('<option value=\"10\">10</option>');
document.write('</select> <span class=\"formMEVnormal\">enfant(s)</span>');
document.write('</div>');
document.write('</div>');
document.write('<div class=\"marginTop formMEVvalidation\"><input class=\"formMEVsubmit\" type=\"image\" src=\"http://www.easyvols.org/base/img/spacer.gif\" alt=\"comparez tous les vols\" tabindex=\"9\" /></div>');
document.write('</form>');
