<?php
// Copyright 2007 FMWebschool Inc. this file is part of FMStudio

function FMStudio_Calendar_Init($language = 'en', $theme = 'win2k-cold-1') {
	static $initDone = false;
	if($initDone) return;
	$calendarRoot = 'Calendar_Module/jscalendar-1.0/';
	echo "\t<!-- calendar stylesheet -->\n";
	echo "\t<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$calendarRoot}{$theme}.css\" title=\"{$theme}\" />\n";
	echo "\t<!-- main calendar program -->\n";
	echo "\t<script type=\"text/javascript\" src=\"{$calendarRoot}calendar.js\"></script>\n";
	echo "\t<!-- language for the calendar -->";
	echo "\t<script type=\"text/javascript\" src=\"{$calendarRoot}lang/calendar-{$language}.js\"></script>\n";
	echo "\t<!-- the following script defines the Calendar.setup helper function, which makes adding a calendar a matter of 1 or 2 lines of code. -->\n";
	echo "\t<script type=\"text/javascript\" src=\"{$calendarRoot}calendar-setup.js\"></script>\n";
	$initDone = true;
}

function FMStudio_Calendar_Bind($inputId,$type = 'timestamp') {
	echo "<script type=\"text/javascript\">\n";
    echo "\tCalendar.setup({\n";
	echo "\t\tinputField: \"{$inputId}\",\n";      // id of the input field
	if($type != 'date') {
		echo "\t\tifFormat: \"%m/%d/%Y %H:%M:00\",\n";       // format of the input field
		echo "\t\tshowsTime: true\n";            // will display a time selector
	}else{
		echo "\t\tifFormat: \"%m/%d/%Y\",\n";       // format of the input field
		echo "\t\tshowsTime: false\n";            // will not display a time selector
	}
	echo "\t});\n";
	echo "</script>\n";
}

?>