var comment = 0;
var __imgs  = [];


function getGroupItems(opts){
   $.each(__imgs[opts.o.id], function(i, val) {opts.itemArray.push(val);});
}

$(function(){

    $('table.art_bottom').find('td:last').css({border: '0'});
    $('table.xpages').find('td:last').attr('width', '100%').attr('align', 'right');

    $('table.art_bottom').wrap('<div class="tabbo">');
    $('table.art_bottom').wrap('<div class="taggo">');
    $('table.art_bottom td').attr('nowrap', 'nowrap');

    $('.l-search').wrap('<div class="laggo">');
   // $('div.pages strong').cornerz({border: 1, radius:10});
   // $('div.pages').cornerz({border: 1, radius:14});
   // $('table.art_bottom').cornerz({border: 1, radius:11});

    $("a#post_comment").mouseup(function(){comment = $(this).metadata();}).fancybox({'zoomSpeedIn': 0, 'zoomSpeedOut': 0, 'overlayShow': true});
    $("a#insert_image").fancybox({'zoomSpeedIn': 0, 'zoomSpeedOut': 0, 'overlayShow': true});
    $("a.answer_comment").mouseup(function(){comment = $(this).metadata();}).fancybox({"zoomSpeedIn": 0, "zoomSpeedOut": 0, "overlayShow": true});

    $("span.bigspan").each(function(){

                var image = $(this).parent().find("img");

                $(this).css("position", "absolute");
                $(this).css("cursor"  , "pointer");
                $(this).css("top"     , $(image).offset().top   + "px");
                $(this).css("left"    , $(image).offset().left  + "px");
                $(this).css("width"   , $(image).width()  + "px");
                $(this).css("height"  , $(image).height() + "px");

           });

    $("a.bigimg").fancybox({'itemLoadCallback': getGroupItems, 'overlayShow': true})
                 .mouseover(function(){$(this).find('span').addClass("imageOver");})
                 .mouseout(function(){$(this).find('span').removeClass("imageOver");});;

    $(".a-what").click(
       function(){
          $(this).parent().find('div.hide-c').show();
          $(this).hide();
          return false;
       }
    );

    $(".voice_ok").click(function(){
        var id = parseInt($(this).parent().attr('id').replace('fvoice_', ''));
        var post = $('#fvoice_' + id).serialize();
        $('#fvoice_' + id).html('<img src="/js/loading.gif" class="white">');
        $('#voice_' + id).load('/ajax/do/voice', {id:id, data:post});
    });

    $(".voice_err").click(function(){
        var id = parseInt($(this).parent().attr('id').replace('fvoice_', ''));
        $('#fvoice_' + id).html('<img src="/js/loading.gif" class="white">');
        $('#voice_' + id).load('/ajax/do/voice', {id:id});
    });

    $("#btnprev").click(function(){
         $('#preview').text($(this).parent().parent().find('textarea').text());
    });
        // Только для шаблона red
       /* var main = $('#main');
        var p = $(main).offset();
        var w = $(main).width()+19;
        var h = $(main).height()+20;
        $('#shadow').css('top', p.top-10);
        $('#shadow').css('left', p.left-10);
        $('#shadow').css('height', ($(main).height()+20) + 'px');


        var so = new SWFObject('/themes/red/shadow.swf', 'shadow2',  w, h, '9', '#000000');
        so.addParam('menu', 'false');
        so.addParam('wmode', 'transparent');
        so.write('shadow');
        //  */

    if(location.hash){
       var comm = location.hash.replace('#comment', '');
       if(comm&&comm!=''&&parseInt(comm)){
         $("a[name=comment"+comm+"]").parent().parent().parent().parent().addClass('curr-comm');

       }
    }

});

