
//preload submenu items images
var imgPreloadArr = new Array (
	"b-aboutus-a.gif",
	"b-lenders-a.gif",
	"b-developers-a.gif",
	"b-estate-a.gif",
	"b-buyers-a.gif",
	"b-sellers-a.gif",
	"b-contact-a.gif",
	"b-status-a.gif",
	"b-what-we-do-a.gif",
	"b-gmcr-at-work-a.gif",
	"b-our-attorneys-a.gif",
	"b-our-approach-a.gif",
	"b-career-opportunities-a.gif",	
	"b-snav-buyers-a.gif",
	"b-snav-contact-a.gif",
	"b-snav-developers-a.gif",
	"b-snav-estate-a.gif",
	"b-snav-lenders-a.gif",
	"b-snav-sellers-a.gif",
	"b-snav-status-a.gif"
);

var pageImages = new Array();

function preloadImages(imgArr, imagesPath)
{
	for (var i=0; i<imgArr.length; i++)
	{
		pageImages[i] = new Image();
		pageImages[i].src = imagesPath + imgArr[i];
	}
}

function addRollowers(itemId)
{
	var navItemAbout = document.getElementById(itemId);
	var links = navItemAbout.getElementsByTagName("A");
	for (var i=0; i<links.length; i++)
	{
		if (links[i].firstChild.id && links[i].firstChild.id == "current")
			continue;
		links[i].onmouseover = function ()
		{
			if(this.firstChild.id != "current")
			this.firstChild.src = this.firstChild.src.replace(".gif", "-a.gif");
		}
		links[i].onmouseout = function ()
		{
			if(this.firstChild.id != "current")
			this.firstChild.src = this.firstChild.src.replace("-a.gif", ".gif");
		}
	}
}

preloadImages(imgPreloadArr, "-images/");


//dynamic navigation
startList = function() {
	if (document.all&&document.getElementById) 
	{
		var navRoot = document.getElementById("top-navigation");
		for (i=0; i<navRoot.childNodes.length; i++)
		{
			var node = navRoot.childNodes[i];
			if (i == 0)
			{
				window.addfunc = (node.className == "current");
			}
			if (node.nodeName=="LI") 
			{
				node.onmouseover=function()
				{
					this.className+=" over";
					if (addfunc && this.className.indexOf("current") == -1)
						show_submenu(false);
				}
				node.onmouseout=function()
				{
					this.className=this.className.replace(" over", "");
					if (addfunc && this.className.indexOf("current") == -1)
						show_submenu(true);
				}
			}
		}
	}
	
	//add rollovers for submenu items
	addRollowers("about-sub");
	addRollowers("lenders-sub");
	addRollowers("developers-sub");
	addRollowers("agents-sub");
	addRollowers("buyers-sub");
	addRollowers("sellers-sub");
	addRollowers("status-sub");
}
window.onload=startList;


function show_submenu(is_show)
{
	var e = document.getElementById("about-sub");
	if (!e) return;
	if(is_show)
	{
		e.style.display = "block";
	}
	else
	{
		e.style.display = "none";
	}
}
