// javascript will go here
$(function(){
		   
    // Specify the ZIP/location code and units (f or c)
    var loc = 'ARSF0011'; // or e.g. SPXX0050
    var u = 'c';

    var query = "SELECT item.condition FROM weather.forecast WHERE location='" + loc + "' AND u='" + u + "'";
    var cacheBuster = Math.floor((new Date().getTime()) / 1200 / 1000);
    var url = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + '&format=json&_nocache=' + cacheBuster;

    window['wxCallback'] = function(data) {
        var info = data.query.results.channel.item.condition;
        $('#wxIcon').css({
            backgroundPosition: '-' + (61 * info.code) + 'px 0'
        }).attr({
            title: info.text
        });
        $('#wxIcon2').append('<img src="http://l.yimg.com/a/i/us/we/52/' + info.code + '.gif" width="34" height="34" title="' + info.text + '" />');
        $('#wxTemp').html(info.temp + '&deg;' + (u.toUpperCase()));
    };

    $.ajax({
        url: url,
        dataType: 'jsonp',
        cache: true,
        jsonpCallback: 'wxCallback'
    });
	
	var barw = $('.bottom-bar').width();
	var barh = $('.bottom-bar').height();
	var winw = $(window).width()/2;
	var winh = $(window).height();
	$('.bottom-bar').css({ top:winh-barh+7, left:winw-barw/2, display:'inline' });
	
	$(window).resize(function(){
		var barw = $('.bottom-bar').width();
		var barh = $('.bottom-bar').height();
		var winw = $(window).width()/2;
		var winh = $(window).height();
		$('.bottom-bar').css({ top:winh-barh+7, left:winw-barw/2, display:'inline' });
	});
    
});


