var slide = new Array;
$(document).ready(function(){


    $('.slide-item').click(function(){
        var id = $(this).attr('id');
        var height = $('.' + id).css('max-height');
       if(height == 'none'){
            $('.' + id).css('max-height',slide[id]);
            $(this).html('&darr;развернуть');
       } else {
            slide[id] = height;
            $('.' + id).css('max-height','none');
            $(this).html('&uarr;свернуть');
       }
    });

    $('.slide-description').live('click', function(){
        var id = $(this).attr('id');
        $('.anchor-description-' + id).css('max-height','none');
        $(this).detach();
        $('.opacity-'+id).detach();

    });
    $('.slide-item-simple').click(function(){
        $(this).parent().parent().children('.hide').removeClass('hide');
        $(this).parent().detach();
    });


    $('.slide-description-container').each(function(){
        var height = $(this).height();
        var maxheight = $(this).css('max-height');

        var reg=/.*anchor-description-([a-zA-Z0-9]+).*/
        var item=reg.exec($(this).attr('class'));

        if(parseInt(maxheight) > height) return;
        $(this).after('<div class="slide-opacity opacity-' + item[1] + '"></div><div id="' + item[1] + '" class="slide-description">&darr;подробнее</div><br class="clear" />');
    });

    /* slide */
   $('.slide-item-auto').each(function(){
        var id = $(this).attr('id');
        var height = $('.' + id + ' p:first-child').height();
        
        if(height == null) return;
        $('.' + id).css('max-height',height + 5);
    });

    /* region */
   $('#region-change #region-anchor').click(function(){
       if($('#region-change .region-sub-container').is(':visible')) return false;
       
        $('#region-change .region-sub-container')
        .html('<iframe src="' + $(this).attr('href') + '" frameborder="0"></iframe>')
        .show();
        return false;
    });
});



