/***** 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_C=new Date(); dateR_C.setDate(dateR_C.getDate()+interval+7);
var selectDR_C=createDOptions(dateR_C.getDate());
var selectMYR_C=createMYOptions(dateR_C.getMonth(),dateR_C.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 verifyMEC(){ // vérifie le formulaire des locations de voitures
	var f=document.getElementById('formMEC');
	if(f.pickUpLocation.tagName.toLowerCase()=="input"){ try{ f.pickUpLocation.value=accent(trim(f.pickUpLocation.value)); }catch(e){} }
}
document.write('<style type=\"text/css\">');
document.write('  #formMEC               { position:relative; width:430px; height:150px; margin:0; padding:0; border:0; font-size:10px;}');
document.write('    #formMEC input       { font-size:9px; text-transform:uppercase; }');
document.write('    #formMEC label       { cursor:pointer; }');
document.write('    #formMEC select      { font-size:9px; font-weight:normal; text-transform:none; }');
document.write('      .formMECleft       { float:left; text-align:left; }');
document.write('      .formMECright      { 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('      .formMECnormal     { font-weight:normal; text-transform:none; }');
document.write('      .formMECvalidation { 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('      .formMECsubmit { 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=\"formMEC\" action=\"http://www.easyvols.org/partners/mec/results.jsp\" onsubmit=\"javascript:verifyMEC();\" target=\"_blank\">');
document.write('<input type=\"hidden\" name=\"clientId\" id=\"eaClientId\" value=\"1\" />');
document.write('<div class=\"formMECleft\">');
document.write('<div class=\"marginTop\" style=\"margin-left:19px;\">ville : <input name=\"pickUpLocation\" type=\"text\" tabindex=\"1\" class=\"inputLong\" /></div>');
document.write('<div class=\"marginTop\" style=\"margin-left:4px;\">retrait : <select name=\"pickUpDay\" id=\"pickUpDay\" tabindex=\"2\" class=\"selectSmall\">'+selectDA+'</select> <select name=\"pickUpMonth\" id=\"pickUpMonth\" tabindex=\"3\" 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/mecRetrait.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:48px;\">à ');
document.write('<select id=\"pickUpHour\" name=\"pickUpHour\" tabindex=\"4\" class=\"selectMedium\">');
document.write('<option value=\"00:00\">00:00</option>');
document.write('<option value=\"01:00\">01:00</option>');
document.write('<option value=\"02:00\">02:00</option>');
document.write('<option value=\"03:00\">03:00</option>');
document.write('<option value=\"04:00\">04:00</option>');
document.write('<option value=\"05:00\">05:00</option>');
document.write('<option value=\"06:00\">06:00</option>');
document.write('<option value=\"07:00\">07:00</option>');
document.write('<option value=\"08:00\">08:00</option>');
document.write('<option value=\"09:00\">09:00</option>');
document.write('<option value=\"10:00\" selected=\"selected\">10:00</option>');
document.write('<option value=\"11:00\">11:00</option>');
document.write('<option value=\"12:00\">12:00</option>');
document.write('<option value=\"13:00\">13:00</option>');
document.write('<option value=\"14:00\">14:00</option>');
document.write('<option value=\"15:00\">15:00</option>');
document.write('<option value=\"16:00\">16:00</option>');
document.write('<option value=\"17:00\">17:00</option>');
document.write('<option value=\"18:00\">18:00</option>');
document.write('<option value=\"19:00\">19:00</option>');
document.write('<option value=\"20:00\">20:00</option>');
document.write('<option value=\"21:00\">21:00</option>');
document.write('<option value=\"22:00\">22:00</option>');
document.write('<option value=\"23:00\">23:00</option>');
document.write('</select>');
document.write('</div>');
document.write('</div>');
document.write('<div class=\"formMECright\">');
document.write('<div class=\"marginTop\" style=\"margin-left:13px;\">âge : <input name=\"driverAge\" type=\"text\" tabindex=\"8\" class=\"inputShort\" value=\"25\" /> <span class=\"formMECnormal\">ans</span></div>');
document.write('<div class=\"marginTop\" style=\"margin-left:0px;\">dépôt : <select name=\"dropOffDay\" id=\"dropOffDay\" tabindex=\"5\" class=\"selectSmall\">'+selectDR_C+'</select> <select name=\"dropOffMonth\" id=\"dropOffMonth\" tabindex=\"6\" class=\"selectMedium\">'+selectMYR_C+'</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/mecDepot.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:33px;\">à ');
document.write('<select id=\"dropOffHour\" name=\"dropOffHour\" tabindex=\"7\" class=\"selectMedium\">');
document.write('<option value=\"00:00\">00:00</option>');
document.write('<option value=\"01:00\">01:00</option>');
document.write('<option value=\"02:00\">02:00</option>');
document.write('<option value=\"03:00\">03:00</option>');
document.write('<option value=\"04:00\">04:00</option>');
document.write('<option value=\"05:00\">05:00</option>');
document.write('<option value=\"06:00\">06:00</option>');
document.write('<option value=\"07:00\">07:00</option>');
document.write('<option value=\"08:00\">08:00</option>');
document.write('<option value=\"09:00\">09:00</option>');
document.write('<option value=\"10:00\" selected=\"selected\">10:00</option>');
document.write('<option value=\"11:00\">11:00</option>');
document.write('<option value=\"12:00\">12:00</option>');
document.write('<option value=\"13:00\">13:00</option>');
document.write('<option value=\"14:00\">14:00</option>');
document.write('<option value=\"15:00\">15:00</option>');
document.write('<option value=\"16:00\">16:00</option>');
document.write('<option value=\"17:00\">17:00</option>');
document.write('<option value=\"18:00\">18:00</option>');
document.write('<option value=\"19:00\">19:00</option>');
document.write('<option value=\"20:00\">20:00</option>');
document.write('<option value=\"21:00\">21:00</option>');
document.write('<option value=\"22:00\">22:00</option>');
document.write('<option value=\"23:00\">23:00</option>');
document.write('</select>');
document.write('</div>');
document.write('</div>');
document.write('<div class=\"marginTop formMECvalidation\"><input class=\"formMECsubmit\" type=\"image\" src=\"http://www.easyvols.org/base/img/spacer.gif\" alt=\"comparez tous les voyagistes\" tabindex=\"8\" /></div>');
document.write('</form>');
