var actual='';
var primero=true;
var scrolling=false;
var anchoboton=223;
var ancho = {'noticias':'480','agenda':'770','mixtapes':'600','galeria':'550','enlaces':'190'}

function show(b)
{
    if (scrolling) return false;
    
    scrolling=true;
    if (actual==b)
    {
        // lo escondo
        actual='';
        jQuery('#contenido_'+b).css('z-index','90');
        contenido(b, false);
    }
    else
    {
        // veo si ya hay uno abierto.
        if (actual!='')
        {
            // lo escondo.
            jQuery('#contenido_'+b).css('z-index','90');
            contenido(actual,false);
        }
        // muestro el que clickee.
        mostrar(b);
        actual=b;
        

    }
    
    return false;
}

function mostrar(b)
{
    if (jQuery('#fondo_'+b).css('width').replace('px','')<parseInt(ancho[b]))
    {
        jQuery('#fondo_'+b).css('width',parseFloat(jQuery('#fondo_'+b).css('width').replace('px',''))+10);
        if (parseFloat(jQuery('#fondo_'+b).css('width').replace('px',''))==parseInt(ancho[b]))
        {
            scrolling=false;
            contenido(b, true);
        }
        else
            setTimeout("mostrar('"+b+"')",1);
    }
}

function esconder(b)
{
    if (jQuery('#fondo_'+b).css('width').replace('px','')>0)
    {
        jQuery('#fondo_'+b).css('width',parseFloat(jQuery('#fondo_'+b).css('width').replace('px',''))-10);
        if (parseFloat(jQuery('#fondo_'+b).css('width').replace('px',''))==0)
        {
            scrolling=false;
        }
        else
            setTimeout("esconder('"+b+"')",1);
    }
}

function contenido(b, desplegar)
{
    scrolling=true;
    if (desplegar)
        jQuery('#contenido_'+b).slideDown(0,function(){scrolling=false;jQuery('#contenido_'+b).css('z-index','200');})
    else
        jQuery('#contenido_'+b).slideUp(0,function(){scrolling=false;esconder(b);})
}

jQuery(document).ready(function()
{
    jQuery("a[href='#top']").click(function()
    {
        jQuery("html").animate({ scrollTop: 0 }, "slow");
        return false;
    });

    jQuery('#contenido_mixtapes ul li:last').css('border','0px');

    jQuery('.boton_menu').click(function(){
		if (!primero)
			show(jQuery(this).attr('href'));
        return false;
    });

    jQuery('#contenido_noticias .nav a').live('click', function(){
        jQuery("html").animate({ scrollTop: 0 }, "slow");
        jQuery('#contenido_noticias').html('<img src="' + ssd + '/images/cargando.gif" />');
        jQuery('#contenido_noticias').load(jQuery(this).attr('href'));
        return false;
    });

    jQuery('a.arma_galeria').click(function(){
        jQuery('#galeria').load(jQuery(this).attr('href'),function()
        {
			jQuery("#galeria a.imagenes_galeria").fancybox({
				'transitionIn'	:	'elastic',
				'transitionOut'	:	'elastic',
				'speedIn'		:	600, 
				'speedOut'		:	200, 
				'overlayShow'	:	false,
				'cyclic'		:	true
				
			});
            jQuery('#galeria a.imagenes_galeria:eq(0)').click();
        });
        return false;
    });
	

    jQuery('#contenido_mixtapes ul li a').attr('target','_blank');

    jQuery(".agenda_pop").fancybox({
            'transitionIn'	:	'elastic',
            'transitionOut'	:	'elastic',
            'speedIn'		:	600,
            'speedOut'		:	200,
            'overlayShow'	:	false,
            'cyclic'		:	true

    });

});


