
var siteURL = "http://www.ecommercepositioning.com";
var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;
var ddimgitem = 0;
var oldimg = 0;

topnav1off = new Image();
topnav1off.src = siteURL + "/images/topnav1_off.gif";
topnav1on = new Image();
topnav1on.src = siteURL + "/images/topnav1_on.gif";
topnav2off = new Image();
topnav2off.src = siteURL + "/images/topnav2_off.gif";
topnav2on = new Image();
topnav2on.src = siteURL + "/images/topnav2_on.gif";
topnav3off = new Image();
topnav3off.src = siteURL + "/images/topnav3_off.gif";
topnav3on = new Image();
topnav3on.src = siteURL + "/images/topnav3_on.gif";
topnav4off = new Image();
topnav4off.src = siteURL + "/images/topnav4_off.gif";
topnav4on = new Image();
topnav4on.src = siteURL + "/images/topnav4_on.gif";
topnav5off = new Image();
topnav5off.src = siteURL + "/images/topnav5_off.gif";
topnav5on = new Image();
topnav5on.src = siteURL + "/images/topnav5_on.gif";

// open hidden layer
function mopen(id, wdth, imgid)
{	
	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	if(oldimg) document.getElementById(oldimg).src = eval(oldimg + 'off.src');

	// get new layer and show it
	oldimg = imgid;
	document.getElementById(imgid).src = eval(imgid + 'on.src');
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
	wdth = wdth - 2;
	ddmenuitem.style.width = wdth + 'px';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	if(oldimg) document.getElementById(oldimg).src = eval(oldimg + 'off.src');
	oldimg = null;
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 
