 $(function() {
    $('.agregar-agenda').click(function(){
        if($(this).attr('href')=='1'){
            $(this).css('color','red');
            $(this).text('SACAR DE MI AGENDA');
            $(this).attr('href', '2');
            $(this).parent().css('background', 'url("/rsrc/images/plus-red-icon.png") no-repeat scroll 4px 50% transparent');
        }else{
            $(this).css('color','#96C211');
            $(this).text('AGREGAR A MI AGENDA');
            $(this).attr('href', '1');
            $(this).parent().css('background', 'url("/rsrc/images/plus-icon.png") no-repeat scroll 4px 50% transparent');
        }
        return false;
    })

    $('#some_name').click(function(){
        $(this).val('');
    })
    /*************************Agendas-Tabs***********************************/
    

    $('.agenda-ampliada-ul,.noticia-ampliada-ul').children().click(function(){
        var agenda = $(this);
        var link = $(this).children();
        
        $('.agenda-ampliada-ul,.noticia-ampliada-ul').children().each(function(){
           var child = $(this);
           child.attr('id', '');
        })
        
        if(link.attr('class') == 'video'){
            $('#mainmedia-image').hide();
            $('#video').show();
            $('#slideshow').hide();
            $('#mapa-canvas').hide();
        }else if(link.attr('class') == 'mapa'){
            $('#mainmedia-image').hide();
            $('#video').hide();
            $('#mapa-canvas').show();
            $('#slideshow').hide();
            if (GBrowserIsCompatible()) {
              map = new GMap2(document.getElementById("mapa-canvas"));
              geocoder = new GClientGeocoder();
              showAddress(link.attr('rel'));
            }
        }else if(link.attr('class') == 'fotos'){
            $('#mainmedia-image').show();
            $('#video').hide();
            $('#slideshow').show();
            $('#mapa-canvas').hide();
        }

        agenda.attr('id', 'here')
        return false;
    })



    
/**************************Votos***************************************/
    /*$('.votes').click(function(){
        var parent = $(this).parent();
        var votos = $(this).attr('href');
        parent.css('background-color', 'yellow');
        parent.fadeOut('fast', function(){
            votos = parseInt(votos);
            votos++;
            $(this).find("a").text(votos+' votos');
            $(this).find("a").attr('href', votos);
            parent.fadeIn('fast', function(){
                parent.css('background-color', 'white');
            });
        });
        return false;
    })*/
/********************Carrousel***************************/
    $(".slideshow").jCarouselLite({
        vertical: true,
        speed: 800,
        btnNext: ".downarrow",
        btnPrev: ".uparrow"
    });

    $(".slideshowmedia").jCarouselLite({
        visible: 3,
        speed: 800,
        btnNext: ".downarrow",
        btnPrev: ".uparrow"
    });

    $(".galleryBox").jCarouselLite({
        visible: 2,
        speed: 800,
        btnPrev: ".ver_mas_galerias_left",
        btnNext: ".ver_mas_galerias_right"
    });
/********************************************/
    $('.news-thumb').click(function(){
        var image = $(this).attr('href');

        $('#mainmedia-image').fadeOut('normal', function(){
            $('#loading').show();
            $('#mainmedia-image').attr('src', image).load(function(){
                $('#loading').hide();
                $('#mainmedia-image').fadeIn('normal');
            })
        })

        return false;
    });
    
    $('.noticia-ampliada-ul').children().click();
})
