
var is_IE = '\v'=='v';

function cientifico(sube,count){
    if (count==10){ $('#bocadillo, #participad, #cientifico, #sombra img').stop().attr('style',''); count=0; }
    var top = sube? '-=20' : '+=20'; time = 1500 + Math.floor(Math.random()*1000);
    $('#bocadillo, #participad, #cientifico').stop().animate({'top':top},time);
    $('#sombra img').stop().animate({'width':top},time);
    setTimeout('cientifico('+!sube+','+(count+1)+')',time);
}

$(document).ready(function(){
    $('body').addClass('js');
    if (is_IE) $('body').addClass('ie');

    cientifico(false,0);

    $('#social a span, #atajos a span, #comparte a span').width(0);
    $('#social a, #atajos a, #comparte a').hover(
        function(){ $(this).children().stop().animate({'width':$(this).width()},200); },
        function(){ $(this).children().stop().animate({'width':0},400); }
    );

    $('a.blank, a[rel=external]').attr('target','_blank');

    $('.votos .star').rating({
        required: true,
        callback: function(value, link){
            $parent = $(this).parent();
            $parent.find('div').unbind().addClass('star-rating-readonly');
            $parent.find('span.vota').html('...');
            $.post("votar.php",{'name':$(this).attr('name'),'nota':value},function(data){
                if (data == -1) $parent.find('.vota').html('ya has votado');
                else if (data == 0) $parent.find('.vota').html('error');
                else $parent.find('.vota').html('gracias');
            });
        }
    });
    $('#votar').hide();

    $('.video a').flash(
        {height:208, width:320}, {version:8},
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.src = $this.attr('href').replace('watch?v=','v/');
            $this.before($.fn.flash.transform(htmlOptions));
        }
    ).addClass('replaced');

});
