/* Author: Alfonso Rivero
 * web: http://alfonsorv.com
 */

$(function () {
    var comentarios = $('.comentarios', this);
    comentarios.each(function ( ) {
        $(this).parents('div.box-content').data('inheight', $(this).height() );
        $(this).hide();
    });
    var vercoms = $('.vercomentarios');
    vercoms.each(function ( ) {
        $(this).data('inheight', $(this).height() );
        $(this).click(function (event) {
            event.preventDefault();
            var el = $('#commentarios-' + $(this).attr('id') );
            var container = el.parents('div.box-content');
            var cuanto = container.data('inheight');
            if(!el.is(":hidden")) {
                cuanto = cuanto * (-1);

                el.slideToggle( 'fast' , function(){
                    container.animate({height: container.height() + cuanto }, 500);
                });
            }else{
                container.animate({height: container.height() + cuanto }, 500,function(){
                    el.slideToggle( 'fast');
                });
            }

            

            //container.height( container.height() + cuanto );
            //el.slideToggle( 'fast' , function(){
                
            //});
        });
    });

    
    var detalles = $('.ofertadetalle');
    $("div#oferta-detalle").animate({width:"0"}, 1);
    detalles.each(function ( ) {
        $(this).click(function (event) {
            event.preventDefault();
            var detalle = $("div#oferta-detalle");
            detalle.animate({width:"440"}, 500, function(){
                $('#oferta-detalle-contenido').fadeIn('slow');
            });
            $('#oferta-detalle-contenido').load( $(this).attr('href') , function() {});
        });
    });

    $('#cerrar-detalle').click(function (event) {
        event.preventDefault();
        $('#oferta-detalle-contenido').fadeOut('fast' , function(){
            $("div#oferta-detalle").animate({width:"0"}, 500);
        });
    });



});
























