//
// Preload the images for smoother mouseOver operation
//
// The portal page's main image
var imgWelcome    = new Image(); imgWelcome.src    = "images/portalWelcome.jpg";
var imgCustom     = new Image(); imgCustom.src     = "images/portalCustomHomes.jpg";
var imgCommercial = new Image(); imgCommercial.src = "images/portalCommercial.jpg";
var imgSite       = new Image(); imgSite.src       = "images/portalSite.jpg";
var imgProperties = new Image(); imgProperties.src = "images/portalProperties.jpg";
//
// The left nav links
var imgCustomLinkOff     = new Image(); imgCustomLinkOff.src     = "images/portalLink_CustomHomes_Off.jpg";
var imgCustomLinkOn      = new Image(); imgCustomLinkOn.src      = "images/portalLink_CustomHomes_On.jpg";
var imgCommercialLinkOff = new Image(); imgCommercialLinkOff.src = "images/portalLink_Commercial_Off.jpg";
var imgCommercialLinkOn  = new Image(); imgCommercialLinkOn.src  = "images/portalLink_Commercial_On.jpg";
var imgSiteLinkOff       = new Image(); imgSiteLinkOff.src       = "images/portalLink_Site_Off.jpg";
var imgSiteLinkOn        = new Image(); imgSiteLinkOn.src        = "images/portalLink_Site_On.jpg";
var imgPropertiesLinkOff = new Image(); imgPropertiesLinkOff.src = "images/portalLink_Properties_Off.jpg";
var imgPropertiesLinkOn  = new Image(); imgPropertiesLinkOn.src  = "images/portalLink_Properties_On.jpg";

//-----------------------------------------------------------------------------
// inputs
//  - imgIndex : int indicating which imgs to display
//  - mainImgTagID : str representing the unique ID of the page's Main Img tag
//  - linkImgElmt : the left nav link Img Object
//
// Swaps the Main Img & Nav Link Img depending on the Nav Link the user has
// moused over.
//-----------------------------------------------------------------------------
function swapImg( imgIndex, mainImgTagID, linkImgElmt )
{
	var imgTag = document.getElementById( mainImgTagID );
	
	if ( imgIndex == 1 )
	{
		imgTag.src = imgCustom.src;
		
		if ( linkImgElmt.src.indexOf("_Off") == -1 )
		{
			linkImgElmt.src = imgCustomLinkOff.src;
		}
		else
		{
			linkImgElmt.src = imgCustomLinkOn.src
		}
	}
	else if ( imgIndex == 2 )
	{
		imgTag.src = imgCommercial.src;
		
		if ( linkImgElmt.src.indexOf("_Off") == -1 )
		{
			linkImgElmt.src = imgCommercialLinkOff.src;
		}
		else
		{
			linkImgElmt.src = imgCommercialLinkOn.src
		}
	}
	else if ( imgIndex == 3 )
	{
		imgTag.src = imgSite.src;
		
		if ( linkImgElmt.src.indexOf("_Off") == -1 )
		{
			linkImgElmt.src = imgSiteLinkOff.src;
		}
		else
		{
			linkImgElmt.src = imgSiteLinkOn.src
		}
	}
	else if ( imgIndex == 4 )
	{
		imgTag.src = imgProperties.src;

		if ( linkImgElmt.src.indexOf("_Off") == -1 )
		{
			linkImgElmt.src = imgPropertiesLinkOff.src;
		}
		else
		{
			linkImgElmt.src = imgPropertiesLinkOn.src
		}
	}
	else
	{
		// The user has moused out.  Return to the default image.
		imgTag.src = imgWelcome.src;
		
		if ( linkImgElmt.src.indexOf("CustomHomes") != -1 )
		{
			linkImgElmt.src = imgCustomLinkOff.src;
		}
		else if ( linkImgElmt.src.indexOf("Commercial") != -1 )
		{
			linkImgElmt.src = imgCommercialLinkOff.src;
		}
		else if ( linkImgElmt.src.indexOf("Site") != -1 )
		{
			linkImgElmt.src = imgSiteLinkOff.src;
		}
		else if ( linkImgElmt.src.indexOf("Properties") != -1 )
		{
			linkImgElmt.src = imgPropertiesLinkOff.src;
		}
	}
}


