/*extern document */
/*extern WCD, Ext */
/*extern propertylist */

/*jslint white: false */

// first, declare the namespace if it does not exist
if (WCD === null || typeof(WCD) !== 'object') {
    var WCD = {};
}

WCD.Weather = {};

WCD.Weather.setCelsius = function(){
	Ext.onReady(function() {  
		Ext.select('.wcd-weather-celsius').enableDisplayMode('block').toggle(); 
		Ext.select('.wcd-weather-fahrenheit').enableDisplayMode('block').toggle(); 
		
		Ext.select('.wcd-weather-cf-selector').update(
			'<a href="javascript:WCD.Weather.setFahrenheit();">F&deg;</a> | C&deg;');

		if(readCookie('wcd_weatherFormat') !== 'celsius') {
			createCookie('wcd_weatherFormat','celsius','365');
		}
		
	} );
};

WCD.Weather.setFahrenheit = function(){
	Ext.onReady(function() {  
		Ext.select('.wcd-weather-celsius').enableDisplayMode('block').toggle(); 
		Ext.select('.wcd-weather-fahrenheit').enableDisplayMode('block').toggle(); 

		Ext.select('.wcd-weather-cf-selector').update(
			'F&deg; | <a href="javascript:WCD.Weather.setCelsius();">C&deg;</a>');

		if(readCookie('wcd_weatherFormat') !== 'fahrenheit') {
			createCookie('wcd_weatherFormat','fahrenheit','365');
		}

	} );
};


/*WCD.Weather.showExtendedForecastDetail = function(day_sequence){
	Ext.onReady(function() {  
		Ext.get('wcd-extended-forecast-detail-'+day_sequence).setVisibilityMode('display'); 
		Ext.get('wcd-extended-forecast-detail-'+day_sequence).show(); 
	} );
};

WCD.Weather.hideExtendedForecastDetail = function(day_sequence){
	Ext.onReady(function() {  
		Ext.get('wcd-extended-forecast-detail-'+day_sequence).setVisibilityMode('display'); 
		Ext.get('wcd-extended-forecast-detail-'+day_sequence).hide(); 
	} );
};*/


// set celsius or fahrenheit from cookie
Ext.onReady(function() {
        if(readCookie('wcd_weatherFormat') === 'celsius') {
	    Ext.select('.wcd-weather-fahrenheit').enableDisplayMode('block').toggle(); 
            WCD.Weather.setCelsius();
        } else {
	    Ext.select('.wcd-weather-celsius').enableDisplayMode('block').toggle(); 
	    WCD.Weather.setFahrenheit();
	}
});