$(document).ready(function(){
    $('#recommendBox li a').bind('mouseover', Recommend.load);
});

var Recommend = {

    load: function(e) {

  	    var id = $(this).attr('id').split('-').pop();

  	    if ($('#recommend-'+id).attr('class') != "current") {
  	        $('#fotoBoxImage').stop(true, true);
            $('#fotoImg').stop(true, true);
            $('#fotoBoxContent h3').stop(true, true);
            $('#fotoBoxContent p').stop(true, true);
            $('#fotoBoxMore').stop(true, true);
            $('#fotoBoxImage, #fotoBoxContent').stop(true, true);

            $('#fotoBoxImage').fadeOut('normal', function(){
    			Recommend.setContent(id);
    		});

    		for (var item in homepageNews) {
                $('#recommend-' + item.split('-').pop()).removeClass('current');
            }

            $('#recommend-'+id).addClass('current');

            $('#fotoBoxContent').fadeOut('normal');
  	    }

        return false;
    },

    setContent: function(newsID) {

		var news = homepageNews['news-'+newsID];

        $('#fotoBoxImage').attr('src', news.image);
        $('#fotoImg').attr('href', news.link);
        $('#fotoBoxContent h3').html('<a href="'+news.link+'">'+news.title+'</a>');
        $('#fotoBoxContent p').html(news.description);
        $('#fotoBoxMore').attr('href', news.link);
        $('#fotoBoxImage, #fotoBoxContent').fadeIn();
        return false;
    }
};