/**
* SABS Agent Search And Booking Software
* <http://www.sabsagent.com>
* Copyright(c) 2001-2009, Micros Travel
*
* @author Jacek Spera <jspera@micros.com>
*/

/*
 * Ext JS Library 2.2.1
 * Copyright(c) 2006-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

// Add the additional 'advanced' VTypes
Ext.apply(Ext.form.VTypes, {
    daterange : function(val, field) {
        var d = field.parseDate(val);

        if(!d){
            return;
        }
        if (field.startDateField && (!this.dateRangeMax || (d.getTime() != this.dateRangeMax.getTime()))) {
            var start = Ext.getCmp(field.startDateField);
            start.setMaxValue(d);
            start.validate();
            this.dateRangeMax = d;
        } 
        else if (field.endDateField && (!this.dateRangeMin || (d.getTime() != this.dateRangeMin.getTime()))) {
            var end = Ext.getCmp(field.endDateField);
            end.setMinValue(d);
            end.validate();
            this.dateRangeMin = d;
        }
        /*
         * Always return true since we're only using this vtype to set the
         * min/max allowed values (these are tested for after the vtype test)
         */
        return true;
    }

});




