$( document ) . ready ( 
  function() {
    $('a.codeExample').each (
      function( i ) {
        $( this ).after( '<pre class="codeExample"><div></div></pre>' );
      }
    )
    $( 'pre.codeExample' ).hide();
    $('a.codeExample').toggle ( 
      function() {
		if( !this.old ){
		  this.old = $(this).html();
		}
        $(this).html('Hide Code');
        parseCode(this);
      },
      function() {
        $(this).html(this.old);
        $(this.nextSibling).hide();
      }
    )
    function parseCode(o){
      if(!o.nextSibling.hascode){
          $.get (o.href,
            function(code){

              o.nextSibling.innerHTML='<div>'+code+'</div>';
              o.nextSibling.hascode=true;
            }
          );
      }
      $(o.nextSibling).show();
    }
  }
)
