﻿// JavaScript Document

			var oldLink = null;
			function setActiveStyleSheet(link, title) {
			  var i, a, main;
			  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
				if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
				  a.disabled = true;
				  if(a.getAttribute("title") == title) a.disabled = false;
				}
			  }
			  if (oldLink) oldLink.style.fontWeight = 'normal';
			  oldLink = link;
			  link.style.fontWeight = 'bold';
			  return false;
			}
			function selected(cal, date) 
			{
			  // done by PIYUSH at 09-04
			  if(Disable==true)
			  {
				  var sldate=date.split('/');
				  var tdt = new Date();
				  if(tdt.getMonth() == (sldate[1]-1) && tdt.getFullYear() == sldate[2])
				  {
					if(sldate[0]== (tdt.getDate()) || sldate[0]== (tdt.getDate()+1))
					{
						alert("Vous pouvez réserver jusqu'à 2 jours à l'avance. Pour les inscriptions à moins de 2 jours, choisissez les formules dernière minute.");
						cal.callCloseHandler();
						return false;
					}
				  }
			  }
			  // end
			  cal.sel.value = date; // just update the date in the input field.
			  if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
				cal.callCloseHandler();
			}
			function closeHandler(cal) {
			  cal.hide();                        // hide the calendar
			  calendar = null;
			}
			
			function showCalendar(id,mycar) { 
			
				var el = document.getElementById(id);
				if (calendar != null) {
					// we already have one created, so just update it.
					calendar.hide();		// hide the existing calendar
					calendar.parseDate(el.value); // set it to a new date
				} else {
					// first-time call, create the calendar
					var cal = new Calendar(true, null, selected, closeHandler,mycar);
					calendar = cal;		// remember the calendar in the global
					cal.setRange(2000, 2070);	// min/max year allowed
					calendar.weekNumbers = false;
					calendar.create();		// create a popup calendar

				}
				calendar.sel = el;		// inform it about the input field in use
				calendar.showAtElement(el);	// show the calendar next to the input field
			
				// catch mousedown on the document
				//Calendar.addEvent(document, "mousedown", checkCalendar);
				return false;
			}
			
			var MINUTE = 60 * 1000;
			var HOUR = 60 * MINUTE;
			var DAY = 24 * HOUR;
			var WEEK = 7 * DAY;
			
			function isDisabled(date) 
			{ 
			  var today = new Date();
			  return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
			}
			
			function flatSelected(cal, date) 
			{
			  //var el = document.getElementById("preview");
			  el.innerHTML = date;
			}
			
			function showFlatCalendar() 
			{
			  var parent = document.getElementById("display");
			  var cal = new Calendar(true, null);
			  cal.weekNumbers = false;
			  //cal.setDisabledHandler(isDisabled);
			  cal.setDateFormat("%A, %B %e");
			  cal.create(parent);
			  cal.show();
			}
