var jQueryPopTimeout = false;
var POP_NAV_OPENER = false;
$.fn.jQueryPop = function() {
	this.mouseover(function(e){
		if(POP_NAV_OPENER!=false && POP_NAV_OPENER.id==this.id){return false;}
		var popNav = getPopNavigation(this.id);
		if(popNav.length>0){
			window.clearTimeout(jQueryPopTimeout);
			$("#jQueryPopNav").remove();
			POP_NAV_OPENER = this;
			var html = '<div id="jQueryPopNav"><ul>';
			for(var i=0;i<popNav.length;i++){html += '<li><a href="'+popNav[i][0]+'">'+popNav[i][1]+'</a></li>';}
			html += '</ul></div>';
			$("body").append(html);
			var pos = function(){var obj = POP_NAV_OPENER;var curleft = curtop = 0;
				if (obj.offsetParent){curleft = obj.offsetLeft;	curtop = obj.offsetTop;
					while (obj = obj.offsetParent){ curleft += obj.offsetLeft;	curtop += obj.offsetTop}}
					return [curleft,curtop];};
			$("#jQueryPopNav").css({position:"absolute",left:pos()[0]+"px",top:pos()[1]+POP_NAV_OPENER.offsetHeight+"px"});
			$("#jQueryPopNav li").hover(
				function(){$(this).addClass("jQueryPopNavHover");},
				function(){$(this).removeClass("jQueryPopNavHover");});
			//$("#jQueryPopNav li").bind("click",
			//	function(){var href = $(this).children("a").attr("href");window.location = href;});
			$("#jQueryPopNav").fadeIn("fast",function(){jQueryPopTimeout = window.setTimeout(function(){$("body").bind("mouseover",jQueryPopNavClose);},1000);});
			function jQueryPopNavClose(e){var l = $(e.target).parents("#jQueryPopNav").length;
				if(l==0 && e.target.parentNode.id!=POP_NAV_OPENER.id && e.target.id!=POP_NAV_OPENER.id && e.target.id!='jQueryPopNav'){
					$("#jQueryPopNav").fadeOut("fast",function(){$("#jQueryPopNav").remove();
						$("body").unbind("mouseover",jQueryPopNavClose);window.clearTimeout(jQueryPopTimeout);
						POP_NAV_OPENER = false;});}}
		}
	});
};
/// SET UP POP MENU'S HERE RELATED TO THE ID OF THE ELEMENT
function getPopNavigation(id){
	popNav = new Array();
	switch(id){
		/// CASE = THE id OF THE ELEMENT AND THE POPNAV ARRAY TO ASSOCIATE IT TO.
		case "nav_about":
		//	popNav[0] = new Array('url', 'Text to Display');
			popNav[0] = new Array('/advisoryCouncil.php','Advisory Council');
			popNav[1] = new Array('/location.php','Location');
			popNav[2] = new Array('http://www.shelteringarmsforkids.com/news.html" target="_blank"','Newsroom');
			popNav[3] = new Array('/pdr.php','Professional Development Resources');
			popNav[4] = new Array('/facultyStaff.php','Staff &amp; Faculty');
		break;
		case "nav_fdt":
			popNav[0] = new Array('/fdc.php','Family Development Credential');
			popNav[1] = new Array('/consulting.php','Consulting and Technical Assistance');
			popNav[2] = new Array('/whatStudentsSay.php','What Students Are Saying');
		break;
		case "nav_ect":
			popNav[0] = new Array('/cdac.php','Child Development Associate Credential');
			popNav[1] = new Array('/consulting.php','Consulting and Technical Assistance');
			popNav[2] = new Array('/whatStudentsTell.php','What Students Are Saying');
		break;
		default:
		//	popNav[0] = new Array('url', 'Text to Display');
		break;
	}
	return popNav;
}