//imgvwr.js 
//a huge thanks goes out the G

//welcome to jquery...the line below basically says don't run me till the page is done setting up the dom 
jQuery(document).ready(function() {
  // put all your jQuery goodness in here.
  // get source when page is loaded
  var original_src = jQuery("#imgvwrFeature img").attr("src"); 
  var original_icon;
    // now lets setup the hover logic using jquery and CSS selectors!
    jQuery("#icons a img").hover(
      // Mouse over
      function () {
        // these vars will use the image you hover on "this" 
        // and attach a suffix modifier to the name to make it featured
        var feature_suffix = "_big";
        var icon_suffix    = "_bw";
        var this_img       = this.src.substring(0,this.src.length-4); //sharedLogic
        var this_img_type  = this.src.substring(this.src.lastIndexOf("."),this.src.length); //sharedLogic
        var featured_image = this_img + feature_suffix + this_img_type;
        var icon_image     = this_img + icon_suffix + this_img_type;    
        // if the hovered image is already black and white then bail out
        if ( jQuery(this).hasClass('dude') ) {
          // alert('dude is true');
          } else { // continue 
	  // reset the bw image to the original icon
          if ((typeof original_icon != 'undefined')){
          jQuery("#icons a img.dude").attr("src",original_icon);	
          }	
          // reset the border on active image		          
          jQuery("#icons a img.dude").toggleClass("dude");
          // set the original icon to this icon
	  original_icon = jQuery(this).attr("src");
          // set active hover
	  jQuery(this).attr("src", icon_image);
	  jQuery(this).toggleClass("dude");
	  // now do the src swap for the feature
	  jQuery("#imgvwrFeature img").attr("src", featured_image);
          };
        },
        // Mouse out
        function () {
        // HAHA, shit, we don't even need to do anything now
        }
      );
}); //closes document dot ready

