
// --------------------------------------------JavaScript DateTimePicker class-------------------------

function DateTimePicker(htmlContainerDivElement, dateTimeType)
{	
	this.Init(htmlContainerDivElement, dateTimeType);
	
	this.inheritFrom = HTMLObject;
	this.inheritFrom(this._dateTimeTXT);
		
	this.AddEventListener('focus',this.Style_GotFocus);
	this.AddEventListener('blur',this.Style_LostFocus);			
	
}

DateTimePicker.prototype.Init = function(htmlContainerDivElement, dateTimeType)
{		
	this._dateTimeTXT = document.createElement("input");
	this._dateTimeTXT.type = "text";
	this._dateTimeTXT.name = htmlContainerDivElement.id + '_txtDateTime';
	this._dateTimeTXT.id = htmlContainerDivElement.id + '_txtDateTime';
	this._dateTimeTXT.value = '';
	this._dateTimeTXT.size='8';
	this._dateTimeTXT.readOnly=true;
	
	this._dateTimeButton = document.createElement("input");
	this._dateTimeButton.type = "button";
	this._dateTimeButton.name = htmlContainerDivElement.name + '_btnDateTime';
	this._dateTimeButton.id = htmlContainerDivElement.id + '_btnDateTime';
	this._dateTimeButton.title="Seleccionar data";
	this._dateTimeButton.value = '...';
	
	htmlContainerDivElement.appendChild(this._dateTimeTXT);
	htmlContainerDivElement.appendChild(this._dateTimeButton);
	
	document.write('<script type="text/javascript">');
	
	switch(dateTimeType)
	{
		case 'dateTime':
			//document.write('Calendar.setup({inputField:"' + this._dateTimeTXT.id + '",ifFormat:"%d-%m-%Y %H:%M",showsTime:true,button:"' + this._dateTimeButton.id + '",singleClick:true});');		
			document.write('Calendar.setup({inputField:"' + this._dateTimeTXT.id + '",ifFormat:"%Y-%m-%d %H:%M",showsTime:true,button:"' + this._dateTimeButton.id + '",singleClick:true});');		
			break;
		case 'time':
			document.write('Calendar.setup({inputField:"' + this._dateTimeTXT.id + '",ifFormat:"%H:%M",showsTime:true,button:"' + this._dateTimeButton.id + '",singleClick:true});');		
			break;
		case 'date':
		default:
			//document.write('Calendar.setup({inputField:"' + this._dateTimeTXT.id + '",ifFormat:"%d-%m-%Y",button:"' + this._dateTimeButton.id + '",singleClick:true});');
			document.write('Calendar.setup({inputField:"' + this._dateTimeTXT.id + '",ifFormat:"%Y-%m-%d",button:"' + this._dateTimeButton.id + '",singleClick:true});');
			break;			
	}
	
	
	document.write('</script>');
}
// --------------------------------------------JavaScript DateTimePicker class End-------------------------

