function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function backsetcities() {
  document.mainForm.gateway_dep.value = "";
  document.mainForm.dest_dep.value = "";
  document.mainForm.gateway_ret.value = "";
  document.mainForm.dest_ret.value = "";
  document.mainForm.nb_adult.selectedIndex = "0";
  document.mainForm.nb_child.selectedIndex = "0";
}

function setDates()
{
  var thisDate = new Date();
  var thisDay = thisDate.getDate();
  var thisMonth = thisDate.getMonth();
  var thisYear = thisDate.getYear();

  // Array contenant le nombre de jours dans chaque mois
  var NumberOfDays = new Array();
  NumberOfDays[0] = "31";  // Janvier
  if (((thisYear - 2000)%4) == 0) // Vérifie si c'est une annee bixestile
  {
   NumberOfDays[1] = "29";  // Février
  } else {
   NumberOfDays[1] = "28";  // Février
  }
  NumberOfDays[2] = "31";  // Mars
  NumberOfDays[3] = "30";  // Avril
  NumberOfDays[4] = "31";  // Mai
  NumberOfDays[5] = "30";  // Juin
  NumberOfDays[6] = "31";  // Juillet
  NumberOfDays[7] = "31";  // Aout
  NumberOfDays[8] = "30";  // Septembre
  NumberOfDays[9] = "31";  // Octobre
  NumberOfDays[10] = "30"; // Novembre
  NumberOfDays[11] = "31"; // Decembre

  // Pour traiter les dates de depart
  if ((thisDay + 10) > NumberOfDays[thisMonth])
  {
   var NewDays = (thisDay + 10) - NumberOfDays[thisMonth];
   document.mainForm.Depday.selectedIndex = NewDays - 1;
   document.mainForm.DepMonth.selectedIndex = thisMonth + 1;
  } else {
   document.mainForm.Depday.selectedIndex = thisDay + 9;
   document.mainForm.DepMonth.selectedIndex = thisMonth;
  }

  // Pour traiter les dates de retour
  if ((thisDay + 17) >= NumberOfDays[thisMonth])
  {
   var NewDays = (thisDay + 17) - NumberOfDays[thisMonth];
   if (NewDays == 0)
   {
     document.mainForm.Retday.selectedIndex = 0;
     document.mainForm.RetMonth.selectedIndex = thisMonth + 1;
   } else {
     document.mainForm.Retday.selectedIndex = NewDays - 1;
     document.mainForm.RetMonth.selectedIndex = thisMonth + 1;
   }
  } else {
   document.mainForm.Retday.selectedIndex = thisDay + 16;
   document.mainForm.RetMonth.selectedIndex = thisMonth;
  }
}
function validate_dates()
{
	var today_date = new Date();
	var selDay = today_date.getDate();
	selDay = parseInt(selDay);
	var selMonth = today_date.getMonth();
	selMonth = selMonth + 1;
	depMonth = document.mainForm.DepMonth.value;

	var selDay_plus = selDay + 2;
	
	
	if((selMonth == 0) || (selMonth == 2) || (selMonth == 4) || (selMonth == 6) || (selMonth == 7) || (selMonth == 9) || (selMonth == 11))
        {
		if(selDay_plus > 31)
		{
                	selDay_plus = selDay_plus - 31;
		}
	}
	if((selMonth == 3) || (selMonth == 5) || (selMonth == 8) || (selMonth == 10))
        {
        	if(selDay_plus > 30)
		{
                        selDay_plus = selDay_plus - 30;
		}
	}
	if((selMonth == 1))
        {
                if(((selFullYear % 4 != 0) && (selFullYear % 100 == 0)) || (selFullYear % 400 != 0))
                {
			if(selDay_plus > 28)
			{
				selDay_plus = selDay_plus - 28;
			}
		}
		else
		{
			if(selDay_plus > 29)
			{
				selDay_plus = selDay_plus - 29;
                        }
                }
        }

	depDay = document.mainForm.Depday.value;

	if(document.mainForm.DepMonth.value == selMonth)
        {
		if((document.mainForm.Depday.value < selDay_plus) || (selDay == document.mainForm.Depday.value))
		{
			alert("Due to ticketing requirements you may not select a travel date within two days of today. Please contact our office for departures within the next two days.");
			return false;
		}
		return true;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function winBRopen(theURL, Name, popW, popH, scroll, resize) { // V 1.0
	var winleft = (screen.width - popW) / 2; 
	var winUp = (screen.height - popH) / 2;
	winProp = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+',scrollbars='+scroll+',resizable='+resize+'';
	Win = window.open(theURL, Name, winProp);
	Win.window.focus();
}



