Ext.namespace('Ext.exampledata');

Ext.exampledata.children = [
	['0'],
	['1'],
	['2'],
	['3'],
	['4'],
	['5']
    ];

Ext.exampledata.adults = [
	['1'],
	['2'],
	['3'],
	['4']
    ];
    
Ext.exampledata.nights = [
	['1'],
	['2'],
	['3'],
	['4'],
	['5'],
	['6'],
	['7']
    ];


function querySt(ji) {
hu = window.location.search.substring(1);
hu = hu.toLowerCase();
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}

var arrivaldate = querySt("arrivaldate");
var adultsval = querySt("adults");
var childrenval = querySt("children");
var nightsval = querySt("nights");

if (!arrivaldate)
	{
	var today = new Date();
	arrivaldate = new Date(today.getFullYear(), today.getMonth(), today.getDate()+8);
	}

var d = new Date();

Ext.onReady(function(){

    Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

    var bd = Ext.getBody();

		/*
		 * ================  Date Range  =======================
		 */
    
    var dr2 = new Ext.FormPanel({
      standardSubmit: true,
      labelWidth: 45,
      frame: true,
      title: '<center>Book a Vacation</center>',
	    bodyStyle:'padding:3px 3px 0',
	    width: 165,
	    height: 190,
      defaults: {width: 78},
      defaultType: 'datefield',
      items: [{
      	fieldLabel: 'Arrival Date',
        name: 'arrivaldate',
        id: 'arrival_date',
        xtype: 'datefieldplus',
        allowBlank:false,
        noOfMonth : 3,
        value: SaDate,
        noOfMonthPerRow : 3,
			  markWeekends:false,
			  markNationalHolidays:true,
				allowMouseWheel: true,
				showWeekNumber:false,
				showActiveDate:false,
				eventDates : function(year) {
						var dates = [
						{
							date: new Date(year,12,31), 
							text: "New Years, ("+(year-1971)+")",
							cls: "x-datepickerplus-eventdates"									
						}
								
						];
						return dates;
					},	
        disabledDates: ["3/21/09","3/22/09","3/24/09"],
        minValue: new Date(d.getYear(),d.getMonth(),d.getDate()-0).clearTime(),
        endDateField: 'enddt' // id of the end date field
      },new Ext.form.ComboBox({
            fieldLabel: 'Nights',
            editable: false,
            hiddenName: 'Nights',
            store: new Ext.data.SimpleStore({
                fields: ['Nights'],
                data : Ext.exampledata.nights
            }),
            displayField: 'Nights',
            typeAhead: true,
            mode: 'local',
            triggerAction: 'all',
            emptyText:'Nights...',
            value: nightsval,
            selectOnFocus:true,
            width:190
            }),new Ext.form.ComboBox({
            fieldLabel: 'Adults',
            editable: false,
            hiddenName: 'Adults',
            store: new Ext.data.SimpleStore({
                fields: ['Adults'],
                data : Ext.exampledata.adults
            }),
            displayField: 'Adults',
            typeAhead: true,
            mode: 'local',
            triggerAction: 'all',
            emptyText:'Adults...',
            value: adultsval,
            selectOnFocus:true,
            width:190
            }),new Ext.form.ComboBox({
            fieldLabel: 'Children',
            editable: false,
            hiddenName: 'Children',
            store: new Ext.data.SimpleStore({
                fields: ['Children'],
                data : Ext.exampledata.children
            }),
            displayField: 'Children',
            typeAhead: true,
            mode: 'local',
            triggerAction: 'all',
            value: childrenval,
            emptyText:'Children...',
            selectOnFocus:true,
            width:190
            })],
      buttons: [{
            text: 'Check Availability',
            handler: function() {
            		dr2.getForm().getEl().createChild({tag: 'input', type: 'hidden', name: 'package_id', value: '50'});
            		dr2.getForm().getEl().dom.action = '/Virginia-Beach-Resort-Packages/';
	        			dr2.getForm().getEl().dom.method = 'GET';
                dr2.getForm().submit();
            }
        }]
    });


    
    dr2.render('dr2');
    
    
});
