var home=
{
  init:function()
  {
    Cufon.replace('h1');
    Cufon.replace('h2');
    Cufon.replace('#titDestacado');
    Cufon.replace('#menu ul li a');
  }
};


window.onload=home.init;


$(document).ready(function(){
	$('ul.jd_menu').jdMenu({disableLinks:false});

    $('#navigation li.list').hover(function(){
        $(this).find(":first").addClass('hover');
    },function(){
        $(this).find(":first").removeClass('hover');
    });
});

var noticias=
{
    i:null,
    maxNews:3,
    init:function(maxNews)
    {
        this.maxNews=maxNews;
        this.showNews(1);//Muestra el primer elemento
        
        $("#news-directions .previous").click(function(){noticias.previous();return false;});
        $("#news-directions .next").click(function(){noticias.next();return false;});

        $("#news-pages a").click(function(){
            noticias.showNews($(this).html());
            return false;
        });
    },

    next:function()
    {
        if(noticias.i==noticias.maxNews)
        {
           noticias.showNews(1);
        }
        else
        {
            noticias.showNews(noticias.i+1);
        }
    },

    previous:function()
    {
        if(noticias.i==1)
        {
            noticias.showNews(noticias.maxNews);
        }
        else
        {
            noticias.showNews(noticias.i-1);
        }
    },

    showNews:function(num)
    {
        if(num!=noticias.i)
        {
            if(noticias.i!=null)
            {
                $('#news-'+noticias.i).hide();
            }

            $('#news-'+num).show();
            noticias.i=num;

            $('#news-pages a').removeClass('marcado');
            $('#news-pages #pag-'+noticias.i).addClass('marcado');
        }
    }
};
