$(function(){
    // $('.tabbed').tabs();
    $('.slider').easySlider();
    //$('.feedslider').easySlider({pause: 2400, continuous: true, controlsShow: true, vertical: false,auto: true, prevId: 'feedPrevBtn', nextId: 'feedNextBtn'});

    //$('.twittslider').easySlider({pause: 1900, continuous: true, controlsShow: false, vertical: false,auto: true, prevId: 'feedPrevBtn', nextId: 'feedNextBtn'});
    $('.twittslider').contentFade({pause: 25000, progressBar: 'progressbar'});
    $('.feedslider').contentFade({pause: 25000, progressBar: 'progressbar2'});
    $('.lightbox a').lightBox();
    
    $('.showcase ul.menu a').click(function(){
        var clicked = this.href.split('#')[1];
        var selected = this;
        if( !clicked || $(this).hasClass('selected') ) return false;
        /*
        $('#showcase ul.menu a.selected').fadeOut({backgroundColor: '#ffffff'},200, function(){
        	$(selected).animate({backgroundColor:'#EF3E42'}, 200).addClass('selected');
        }).removeClass('selected'); */ 
        $('#showcase div.selected').removeClass('selected').animate({opacity:'hide'}, 200, function(){
        	var slide = $('#'+clicked);
            slide.addClass('selected').fadeIn(200);
            //var child = slide.find('div.left div.grid_4');
            //child.css({marginTop: ((slide.height()-child.height())/2)+'px'});
        });
        $('#showcase ul.menu a.selected').animate({backgroundColor: '#ffffff', color: '#1A1A1A'}, 200,function(){
        	$(selected).animate({backgroundColor: '#EF3E42', color: '#ffffff'}, 200).addClass('selected');
        }).removeClass('selected');
        
        return false;
    });

    /*
    $('.showcase a.selected').dropShadow({left:2, right:0, top: 2, bottom: 4});
    var slide = $('.showcase div.selected');
    slide.dropShadow({left:2, right:4, top: 2, bottom: 4});
    var child = slide.children('div.left');//.css({paddingTop: ((h-child.height())/2)+'px'});
    child.css({paddingTop: ((slide.height()-child.height())/2)+'px'});
    */
    //var slide = $('.showcase div.selected');
    //var child = slide.find('div.left div.grid_4');
    //child.css({marginTop: ((slide.height()-child.height())/2)+'px'});
    
    $(".accordion").accordion({autoHeight: false});

    $(".text-list .text-item").hover(function(){
    	$(this).find('.title h2').addClass('selected');
    },function(){
    	$(this).find('.title h2').removeClass('selected');
    });
    
    /* por ahora sólo comento esto
    $('#navbar li a').hover(function(){
        var actor = this.getElementsByTagName('span')[0];
		if( $(this).hasClass('selected') ) {
	        $(actor).animate({top: '0px', height: '110px'}, 100).animate({height: '10px'}, 100);
		} else {
	        $(actor).animate({height: '110px'}, 100).animate({height: '10px', top: '100px'}, 100);
		}
        $(this).css({ color: '#ef3e42'});
    }, function(){
        var actor = this.getElementsByTagName('span')[0];
		if( $(this).hasClass('selected') ) {
	        $(actor).animate({height: '110px'}, 100).animate({height: '10px', top: '100px'}, 100);
	        $(this).css({ color: '#ef3e42'});
		} else {
	        $(actor).animate({top: '0px', height: '110px'}, 100).animate({height: '10px'}, 100);
	        $(this).css({ color: '#1a1a1a'});
		}
    });
	*/
    $('#subscriptors-form').ajaxForm({target: '#subscriptors'});
    
    $(".twoCols").columnize({columns: 2, balance: true, column: 'grid_3'});
    $(".threeCols").columnize({columns: 3, balance: true, column: 'grid_2'});
    
    $(document).pngFix();
    
    $('.twitt-this').hover(function(){
    	$(this).css({backgroundPosition: '0 -40px'});
    	$('.twitt-this ~ .bubble:first').css({opacity: '0'}).show().animate({opacity: '.95'},400);
    }, function(){
    	setTimeout(function(){
        	$(this).css({backgroundPosition: '0 0'});
        	$('.twitt-this ~ .bubble:first').animate({opacity: 0}, 400).hide('slow');
    	}, 15000);
    })
    
});
