(function($){
var showdip = function(parent, options){
  this._class  = showdip;
  this.parent  = parent;
  this.test = this.parent.val();
  
  this.setupmouseenter();

};

showdip.fn = showdip.prototype;

showdip.fn.setupmouseenter = function(){
  this.parent.mouseenter($.proxy(function(){
  this.setpopup();

  }, this));
};

showdip.fn.setimg = function(img){
  this.setimg=img;
};


showdip.fn.setpopup = function(){

	var p =  this.parent;
	var pid =  this.parent.attr("id");
	var position = p.position();
	if(pid == "mpic1"){
	var popup = $("<img src='/images/menutop/"+ this.setimg +"' />");
	var poppositionT =  45;
	var poppositionL =  70;
	}
	else if(pid == "mpic2"){
		var popup = $("<img src='/images/menutop/"+ this.setimg +"' />");
	var poppositionT =  45;
	var poppositionL =  10;
	}
	else if(pid == "mpic3"){
		var popup = $("<img src='/images/menutop/"+ this.setimg +"' />");
	var poppositionT =  45;
	var poppositionL =  50;
	}
	else if(pid == "mpic4"){
		var popup = $("<img src='/images/menutop/"+ this.setimg +"' />");
	var poppositionT =  45;
	var poppositionL =  5;
	}
	else { 
		var popup = $("<img src='/images/menutop/"+ this.setimg +"' />");
	var poppositionT =  45;
	var poppositionL =  20;
	}
	
	popup.css({
			  "position":"absolute" ,
					 top: function(index, value) {
      			     return position.top + poppositionT;
     				 }, 
     				 left: function(index, value) {
       				 return position.left - poppositionL;
    				  }
					  
	 			 });
	$("body").append(popup);	
	
	  this.parent.mouseleave($.proxy(function(){
 		popup.remove();	
  }, this));
	  
};

$.fn.showdip = function(options, callback){
  return(new showdip(this, options));
};

window.showdip = showdip;

})(jQuery);
