//hoverIntent for delay of share pop-up close
(function($$){$$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

//modal for share
$$(document).ready(function() {	
	$$('a[name=share]').click(function(e) {
		e.preventDefault();
		var id = $$(this).attr('href');
		var maskHeight = $$(document).height();
		var maskWidth = $$(window).width();
		$$('#share-mask').css({'width':maskWidth,'height':maskHeight,'top':0, 'left':0}).fadeIn(0).fadeTo("slow",0.2);
		$$(id).slideDown(300); 
	});
	
	$$('#share-links a').click(function (e) {
		$$('#share-mask').hide();
		$$('#share-links').slideUp();
	});	
	
	$$('#share-mask').click(function () {
		$$(this).hide();
		$$('#share-links').slideUp();
	});	

	// when mouse is off the share box, it closes after a delay
	$$("#share-mask").hoverIntent(disappear,stay);
	$$("#share-mask").hoverIntent({
		sensitivity: 7, 
		interval: 1300, 
		over: disappear, 
		timeout: 500, 
		out: stay
	});
	
});

function disappear(){ $$(this).hide();$$('#share-links').slideUp() ;}
function stay(){ }

// share icons
function message() {
	var t = $$('h1').eq(0).text();   /*  grabs the title via h1 tag */
    var u = window.location.href;  /*  grabs the page url */
	var j = "Johnson %26 Johnson"
	var h = "JNJ.com"
	var message = document.write('<ul><li class="email"><a href="javascript:emailtoFriend()" title="E-mail to a Friend">E-mail to a Friend</a></li><li class="delicious"><a href="http://del.icio.us/post?url='+u+'&title='+t+'" title="Add to Delicious" target="_blank">Delicious</a></li><li class="digg" title="Digg this Page"><a href="http://digg.com/submit?phase=2&url='+u+'&title='+t+'" target="_blank">Digg</a></li><li class="diigo"><a href="http://www.diigo.com/post?url='+u+'&title=<?php the_title(); ?>" title="Share on Diigo" target="_blank">Diigo</a></li><li class="facebook" title="Share on Facebook"><a href="http://www.facebook.com/share.php?u='+u+'" target="_blank">Facebook</a></li><li class="linkedin"><a href="http://www.linkedin.com/shareArticle?mini=true&url='+u+'&title='+t+'" title="Share on LinkedIn" target="_blank">LinkedIn</a></li><li class="mixx"><a href="http://www.mixx.com/submit?page_url='+u+'" title="Share on Mixx" target="_blank">Mixx</a></li><li class="myspace"><a href="http://www.myspace.com/Modules/PostTo/Pages/?c='+u+'&t=<?php the_title(); ?>" title="Share on MySpace" target="_blank">MySpace</a></li><li class="twitter"><a href="http://twitter.com/home/?status='+u+'" title="Share on Twitter" target="_blank">Twitter</a></li><li class="yahoo"><a href="http://buzz.yahoo.com/buzz?targetUrl='+u+'&headline='+t+'" title="Share on Yahoo" target="_blank">Yahoo! Buzz</a></li></ul><br class="clear" /><p class="exit">By clicking on a link above, you will leave www.jnj.com. The terms-of-use and privacy policies on other sites may differ from those on www.jnj.com.</p>'); 
}
