﻿$(document).ready(function () {
    if ($("#weather").length > 0) {
        $("#weather").hide();
        $.ajax({ url: weatherAjaxUrl,            
            dataType: "jsonp",
            jsonp: "callback",
            jsonpCallback: "PopulateWeatherFromAjaxResponse"
        });
    }
});

function PopulateWeatherFromAjaxResponse(data) {

    $.each(data, function (i, item) {
        if (item.Max) {
            $("#maxTemp").html(item.Max);
        } else {
            $("#maxTemp").html('N/A');
        }

        $("#forecast").html(item.Text);        
        return false;
    });

    $("#weather").fadeIn();
}
