/*
Copyright (c) ScanFrame 2008.
All Rights Reserved.

$Source: /export/cvs/primo/com/jscripts/calendar.js,v $
$Author: arjan $
$Revision: 1.2 $

Identification:
  JSCRIPTS

Initial Author:
  AVO 20080909

Purpose:
	Library for date picker loading and creation.

*/

// Global Flag for when script is imported twice.
var calendar_imported;
//
if (!calendar_imported)
{
	// Set flag so reenty is not possible.
	calendar_imported = true;
	// Import the main calendar script.
	javascript_import('jscripts/calendar/rich_calendar.js', 'rich_calendar_base')
	// Dynamically load the needed style
	stylesheet_import('jscripts/calendar/rich_calendar.css', 'rich_calendar_css');
	// On loaded load the languages. This is needed for IE !$!#!!$#
	AddEvent(window, 'load', function()
	{
		javascript_import('jscripts/calendar/rc_lang_en.js', 'rich_calendar_en');
		javascript_import('jscripts/calendar/rc_lang_nl.js', 'rich_calendar_nl');
	});
	// Global Calendar object. Only one can exist at a time.
	var CalendarObject = null;
	// Called from an input ar ascociated button.
	function SelectDate(input, lang, show_time)
	{
		if (CalendarObject)
			CalendarObject.hide();
		CalendarObject = new RichCalendar(input, show_time);
		CalendarObject.language = lang;
		CalendarObject.parse_date(input.value);
		CalendarObject.auto_close = true;
		CalendarObject.show_at_element(input, "under");
	}
}
