var jQueryPopTimeout = false;
var POP_NAV_OPENER = false;
$.fn.jQueryPop = function() {
	this.mouseover(function(e){
		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;});}}
		function jQueryClearAll(){window.clearTimeout(jQueryPopTimeout);
				$("#jQueryPopNav").remove();$("body").unbind("mouseover",jQueryPopNavClose);}
		if(POP_NAV_OPENER!=false && POP_NAV_OPENER.id==this.id){return false;}
		var popNav = getPopNavigation(this.id);
		if(popNav.length>0){jQueryClearAll();
			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);});
		}
	});
};

/// 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 "navCommFeatures":
			popNav[0] = new Array("comm-feature01.html","Building Successful Communities");
		break;
		case "navManFeatures":
			popNav[0] = new Array("man-feature01.html","Big Facility Improvements for Manheim, PA");
			popNav[1] = new Array("man-feature02.html","Manheim Consulting: Accelerating Business");
		break;
		case "navPapFeatures":
			popNav[0] = new Array("pap-feature01.html","Making a Difference in 2006");
		break;
		case "navTVFeatures":
			popNav[0] = new Array("tv-feature01.html","Local Coverage Shines in Stormy Weather");
		break;
		case "navAutoFeatures":
			popNav[0] = new Array("auto-feature01.html","Cox's Newest Subsidiary");
			popNav[1] = new Array("auto-feature02.html","AutoTrader.com: Cox Auto Trader's Growth Engine");
			popNav[2] = new Array("auto-feature03.html","Auto Trader Publishing: Magazines and More");
			popNav[3] = new Array("auto-feature04.html","Auto Mart: Catering to Dealers");
		break;
		case "navRadioFeatures":
			popNav[0] = new Array("radio-feature01.html","Music, News & So Much More");
			popNav[1] = new Array("radio-feature02.html","Two Cox Teams/One Cox Market");
		break;
		default:
		//	popNav[0] = new Array('url', 'Text to Display');
		break;
	}
	return popNav;
}