// Weather Widget functions
var current_weather_zip;
function set_current_weather_zip(zip) {
	current_weather_zip = zip;
}

function show_weather_form() {
	$('#weather > .current').fadeOut('fast');
	$('#weather > .form').fadeIn('fast');
	weather_form_to_default();
}

function hide_weather_form() {
	$('#weather > .form').fadeOut('fast');
	$('#weather > .current').fadeIn('fast');
}

function weather_form_to_default() {
	var weather_zip = $('#weather #weather_zip').val();
	var default_weather_zip = 'Zip Code';
	if(weather_zip==current_weather_zip) {
		$('#weather #weather_zip').addClass('default');
	} else if(weather_zip=='' || weather_zip==default_weather_zip) {
		$('#weather #weather_zip').val(default_weather_zip).addClass('default');
	}
}

function weather_form_focus() {
	$('#weather #weather_zip').val('').removeClass('default');
}

$(document).ready(function() {
	
	// Weather Widget
	$('#weather #change_zip').click(function() {
		show_weather_form();
	});
	
	$('#weather #cancel_zip').click(function() {
		hide_weather_form();
	});
	
	$('#weather #weather_zip').focus(function() {
		weather_form_focus();
	}).blur(function() {
		weather_form_to_default();
	});
	
});
