//WEATHER WIDGET
$(document).ready(function(){ 
	var clouds;
	$.getJSON("http://ws.geonames.org/weatherIcaoJSON?ICAO=KBFI&callback=?", 
			{'uID': 1}, function(data){
				if ( data.weatherObservation.clouds != 'n/a' ) { clouds = data.weatherObservation.clouds + ', '; }else{ clouds = "" }
				$('.weather p').append(
					'<span class="georgia_red_italic">Currently in Seattle:&nbsp;</span>' 
					+ clouds
					+ conversion(data.weatherObservation.temperature) 
					+ '&deg;F'
				 );
				$('.loader').hide();
	  });   
	//Converts Celcius to Fahrenheit 
	function conversion(cel) {
		far = Math.round((9/5 * cel) + 32);
		return far;
	}; 
   
	// Traffic page maps sliding 
	$('.slider').cycle({
		fx: 'scrollLeft', 
		timeout:       6000,
		pager: '.numbered_buttons ul', 
		pause: true
	});
	
	$('.home_hero').cycle({
		
	});
	      
	//Input click-in/click-out
	$("input[type='text']").focus(function(){
		if(this.value == this.defaultValue){
			this.value= '';
		}
	});
	$("input[type='text']").blur(function(){
		if($.trim(this.value) == ''){
			this.value = this.defaultValue;
		} 
	}); 
	
	$("#signup").validate({
		errorContainer: $(".errors1. .errors2, .errors3")
	});
	
	var hash = window.location.hash;
		if(hash){
			if(hash == "#success"){ 
				$('#alert').addClass('good').removeClass('error');				
				$('#alert').slideToggle();
				$('#alert').append('Thanks very much -- your information has been sent!');
			}else if(hash == '#error'){
				$('#alert').slideToggle();
				$('#alert').addClass('error').removeClass('good');
				$('#alert').append('We\'re sorry -- there seems to have been a problem with the form submission. Can you please try again, or contact us directly at <a href="mailto:mike@processheating.com">mike@processheating.com</a>.')
			}
		}
	     
});

