$(function(){
	
	// header weather
	$.simpleWeather({
		zipcode: '55808',
		unit: 'f',
		success: function(weather) {
		//$("#weather").append('<span>'+weather.city+', '+weather.region+'</span>');
		$("#weather").append('<img width="125px" src="'+weather.image+'">');
		$("#weather").append('<p>Currently '+weather.temp+'&deg; '+weather.units.temp+'<br><span> '+weather.currently+'</span><br><a href="'+weather.link+'" target="_blank">View Forecast &raquo;</a></p>');
		},
		error: function(error) {
		$("#weather").html('<p>'+error+'</p>');
		}
	});
	
	// mailsignup
	$("#sendmail").click(function(){
		var valid = '';
		var isr = ' is required.';
		
		var mail = $("#mail").val();
		
		if (!mail.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
		valid += ' A valid Email'+isr;
		}
		
		if (valid!='') {
			$("#maildesc").fadeIn("slow");
			$("#maildesc").html("<span style='color:red'>Error:"+valid+"</span>");
		}else {
			var datastr ='mail=' + mail;
			$("#maildesc").css("display", "block");
			$("#maildesc").html("Signing up …. ");
			$("#maildesc").fadeIn("slow");
			setTimeout("send('"+datastr+"')",2000);
		}
		return false;
	});
	
	
	
	
});




// mailsignup send
function send(datastr){
$.ajax({
type: "POST",
url: "mailsignup.php",
data: datastr,
cache: false,
success: function(html){
$("#maildesc").fadeIn("slow");
$("#maildesc").html(html);
//setTimeout('$("#maildesc").fadeOut("slow")',2000);
}
});

}

// Events Link Handling
$("#upcomingevents a").attr("href", "events.php")
