$(document).ready(function(){
      $('#the_tabs > ul').tabs();
      //$('#gallery > ul').jqGalViewII();

      $('ul.thumbs a').each(function(){
          $(this).click(function(){
              $('#photo').addClass('loading');
              var link = $(this);
              var href = $(this).attr("href");
              $(this).removeAttr("href");
              $('#photo img').fadeOut('slow', function(){
                $('#photo img').remove();
                $('#photo').append('<img class="oo" style="display: none;" src="'+ href +'" />');
                $('img.oo').fadeIn(1000);
                $(link).attr("href", href);
              });
          });
      });

      $('div.vids a').each(function(){
          $(this).click(function(){
              $('span.nowplaying').removeClass('nowplaying');
              $(this).prev('span').addClass('nowplaying');
              $('img.playing').removeClass('playing');
              $(this).children().addClass('playing');
              $('#vid').addClass('loading');
              var link = $(this);
              var href = $(this).attr("href");
              $(this).removeAttr("href");
              $('#vid span').fadeOut('slow', function(){
                $('#vid').html('<span><object width="508" height="320"><param name="movie" value="http://www.youtube.com/v/'+href+'&hl=it&fs=1"></param><param name="wmode" value="opaque"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+href+'&hl=it&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" wmode="opaque" allowfullscreen="true" width="508" height="320"></embed></object></span>');
                $(link).attr("href", href);
              });
          });
      });

      $('#garro').each(function(index){
              $("a[@rel=ajax]").click(function() {
                    $(this).wrap('<div class="ajaxdiv"></div>');
            	    $('.ajaxdiv').load('?page_id=ajgldsp&obj_id='+ ($(this).attr("gal_id")) );
                    $('.ajaxdiv').removeClass('ajaxdiv');
              });
      });
     $('a[@rel=ajax]').eq(0)
        .trigger('click')
     .end();
});
