$(document).ready( function() {
     $('#commentForm').bind( 'submit', function() { 
          if( $('#name').val() == '' || $('#comment').val() == '' ) {
               alert( 'Please enter missing form fields.' );
               return false;
          }
          $.ajax( {
               type: "POST",
               url: "addComment.php",
               dataType: "html",
               data: $('#commentForm').serialize(),
               success: function(msg){
                    $( 'ol' ).prepend( msg );
                    $('#commentForm').toggle('slow');
                    $('#commentForm #name, #commentForm #comment').val( '' );
               }
          } );
          return false;
     }); 
     $('#lightbox').bind( 'load', function() {
          $('#lightbox').toggle( 'slow' );
     } );
} );



function unLightBox() { 
     $('#lightbox').toggle( 
          'slow', 
          function() { 
               $('#lightbox').attr( 'src', 'images/blank.gif' ); 
          } 
     );
}



function showMe( image, width, height ) {
     var marginLeft = Math.round( width / -2 ) + 'px';
     var marginTop = Math.round( height / -2 ) + 'px';
     var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
     if( !isIE6 ) {
          $('#lightbox').css( 'marginLeft', marginLeft );
          $('#lightbox').css( 'marginTop', marginTop );
     }
     $('#lightbox').attr( 'width', width );
     $('#lightbox').attr( 'height', height );
     var src = 'antiAds/' + image + '.jpg';
     $('#lightbox').attr( 'src', src );
     
}



function commentToggle() {
     $('#commentForm').toggle( 'slow' );
     return false;
}

