function showHideTab(index,count,content_elementID,tab_elementID){
	for(var i=1;i<=count;i++){
		var className='';
		var display='none';
		if(i==index){
			display='block';className='active'
		}

		jQuery('#'+content_elementID+i).css('display',display);

		if(className===''){
		jQuery('#'+tab_elementID+i).removeClass()
		}
		else{
		jQuery('#'+tab_elementID+i).addClass(className)
		}
	}
}





function hideTab(tab_elementID,tab_num){jQuery('#'+tab_elementID+tab_num).css('display','none')}

function update(){windowHandle.document.open();windowHandle.document.write('<br />');windowHandle.document.close()}

function popUp(URL,h,w){
	var day=new Date();
	var id=day.getTime();
	var windowHandle=window.open(URL,id,'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width='+w+',height='+h+',left=0,top=0');
	if(!windowHandle.opener){
		windowHandle.opener=self
	}
	setTimeout(function(){
		update()
	},1000)
}

jQuery(function(){
	jQuery.fn.aToButton=function(){
		return this.each(function(){
			var btn=document.createElement('button');
			jQuery(btn).html(jQuery(this).html()).attr('href',jQuery(this).attr('href')||'').attr('class',jQuery(this).attr('class')||'').attr('title',jQuery(this).attr('title')||'').bind('click',function(e){location.href=jQuery(this).attr('href');return false});
			jQuery(this).replaceWith(btn)
			}
		)};
	externalLinks()
});

var MainNavTimeout;
var hideSubNav=function(hoverTab,hoverNav,selectNav){
	hoverNav.unbind("hover");
	window.clearTimeout(MainNavTimeout);
	MainNavTimeout=window.setTimeout(function(){
		hoverTab.removeClass("hover");
		hoverNav.hide();
		selectNav.show();
		jQuery("#subnav").removeClass("hover");
		jQuery("#subnav").addClass("current");
// begin joe's wonky temp patch
var tag=hoverTab.attr("title").replace(/\s/g,'');
		jQuery("#subNav_Homepage").css('display','block')
// end joe's wonk
	},1000)
};

var loadNav=function(){
	jQuery("#mainnav li a").each(function(){
		var currentTabTag=jQuery("#mainnav li a.current").attr("title");
		var selectNav=jQuery("#subNav_"+currentTabTag);
		var hoverNav=jQuery("#subNav_Empty");
		jQuery(this).hover(function(){
			var hoverTab=jQuery(this);
			var isSelected=hoverTab.hasClass("current");
			var tag=hoverTab.attr("title").replace(/\s/g,'');
			if(jQuery("#subNav_"+tag).length){
				hoverNav=jQuery("#subNav_"+tag)
			}
			window.clearTimeout(MainNavTimeout);
			hoverNav.unbind("hover");
			hoverTab.parent().siblings().children().removeClass("hover");
			hoverTab.addClass("hover");
			hoverNav.siblings("*:visible").hide();
			hoverNav.show(0);
			hoverNav.parent().hover(function(){
				window.clearTimeout(MainNavTimeout)
			},
			function(){
				hideSubNav(hoverTab,hoverNav,selectNav)
			});
			if(!isSelected){
				jQuery("#subnav").removeClass("current");
				jQuery("#subnav").addClass("hover")
			}
			else{
				jQuery("#subnav").removeClass("hover");
				jQuery("#subnav").addClass("current")
			}
		},
		function(){
			var hoverTab=jQuery(this);
			var tag=hoverTab.attr("title").replace(/\s/g,'');
			if(jQuery("#subNav_"+tag).length){
				hoverNav=jQuery("#subNav_"+tag)
			}
		hoverNav.unbind("hover");
		hideSubNav(hoverTab,hoverNav,selectNav);
		hoverNav.parent().hover(function(){
			window.clearTimeout(MainNavTimeout)
				},
			function(){
				hideSubNav(hoverTab,hoverNav,selectNav)
			}
		)}

	)}
)};

