﻿/*  Author: Justin Shearer
	Date Modified: 1/31/11
*/
$(document).ready(function(){
	$('nav ul>li:last-child').addClass('last');
	$('input[type=submit]').wrap('<span class="buttonWrapper"></span>');
	$('var').html(new Date().getFullYear());
	$("header nav ul").superfish({
		hoverClass:'selected',
		autoArrows:false,
		animation:{height:'show'}
		}); 
	$.YQL("select * from weather.forecast where location=29201",function(data){
			var w=data.query.results.channel;
			var wd=w.wind.direction;
			if(wd>=348.75&&wd<=360){wd="N"};if(wd>=0&&wd<11.25){wd="N"};if(wd>=11.25&&wd<33.75){wd="NNE"};if(wd>=33.75&&wd<56.25){wd="NE"};if(wd>=56.25&&wd<78.75){wd="ENE"};if(wd>=78.75&&wd<101.25){wd="E"};if(wd>=101.25&&wd<123.75){wd="ESE"};if(wd>=123.75&&wd<146.25){wd="SE"};if(wd>=146.25&&wd<168.75){wd="SSE"};if(wd>=168.75&&wd<191.25){wd="S"};if(wd>=191.25 && wd<213.75){wd="SSW"};if(wd>=213.75&&wd<236.25){wd="SW"};if(wd>=236.25&&wd<258.75){wd="WSW"};if(wd>=258.75 && wd<281.25){wd="W"};if(wd>=281.25&&wd<303.75){wd="WNW"};if(wd>=303.75&&wd<326.25){wd="NW"};if(wd>=326.25&&wd<348.75){wd="NNW"};
			$('#weatherWidget').append("<img src='http://l.yimg.com/a/i/us/nws/weather/gr/"+w.item.condition.code+"d.png' alt='"+w.item.condition.text+"'>");
			$('#weatherTemp').html(w.item.condition.temp+"°");
			$('#weatherText').html("Conditions: "+w.item.condition.text);
			$('#weatherWind').html("Winds: "+wd +" "+w.wind.speed+"mph");
			$('#weatherLink').html("<a href='"+w.item.link+"'>Full Forecast</a>");
	});

	$('#mainImage').cycle({timeout:5000});
	$('#quicklinks').change(function(){
		window.location = $(this).val();
	});
});
$(window).load(function () {
	$('#main img').not('.home #main img').each(function(index){
		$(this).wrap("<span class='imgWrap' height='"+$(this).height()+"' width='"+$(this).width()+"'></span>");
	})
	$('.home section').height(Math.max($('#getInvolved').height(),$('#getInformed').height(),$('#getWhatYouNeed').height()));
});
