  ///////////////////////////////////////////////////////////////
  displayCalendar = function(month, year) {
    if (month == null && year == null) {
      date = new Date();
      month = date.getMonth();
      year = date.getYear();
    }
    daysInMonth = getDaysInMonth(month, year);
    startDay = getStartDay(month, year);
    
    nextMonth = month+1;
    nextYear = year;
    if (nextMonth > 11) {
      nextMonth = 0;
      nextYear++;
    }
    
    prevMonth = month-1;
    prevYear = year;
    if (prevMonth < 0) {
      prevMonth = 11;
      prevYear--;
    }
    
    HTML = '<div class="head"><a href="#" onclick="displayCalendar(prevMonth, prevYear); return false;"><<</a> ';
    HTML += (month+1) + '/' + year;
    HTML += ' <a href="#" onclick="displayCalendar(nextMonth, nextYear); return false;">>></a></div>';
    
	
	
	
    HTML += '<table>';
    HTML += '<tr>';
    

    for (v=0;v<startDay;v++) {
      HTML += '<td class="empty">&nbsp;</td>';
    }
	
    for(j = 0; j < daysInMonth; j++) {
      HTML += ('<td id="' + (j + 1) + '"><a href="#" onclick="selectDay(' + (j+1) + ', ' + month + ', ' + year + '); return false;">' + (j + 1) + '</a></td>');
      
      startDay++;
      if (((startDay) % 7) == 0) { // 6, 13, 20, 27 -- the last day in the week
        if (j < daysInMonth) { HTML += '</tr><tr>'; }
      }
    }

    k = startDay % 7;
    while (k < 7 && k > 0) {
      HTML += '<td class="empty">&nbsp;</td>';
      k++;
    }
	
    HTML += '</tr>';
    HTML += '</table>';
	
	
    if (g('cal')) {
      g('cal').innerHTML = HTML;
	}
	
	
	
	
    
  }
  /////////////////////////////////////////////////////////////
  
  /////////////////////////////////////////////////////////////
  selectDay = function(day, month, year) {
    oldSelected = g('day').value;
    if (g(oldSelected)) { g(oldSelected).className = ''; }
    
    g(day).className = 'selected';
    g('day').value = day;
    g('month').value = month;
    g('year').value = year;
  }
  /////////////////////////////////////////////////////////////
  
  
  /////////////////////////////////////////////////////////////////
  getStartDay = function(month, year) {
    // returns the number coresponding to the day of the week on which the month starts
    date = new Date(year, month);
    return date.getDay();
  }
  /////////////////////////////////////////////////////////////////
  
  
  /////////////////////////////////////////////////////////////////
  getDaysInMonth = function(month, year) {
    // returns the number of days in a given month
    daysSoFar = 28;
    date = new Date(year, month, daysSoFar);
    
    while (date.getMonth() == month) {
      date.setDate(date.getDate() + 1);
      daysSoFar++;
    }
    daysSoFar--; // the above algorithm will increment daysSoFar one extra time
    return daysSoFar;
  }
  ///////////////////////////////////////////////////////////////////

  function initCalendar() {
    date = new Date();
    displayCalendar(date.getMonth(), date.getFullYear());
  }

ev.add(window, 'load', initCalendar);



function checkForm(form) {


  if (form.type.value == 'Choose...') {
  	alert('Veuillez sélectionnez une estimation de type');
	return false;
  } else if (form.type.value == 'Choisissez...') {
    alert('Veuillez sélectionnez une estimation de type');
	return false;
  } else if (form.firstName.value == '') {
    alert('Veuillez entrer votre prénom.');
	return false;
  } else if (form.lastName.value == '') {
    alert('Veuillez entrer votre nom.');
	return false;
  } else if (form.address.value == '') {
    alert('Veuillez entrer une adresse.');
	return false;
  } else if (form.city.value == '') {
    alert('Veuillez entrer la ville.');
	return false;
  } else if (g('firstPhone').value == '') {
    alert('Veuillez entrer un numéro de téléphone.');
	return false;
  } else if (!(form.email.value.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i))) {
    alert('Le format du courriel entré n’est pas valide.');
	return false;
  }
  return true;
}

function addNumber() {
  var div = g('phoneNumbers');
  
  var label = document.createElement('label');
  label.innerHTML = 'Autre Num&eacute;ro : ';
  label.className = 'sameLineLarge';
  
  var input = document.createElement('input');
  input.name = 'phone[]'
  input.className = 'medium';
  
  div.appendChild(label);
  div.appendChild(input);
}
