// JavaScript Document

$(document).ready(init);

function init() {
	$('.mg-widget').each(function(idx){
	   classes = $(this).attr('class').split(' ');
       var _pos = classes[classes.length - 1].split('p')[1];
       
       var _local = $('#local').text();
       var target = $(this);
       $.post('widgets/',{page:_module, pos: _pos, local: _local?_local:0}, function(resp){
            if (resp.info = 'ok'){
                target.hide();
                target.html(resp.widget);
                target.fadeIn();
            }
       }, 'json');
	});
    $.post('widgets/weather/', {m:'min'},function(resp){
        if (resp.info == 'ok'){
            var a = $('#header-widget.weather').find('a.info');
            a.text(resp.str);
			a.attr('title',resp.str);
			a.fadeIn();
        }
    }, 'json');
}
