
var CityCombo ;
var CountyCombo ;
var txtZipCode ;
Ext.onReady(function()
{
   Ext.QuickTips.init();
   
	CityCombo = new Genesis.ComboBox({
		store: DistinctCityDS,
		displayField:'NAME',
		valueField: 'ID',
		typeAhead: true,
		mode: 'local',
		triggerAction: 'all',
		hideTrigger	:false,
		listWidth:150,
		selectOnFocus:true,
		autocomplete:'off',
		applyTo: 'together_txtCity',
		  listeners:{select:{fn:function(combo, value) {

			CountyCombo.setValue('');
			txtZipCode.setValue('');
	}}}

	});

	CountyCombo = new Genesis.ComboBox({
		store: CountyDS,
		displayField:'NAME',
		valueField: 'ID',
		typeAhead: true,
		mode: 'local',
		triggerAction: 'all',
		hideTrigger	:false,
		listWidth:150,
		selectOnFocus:true,
		autocomplete:'off',
		applyTo: 'together_txtCounty',
		listeners:{select:{fn:function(combo, value) {

			CityCombo.setValue('');
			txtZipCode.setValue('');
	}}}
	});

	txtZipCode = new Genesis.NumTextBox({		
		applyTo: 'together_txtZipcode',
		listeners:{change:{fn:function(txt, value,newvalue) {

			CountyCombo.setValue('');
			CityCombo.setValue('');
	}}}
	});		

});
function GoSearch()
{
  	var city=document.getElementById('together_txtCity').value;
  	var county=document.getElementById('together_txtCounty').value;
  	var zip=document.getElementById('together_txtZipcode').value;
	window.location='UI/SearchProviderResult.aspx?city='+city +'&county='+ county +'&zip='+zip;
	
}

//var SelectCounty=function(record, index)
//{
//    if(this.fireEvent('beforeselect', this, record, index) !== false){
//            this.setValue(record.data[this.valueField || this.displayField]);
//            this.collapse();
//            this.fireEvent('select', this, record, index);
//    }
//    clearOthers('CO');
//    return true;
//}

//var SelectCity=function(record, index)
//{
//    if(this.fireEvent('beforeselect', this, record, index) !== false){
//            this.setValue(record.data[this.valueField || this.displayField]);
//            this.collapse();
//            this.fireEvent('select', this, record, index);
//    }
//    clearOthers('CI');
//    return true;
//}

//    


function ValidateHomePage()
{
    var city,county,zip;
    city=trim(document.getElementById('together_txtCity').value);
    county=trim(document.getElementById('together_txtCounty').value);
    zip=trim(document.getElementById('together_txtZipcode').value);
    var dvError=document.getElementById('dvError');
    dvError.innerHTML='';
    if(city=='' && county=='' && zip=='')
    {
        //ShowError('Please provide value of City or County or Zip Code');
        dvError.innerHTML='Please provide the value of City or County or Zip Code';
        document.getElementById('together_txtZipcode').focus();
        return false;
    }
    else if(zip.length<5 && zip.length>0 )
    {
		//ShowError('Invalid Zip Code format. Please provide the Zip Code in 5 digit format.');
		dvError.innerHTML='Invalid Zip Code format. Please provide the Zip Code in 5 digit format.';
		document.getElementById('together_txtZipcode').focus();
		return false;
    }
    
    return true;
}