
this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 5;
		yOffset = 5;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";
		var _tempArray = this.t.split("|");	
										  
		$("body").append("<p id='tooltip'><span class='text1'>"+ _tempArray[0] +"</span><span class='text2'>"+ _tempArray[1] +"</span></p>");
		$("#tooltip")
			.css("top",(e.pageY + 5) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY + 5) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});
	
	// right hand side one
	
	$("a.tooltip_right").hover(function(e){											  
		this.t = this.title;
		this.title = "";
		var _tempArray = this.t.split("|");	
										  
		$("body").append("<p id='tooltip_right'><span class='text1'>"+ _tempArray[0] +"</span><span class='text2'>"+ _tempArray[1] +"</span></p>");
		$("#tooltip_right")
			.css("top",(e.pageY + 5) + "px")
			.css("left",(e.pageX - (225)) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip_right").remove();
    });	
	$("a.tooltip_right").mousemove(function(e){
		$("#tooltip_right")
			.css("top",(e.pageY + 5) + "px")
			.css("left",(e.pageX - (225)) + "px");
	});
	
	
	var popupStatus = 0; 
	
	/////
	$(".email_signup").click(function(e){											  
		this.t = this.title;
		this.title = "";
		
		e.stopPropagation();
		
		if(popupStatus == 1 )
		{ 	
			if(e.target.id != "email_popup" && e.target.id != "join_mail" && e.target.id != "popup_input" && e.target.id != "green_arrow")
			{
				$("#email_popup").remove();
				$(".email_signup").css("backgroundPosition", "0 0");
				popupStatus = 0;
			}
			popupStatus = 0;
		}
		else
		{
				
		var _tempArray = this.t.split("|");	
										  
		$(".email_signup").append("<p id='email_popup'><span class='join_mail' id='join_mail'>Join the Jacobson Mailing List</span><input type='text' class='input' id='popup_input'></input><a href='' class='green_arrow_link' id='green_arrow'><img src='/public/_images/public/green_arrow.gif'/></a></p>");
		$("#email_popup")
			.css("top",(25) + "px")
			.css("left",(- (170)) + "px")
			.css("position", "absolute")
			.fadeIn("fast");
		$(".email_signup").css("backgroundPosition", "0 -39px");
	
		
		if(popupStatus == 0)
		{
			$("body").click(function(e)
			{		
				if(e.target.id != "email_popup" && e.target.id != "join_mail" && e.target.id != "popup_input" && e.target.id != "green_arrow")
				{
					$("#email_popup").remove();
					$(".email_signup").css("backgroundPosition", "0 0");
					popupStatus = 0;
				}
		    });
		}
			popupStatus = 1;
		}
    });
};


this.menuHoverListener = function(){
	
	$(".email_signup").hover(function(e){
	  $(this).css("backgroundPosition", "0 -39px");
	},function(){
	  $(this).css("backgroundPosition", "0 0");
	});
		
};

// starting the script on page load
$(document).ready(function(){
	tooltip();
	//menuListener1();
	menuHoverListener();
});