Ext.QuickTips.init();

function decorateFields()
{	
	var dateFields = Ext.query('.ExtDateField');
	Ext.each( dateFields, function( textField )
    	{
			// don't decoreate them again if already decorated, you get double widgets
			if ( ! Ext.get(textField).hasClass('x-form-field') )
			{
				// get the date value from the textField, omit the time
				var dateVal = textField.value.substring(0,10);
			
	    		var dateField = new Ext.form.DateField({
	            	allowBlank: true,
	            	format:'m/d/Y',
	            	applyTo: textField,
					emptyText: 'mm/dd/yyyy',
					id: textField.id,
					msgTarget: 'under',
					invalidText: 'invalid date - it must be in the format of mm/dd/yyyy'
	        	});
        	
				// set the value of the newly-christened DateField
				if ( dateVal != '0000-00-00'  ) {
					dateField.setValue(dateVal);
				} else {
					dateField.setValue('');
				}
	      //dateField.on( 'focus', enableSave );
			}
		});
	
	var timeFields = Ext.query('.ExtTimeField');
	Ext.each( timeFields, function( textField )
    	{
			if ( ! Ext.get(textField).hasClass('x-form-field') )
			{
	    		var timeField = new Ext.form.TimeField({
	            	allowBlank: true,
	            	format:'h:i a',
	            	applyTo: textField,
					emptyText: 'hh:mm am'
	        	});
				timeField.on( 'change', enableSave );
			}
		});
}

Ext.onReady( decorateFields );

