if (!window.$)
	var $ = function(s) {return document.getElementById(s); };

var CM = {

	hasCalendar	:	false,
	hasForm	:	false,
	hasValidation	:	true,

	options : {
		frm: 'contactForm',
		btn: 'submitButton',
		startDate : 'arrival-date',
		endDate: 'departure-date',
		startCal : 'arrivalCalendar',
		endCal : 'departureCalendar'
	},

	initForm : function()
	{
		var opt = this.options;
		if (!this.hasForm)
			return;
		// contact form code
		if ($(opt.btn))
			$(opt.btn).onclick= function() { if (this.form.onsubmit()) this.form.submit(); };

		if ($(opt.frm) && this.hasValidation)
			$(opt.frm).onsubmit = function() { return validateForm($(opt.frm)); };
	},

	initCalendars : function()
	{
		var opt = this.options;

		if (!this.hasCalendar)
			return;
		if ($(opt.startCal))
		{
			Calendar.setup({inputField:$(opt.startDate), button:$(opt.startCal), ifFormat:"%m/%d/%Y", step:1, showsTime:false});
			$(opt.startCal).style.visibility = "visible";
		}
		if ($(opt.endCal))
		{
			Calendar.setup({inputField:$(opt.endDate), button:$(opt.endCal), ifFormat:"%m/%d/%Y", step:1, showsTime:false});
			$(opt.endCal).style.visibility = "visible";
		}
	}
};