﻿// JScript File
Ext.namespace('Genesis');
/*
  * @extends Ext.form.DateField
  * @constructor
  * @param {Object} config Configuration options
*/

Ext.apply(Ext.form.VTypes, {
	daterange : function(val, field) {
		var date = field.parseDate(val);

		if(!date){
			return;
		}
		if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) {
			var start = Ext.getCmp(field.startDateField);
			start.setMaxValue(date);
			start.validate();
			this.dateRangeMax = date;
		} 
		else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) {
			var end = Ext.getCmp(field.endDateField);
			end.setMinValue(date);
			end.validate();
			this.dateRangeMin = date;
		}
		/*
		 * 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;
	},
	password : function(val, field) {
        if (field.initialPassField) {
            var pwd = Ext.getCmp(field.initialPassField);
            return (val == pwd.getValue());
        }
        return true;
    },

    passwordText : 'Passwords do not match'
});

Genesis.DatePicker=function(config)    {
        //call parent constructor
        Genesis.DatePicker.superclass.constructor.call(this,config);          
		this.on("focus",this.withFocus,this);
		this.on("blur", this.lostFocus,this); 
 }


    Ext.extend(Genesis.DatePicker,Ext.form.DateField,{    
    visibilityType:'U',
	controlID:'',
  
    format:'m/d/Y',
    width:100,
    withFocus:function(){	
		this.hasFocus=true;
        checkVisibility(this);
	 },
	 lostFocus:function(){
	    this.hasFocus=false;
    	checkVisibility(this);
     },
	  
    afterRender:	 function(){
            Genesis.DatePicker.superclass.afterRender.apply(this, arguments);
			checkVisibility(this);    		
    }

    ,editorDatePicker:function() {
        return new Ext.grid.GridEditor(new Genesis.DatePicker());
    } // eo function editorGender
   
    });
    Ext.reg('gendate',Genesis.DatePicker);
    
    
    
    
    
    
