// STUPID jQUERY TRICKS!
// WRITTEN BY J. JEFFERS EXCEPT WHERE CREDIT IS GIVEN.
// IF YOU LIKE THESE TAKE THEM AS YOUR OWN AND MAKE THEM WORK FOR YOU!
$(document).ready( function() {
   // Halftone / Interactive Image Trick
   $('#primaryContent .entry .description img').each( function() {
       var link_target = '#';
       var image = $(this);
       if(image.parent().get(0).tagName == "A") {
           link_target = image.parent().get(0).href;
           var new_image = image.clone();
           image.parent().before(new_image);
           image.parent().remove();
           image = new_image;
       }
       if(image.parent().get(0).tagName == "P") {
          image.parent().addClass('halftone');
       } else {
          image.wrap('<p class="halftone"></p>');
       }
       image.after('<span></span><a class="image_nav" href="'+link_target+'">'+this.alt+'</a>');
       image.parent().hover(
         function(){
            $(this).find('a.image_nav').slideDown("fast");
            $(this).find('span').fadeOut("fast");
         },
         function(){
            $(this).find('a.image_nav').slideUp("fast");
            $(this).find('span').fadeIn("fast");
         }
       );
       if(link_target != "#") {
          image.parent().click(function(){
              window.open($(this).find('a.image_nav').get(0).href);
              return false;
           });
       } else {
          image.parent().addClass('no-cursor');
       }
       if(image.width() > 150) {
          image.parent().css("width",image.width());
       }
   });
});