/* ************************************************************
// JavaScript: www.coldwellbankerpremier.com/js/submenu.js
// ©2008 by Inico.com, LLC
// Last modified: 2008-05-13 16:13:47 UTC
// ************************************************************
*/


document.LastSubMID = new Array( );
document.TimeoutSubmenu = new Array( );

if(!document.barbghovercolor)
document.barbghovercolor= 'gray';

if(!document.barbghoverimage)
document.barbghoverimage= '/_img/1x1.gif';

if(!document.barhovercolor)
document.barhovercolor= 'white';

if(!document.barbgcolor)
document.barbgcolor= 'white';

if(!document.barcolor)
document.barcolor= 'gray';

if(!document.SubmenuIdPrefix)
document.SubmenuIdPrefix ='s'

if(!document.MenuIdPrefix)
document.MenuIdPrefix ='a'

if(!document.MenuClassName)
document.MenuClassName ='m'

if(!document.SubmenuClassName)
document.SubmenuClassName ='sub'

if(!document.CoverIframeIdPrefix)
document.CoverIframeIdPrefix ='coverupselct'

function coverSelectField(objRef,Idx)
{
	if(objRef){
	iframeRef = document.getElementById(document.CoverIframeIdPrefix+String(Idx));
		//objRef.style.visibility = 'visible';
		objRef.style.display = 'block';
	if(iframeRef){
		iframeRef.style.width = objRef.offsetWidth ;
		iframeRef.style.height = objRef.offsetHeight ;
		iframeRef.style.marginTop = objRef.style.marginTop;
		iframeRef.style.marginLeft = objRef.style.marginLeft;
		iframeRef.style.top = objRef.style.top ;
		iframeRef.style.left = objRef.style.left;
		iframeRef.style.zIndex = objRef.style.zIndex - 1;
		iframeRef.style.display = 'block';
		//alert(objRef.style.top)
	}
	}
}

function showSubs( subIDindx)
{
	if ( document.TimeoutSubmenu[subIDindx])
		clearTimeout( document.TimeoutSubmenu[subIDindx])

	hideSubs( );

	subID = document.SubmenuIdPrefix + String( subIDindx)

	document.LastSubMID[subIDindx] = document.getElementById( subID);
//	document.LastSubMID[subIDindx].style.display = 'block'

	coverSelectField(document.LastSubMID[subIDindx],subIDindx)
}

function hideSubs( )
{

	for( i = 0;i < document.LastSubMID.length;i++)
	{
		if ( document.LastSubMID[i]){
			document.LastSubMID[i].style.display = 'none'; //.visibility = 'hidden';
//			coverSelectField(document.LastSubMID[i],true)
		iframeRef = document.getElementById(document.CoverIframeIdPrefix+String(i));
		if(iframeRef)
		iframeRef.style.display = 'none';

		}

		if ( document.TimeoutSubmenu[i])
			clearTimeout( document.TimeoutSubmenu[i]);

	}
}

function hideSub( subIDidx)
{
	iframeRef = document.getElementById(document.CoverIframeIdPrefix+String(subIDidx));
	if(iframeRef)
	iframeRef.style.display = 'none';

	// subID = 's'+ String(subIDindx)
	if ( document.LastSubMID[subIDidx])
		document.LastSubMID[subIDidx].style.display = 'none';//.visibility = 'hidden';
}

function highlightItem( IID)
{
	MID = document.getElementById( document.MenuIdPrefix  + String( IID));
	if ( MID)
	{
		MID.style.backgroundColor = document.barbghovercolor;
                  MID.style.backgroundImage = 'url('+document.barbghoverimage+')';

		MID.style.color = document.barhovercolor
	}
}

function downlightItem( MID)
{
	if ( MID)
	{
		MID.style.backgroundColor = document.barbgcolor;
                    MID.style.backgroundImage = (document.barbgimage ? 'url('+document.barbgimage+')' :'none')

		MID.style.color = document.barcolor
	}
}

function resetItemColor( currentItem)
{
	if ( document.ItemCount)
		ICount = document.ItemCount + 1
	else
		ICount = 30

	for( i = 0;i <= ICount;i++)
	{
		rID = document.MenuIdPrefix + String( i)
		refItem = document.getElementById( rID);
		if ( refItem)
		{
			if ( currentItem == i)
			{
				refItem.style.backgroundColor = document.barbghovercolor
				refItem.style.color = document.barhovercolor
                                     refItem.style.backgroundImage = 'url('+document.barbghoverimage+')';

			}
			else
			{
				refItem.style.backgroundColor = document.barbgcolor
				refItem.style.color = document.barcolor
                                 refItem.style.backgroundImage = (document.barbgimage ? 'url('+document.barbgimage+')' :'none')

			}
		}
	}
}

browsername = navigator.appName;
browserVer = parseInt( navigator.appVersion);
if ( browsername == "Microsoft Internet Explorer" && browserVer >= 4)
{
	document.write( "<style type='text/css'>\n");
	document.write( "."+document.SubmenuClassName+" a, a."+document.MenuClassName+" {width:100%}\n");
	document.write( "</style>\n");
} ;

document.write( "<style type='text/css'>\n");
document.write( "a."+document.MenuClassName+"{background-color:" + document.barbgcolor + ";color:" + document.barcolor + "}\n");
document.write( "</style>\n");
