/**
* --------------------------------------------------------------------
 * jQuery-Plugin "hoverMenu"
 * Version: 1.0, 25.02.2009
 * by Matthias Wilhelm / mindconnect
 * http://www.mindconnect.com/
 *
 * Copyright (c) 2009 Mindconnect
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 */

(function($) {

	$.fn.hoverMenu = function(options) {

		jQuery("#bubble").ifixpng();
	
		// build main options before element iteration
		var opts = $.extend({}, $.fn.hoverMenu.defaults, options);
		// iterate and reformat each matched element
		var replaceRexExp=new RegExp(opts.search);

    return this.each(function() {

      	  var $this = $(this);
	      // build element specific options
		  
		  var image_src=$this.attr("src");
		  
		  var image_hov_src=image_src.replace(replaceRexExp,opts.replace);
		
		  var preload=new Image();
		  preload.src=image_hov_src;
		  
		
		$this.mouseover(function(){
		  	  var left=($this.offset().left+$this.width()-12);
			  
			 // console.log($this.offset().left+" "+$this.width());
			 // console.log($this.position().left+" "+$this.width());
			
			  jQuery("#bubble").css("left",left);
			  jQuery("#bubble").show();
			  $this.attr("src",image_hov_src);
			  //jQuery("#bubble").fadeIn("fast");
		}).mouseout(function(){
			  jQuery("#bubble").hide();
			  $this.attr("src",image_src);
		});

    });

  };

  //
  // private function for debugging
  //

  function debug($obj) {

    if (window.console && window.console.log)
      window.console.log('hilight selection count: ' + $obj.size());
  };


  //
  // plugin defaults
  //

  $.fn.hoverMenu.defaults = {
    search: '_p\\.',
    replace: '_a.'
  };

//
// end of closure
//

})(jQuery);
