Weather = Class.create();
Weather.prototype = {
	initialize: function() {
	},

    showLoading: function() {
        document.getElementById("checkWeather").disabled = true;
        document.getElementById("checkWeather").value = 'Loading ...';
    },
    
    hideLoading: function() {
        document.getElementById("checkWeather").disabled = false;
        document.getElementById("checkWeather").value = 'Go';
    },
    
    resetValue: function() {
        document.getElementById("result").style.display = 'none';
    },
    
    showValue: function() {
        document.getElementById("result").style.display = 'block';
    },
	
	checkWeather: function() {
	    this.resetValue();
	    this.showLoading();
        var pars = 'zip=' + escape(document.getElementById('weatherZip').value);
        new Ajax.Request('getweather.php', {method: 'get', parameters: pars, onComplete: this.handleWeather.bind(this)});
	},

	handleWeather: function(originalRequest) {
	    this.showValue();
	    this.hideLoading();
	    document.getElementById('result').innerHTML = originalRequest.responseText;
	}
}

var weather;
window.onload = function() {
    weather = new Weather();
}
