function parseCode(o){
  if(!$("#content").hascode){
      $.get (o.attr('href'),
        function(code) {
          $("#content").html('<code>'+code+'</code>');
          $("#content").hascode=true;
        }
      );
  }
  $("#content").show();
}

function hide_all() {
    $('a.codeExample').each (
      function( i ) {
        $('#content_'+i).hide();
      }
    )
}

$( document ).ready ( 
  function() {
    var image = new Image;
    image.src = 'new.gif';

    $('a.codeExample').click(function() {
     if ($('#content').attr('hide') == 0 && $('#content').attr('category') != $(this).attr('tag')) {
        $('a[tag='+$('#content').attr('category')+']').html(old);
        $("#content").hide();
        $('#content').attr('hide',1);
        $('#content').html('');
     }
     
     if ( $('#content').attr('hide') == 1) {
        old = $(this).html();
        $(this).html('Hide '+$(this).html());
        parseCode($(this));
        $('#content').show();
        $('#content').attr('hide',0);
        $('#content').attr('category', $(this).attr('tag'));
      } else {
        $(this).html(old);
        $("#content").hide();
        $('#content').attr('hide',1);
        $('#content').html('');
      }
      return false;
    }
    )
  }
)

