 
 /* Image preloading*/
 if (document.images)
{
    preload_image_object = new Image();
    image_url = ["/images/FJ_home_nav_bottom.gif",
				 "/images/FJ_home_nav_bottom_over.gif",
				 "/images/RCCC_home_nav_top.gif",
				 "/images/RCCC_home_nav_top_over.gif",
				 "/images/topnav01_out.gif",
				 "/images/topnav01_in.gif",
				 "/images/topnav02_out.gif",
				 "/images/topnav02_in.gif",
				 "/images/topnav03_out.gif",
				 "/images/topnav03_in.gif",
				 "/images/topnav04_out.gif",
				 "/images/topnav04_in.gif",
				 
				 "/images/RCCC_home_nav_feat_cs_bkg_over.gif",
				 "/images/media_out.gif",
				 "/images/media_in.gif",
				 "/images/calendar_out.gif",
				 "/images/calendar_in.gif",
				 "/images/logofront_48.jpg",
				 "/images/spot_03.jpg",
				 "/images/spot_04.gif"				 
				 ]
	for(var i=0; i<image_url.length; i++) preload_image_object.src = image_url[i];
}



var menusToClose = new Array();
function addTopNavBehavior(context){
	if (!context) context = document.getElementById("primaryNav");
	
	for(var i = 0; i < context.childNodes.length; i++){
		var n = context.childNodes[i];
		if (n.nodeName == "LI"){
			if(/MSIE (5|6)/.test(navigator.userAgent)){
				n.showSubMenu = showSubMenu;
				n.hideSubMenu = hideSubMenu;
				n.onmouseenter = function() { this.className = this.className.replace(new RegExp('\\s+hover', 'g'),''); this.className += " hover"; this.showSubMenu(event);};
				n.onmouseleave = function() { this.className = this.className.replace(new RegExp('\\s+hover', 'g'),''); this.hideSubMenu(event);};
			}else{
				n.onmouseover = showSubMenu;
				n.onmouseout = hideSubMenu;
			}
			
			//we could do this on the handlers, by testing the classname for equality, but
			// in ie 5/6 whatever:hover adds all kinds of hover-related classes, so it's
			// easier just to figure out if we should swap images here and check this bool later on.
			if (n.className.indexOf("about") == 0 || n.className.indexOf("community") == 0 || n.className.indexOf("connect") == 0 ||
				n.className.indexOf("visit") == 0 || n.className.indexOf("features") == 0 || n.className.indexOf("customerservice") == 0){
				n.swapImage = true;
			}
			
			var s = n.getElementsByTagName("OL")[0];
			if (s)addTopNavBehavior(s);
		}	
	}
	
}



function showSubMenu(e){	
	var subMenu = this.getElementsByTagName("OL")[0];
	if (!subMenu){
    subMenu = this.getElementsByTagName("DIV")[0];
     var imgs = subMenu.getElementsByTagName("IMG");
    for (i=0;i<imgs.length;i++){
      if (imgs[i].className == "productFeatureImage"){
        imgs[i].src = imgs[i].longDesc;
        break;
      }
    }
    //alert("longDesc:" + i.longDesc);
    //alert("longdesc:" + i.longdesc);
  }

	if (!e) var e = window.event;
	if (this.closeTimeoutID > 0) this.closeTimeoutID = 0;
	

	this.className = this.className.replace("open", "");
		 
	if (this.swapImage){
		 var img = this.getElementsByTagName("IMG")[0];
  img.src = img.src.replace("_out.", "_in.");
	}
	
	if (!subMenu) return;
	this.className += " open";
	subMenu.style.zIndex = 1; /* otherwise borders of sibling dropdowns cause problems */
		
	
	if (subMenu.offsetHeight < this.parentNode.offsetHeight) 
		subMenu.style.height = this.parentNode.offsetHeight-2 + "px";
		/* subtract two for borders */

}

function hideSubMenu(e){
	//find a submenu, or leave
	var subMenu = this.getElementsByTagName("OL")[0];
	if (!subMenu) subMenu = this.getElementsByTagName("DIV")[0];
	
	
	//figure out where the mouse is going to
	var relTarg = null;
	if (!e) var e = window.event;
	if (e.relatedTarget) relTarg = e.relatedTarget;
	else if (e.toElement) relTarg = e.toElement;
	
	//if it's going to one of my child elements, don't close anything
	while (relTarg != null && relTarg != this && relTarg.nodeName != 'BODY' && relTarg.nodeName != 'HTML')
		relTarg= relTarg.parentNode
	if (relTarg == this) return;
	
	//close this element in a bit
	/* leaving this in case ML decides he wants the delay again 
	try{
	
		this.closeTimeoutID = setTimeout("hideSubMenu_Internal()", 250);
		menusToClose.push(this);
	}catch (err){ /* ie5 fails */
		this.className = this.className.replace("open", "");
		if (subMenu) subMenu.style.zIndex = 0;
		if (this.swapImage){
		 	var img = this.getElementsByTagName("IMG")[0];
			img.src = img.src.replace("_in.", "_out.");
		}
	//}
}
	
	
function hideSubMenu_Internal(){	
	var li = menusToClose.shift();	
	
	if (li.closeTimeoutID > 0){	
		/*var subMenu = li.getElementsByTagName("OL")[0];
		if (!subMenu) subMenu = li.getElementsByTagName("DIV")[0];
		if (!subMenu) return;*/
	
		li.className = li.className.replace("open", "");		
		li.closeTimeoutID = 0;
	}
}


var topNav_oldOnload = window.onload;
window.onload = function(){	
	if (topNav_oldOnload) topNav_oldOnload(); 
	addTopNavBehavior(document.getElementById("primaryNav"));
	addTopNavBehavior(document.getElementById("featuresAndCSNavList"));
}

