/***** 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(){ // on cache les divs de la date du vol retour
 document.getElementById('returnTitre').style.visibility='hidden';
 document.getElementById('returnDate').style.visibility='hidden';
}
function selectTypeAR(){ // on affiche les divs de la date du vol retour
 document.getElementById('returnTitre').style.visibility='visible';
 document.getElementById('returnDate').style.visibility='visible';
}
/**************/
/* STYLES CSS */
/**************/
document.write('<style type=\"text/css\">');
document.write('#formMEV           { position:relative; width:113px; height:400px; margin:0; padding:0; padding-left:2px; border:0; color:#000000; font-family:verdana,arial,helvetica,sans-serif; font-size:10px; text-align:left !important;}');
document.write('  #formMEV label   { cursor:pointer; display:block; }');
document.write('  #formMEV input   { font-size:9px; text-transform:uppercase; }');
document.write('  #formMEV select  { font-size:9px; font-weight:normal; text-transform:none; }');
document.write('    .marginTop     { margin-top:10px; font-weight:bold; text-transform:uppercase; }');
document.write('    .inputLong     { width:105px; }');
document.write('    .selectSmall   { width:41px; }');
document.write('    .selectMedium  { width:70px; }');
document.write('    .formMEVnormal { font-weight:normal; text-transform:none; }');
document.write('    .formMEVsubmit { width:110px; height:20px; background-image:url(http://www.americas-fr.com/images/rech-vol.gif); background-repeat:no-repeat;background-position:center; }');
document.write('</style>');
/**************/
/* FORMULAIRE */
/**************/
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\">type de vol :</div>');
document.write('<label for=\"typeAS\" class=\"marginTop formMEVnormal\"><input type=\"radio\" name=\"type\" id=\"typeAS\" value=\"0\" onclick=\"JavaScript:selectTypeAS()\" /> aller simple</label>');
document.write('<label for=\"typeAR\" class=\"marginTop formMEVnormal\" style=\"margin-bottom:20px !important;\"><input type=\"radio\" name=\"type\" id=\"typeAR\" value=\"1\" checked=\"checked\" onclick=\"JavaScript:selectTypeAR()\" /> aller retour</label>');
document.write('<div class=\"marginTop\">ville de départ :</div>');
document.write('<div class=\"marginTop\"><input name=\"departAller\" type=\"text\" tabindex=\"1\" class=\"inputLong\" /></div>');
document.write('<div class=\"marginTop\">ville d\'arrivée :</div>');
document.write('<div class=\"marginTop\"><input name=\"arriveeAller\" type=\"text\" tabindex=\"2\" class=\"inputLong\" /></div>');
document.write('<div class=\"marginTop\">date de l\'aller :</div>');
document.write('<div class=\"marginTop\"><select name=\"jourAller\" id=\"jourAller\" tabindex=\"3\" class=\"selectSmall\">'+selectDA+'</select><select name=\"moisAller\" id=\"moisAller\" tabindex=\"4\" class=\"selectMedium\">'+selectMYA+'</select></div>');
document.write('<div class=\"marginTop\" id=\"returnTitre\">date du retour :</div>');
document.write('<div class=\"marginTop\" id=\"returnDate\"><select name=\"jourRetour\" id=\"jourRetour\" tabindex=\"5\" class=\"selectSmall\">'+selectDR_V+'</select><select name=\"moisRetour\" id=\"moisRetour\" tabindex=\"6\" class=\"selectMedium\">'+selectMYR_V+'</select></div>');
document.write('<div class=\"marginTop\">place(s) :</div>');
document.write('<div class=\"marginTop\">');
document.write('<select name=\"paxAdultes\" id=\"paxAdultes\" tabindex=\"7\" class=\"selectSmall\">');
document.write('<option value=\"01\" selected=\"selected\">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 class=\"marginTop\">');
document.write('<select name=\"paxEnfants\" id=\"paxEnfants\" tabindex=\"8\" class=\"selectSmall\">');
document.write('<option value=\"00\" selected=\"selected\">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 class=\"marginTop\"><input class=\"formMEVsubmit\" type=\"image\" src=\"http://www.easyvols.org/base/img/spacer.gif\" alt=\"comparez tous les voyagistes\" tabindex=\"9\" /></div>');
document.write('</form>');
