/**
 * TikiCMS
 * Copyright (C) 2009, Tiki Web Inteligente Ltda.
 * @requires jQuery 1.3.2 or latter
 *
 * $Id: application_controller_home.js 113 2010-03-10 18:24:09Z caio $
 */

Application.Controller.Home = (function() {

    // gambiarra enquanto não consigo mandar o objeto jQuery como argumento desta função
    var $ = jQuery;

    function index() {

        $.getJSON(Application.build_url('noticias.json'), function(data) {

            if (data.resultSet && !data.msgErro) {

                var htmlNoticias = '';
                
                for (var i = 0, length = data.resultSet.length; i < length; i++) {

                    var titulo = data.resultSet[i].titulo;
                    var url = data.resultSet[i].url;

                    htmlNoticias += '<li><a href="'+url+'" target="_blank">'+titulo+'</a></li>';
                }

                $('.noticiasLista').html(htmlNoticias).children(':last').addClass('last-child');
                $('#area_noticias').show();
            }
        });
    }

    return {
        'index': index
    };
})();

