// Schedule Service Form YUI Calendar JS by Josh Lizarraga
// Copyright 2010 Autofusion.com

(function(){

if (!Date.now)
{
  Date.now = function now()
  {
    return +new Date();
  };
}

var oTomorrow = Date.now() + 86400000; // 8640000ms = 1 day.

oTomorrow = new Date(oTomorrow);

oTomorrow = (oTomorrow.getMonth() + 1) + '/' + (oTomorrow.getDate()) + '/' + (oTomorrow.getFullYear());

var initCalendar = function(){
	var oCalendar = new YAHOO.widget.Calendar("forms_Calendar", {
		title:		"Choose a date:",
		close:		true,
		selected:	oTomorrow,
		mindate:	oTomorrow
	});
	oCalendar.render();
	oCalendar.selectEvent.subscribe(function(pType, pArgs){
		var oInput = document.getElementById("schedule_date");
		oInput.value = pArgs[0][0][1] + "/" + pArgs[0][0][2] + "/" + pArgs[0][0][0];
		this.hide();
	}, oCalendar, true);
	YAHOO.util.Event.addListener("forms_ShowCalendar", "click", oCalendar.show, oCalendar, true); 
	YAHOO.util.Event.addListener("schedule_date", "focus", oCalendar.show, oCalendar, true); 
};

YAHOO.util.Event.onDOMReady(initCalendar);

})();
