var fullyLoaded=false;
var NN 	= document.layers ? true : false;
var hideName = (NN ? 'hide' : 'hidden');
var showName = (NN ? 'show' : 'visible');
var zIdx 	 = -1;
var x, y;
function genLayer(sName, startLeft, startTop, sVis, copy) 
{
	if (NN) {
		document.writeln('<LAYER NAME="' + sName + '" LEFT="'+startLeft+'" TOP="'+startTop+'" VISIBILITY="' + sVis + '"' + ' z-Index=' + (++zIdx) + '>' + copy + '</LAYER>');
		}else {
		document.writeln('<DIV ID="' + sName + '" STYLE="position:absolute;background-color:#FFFF00;top:'+startTop+';left:'+startLeft+';overflow:none; visibility:' + sVis + '; z-Index=' + (++zIdx) + '">' + copy + '</DIV>');
		}
	}
// Define a function to hide layers
function hideSlide(name) {
	refSlide(name).visibility = hideName;
	}

// Define a function to reveal layers
function showSlide(name) {
	refSlide(name).visibility = showName;
	}

// Define a central function to reference layers
function refSlide(name) {
	if (NN) { return document.layers[name]; }
	else if (document.all)
	 { return eval('document.all.' + name + '.style'); }
	 else
	 { return eval('document.getElementById("'+name+'").style');}
	}
	
function motionListener() {
	if (NN) {
		window.captureEvents(Event.MOUSEMOVE);
		window.onmousemove = grabXY;
		}
	else if (document.all) { 
		document.onmousemove = grabXY;
		} 
	}

// Track the x/y coordinates  
// of mouse pointer arrow
function grabXY(ev) {
	if(NN) {
		x = ev.pageX;
		y = ev.pageY;
		}
	else if (document.all) {
		x = event.x;
		y = event.y;
		}
	}
	
function shutThis(e)
{
var source;
source=document.getElementById(e.currentTarget.id).id;
hideSlide(source);
}

var subWidth;
var subHeight;
var subTop;
var subLeft;
var onmenu=false;
		
function displaySub(name, action) {
if(fullyLoaded==true)
{
scrollamount = NN ? 0 : document.body.scrollTop;
	if(action) {onmenu=true;
	 			showSlide(name);
				aimnum=parseInt(name.substr(2));
				for(i=0; i<8; i++)
				{
				noaim="sm"+(i+1);
				if(i+1!=aimnum)
					hideSlide(noaim);
				}
				if(document.all)
				{
				subWidth=document.getElementById(name).offsetWidth;
				subHeight=document.getElementById(name).offsetHeight;
				}
				if(NN)
				{
				subWidth = refSlide(name).document.width;
				subHeight = refSlide(name).document.height;
				aim=refSlide(name).id;
				}
				if(!NN)
				{
				aim=document.getElementById(name).id;
				}
				subTop=parseInt(refSlide(name).top)-scrollamount;
				subLeft=parseInt(refSlide(name).left);
				tmr=window.setInterval("displaySub(aim, false)", 20);
				if(!document.all && !document.layers)
					{
					document.getElementById(name).addEventListener('mouseout', shutThis, true);
					document.getElementById(name).addEventListener('mouseover', pointerOn, true);
					}
				
		}
	else {
	if(!onmenu && ((x < subLeft) || (x > subLeft+subWidth) || (y < subTop) || (y > subTop+subHeight)))
			{
			hideSlide(name);
			clearInterval(tmr); 
			}
		}
	}
	}
	
function pointerOn(e)
{
displaySub(document.getElementById(e.currentTarget.id).id, true);
kids=document.getElementById(e.currentTarget.id).childNodes;
for(i=0; i<kids.length; i++)
	{
	kids[i].addEventListener('mouseout', pointerKid, true);
	}
}
function pointerKid(e)
{
displaySub(e.target.parentNode.id, true);
alert('test');
}
	


motionListener();
self.focus();
function goToDir()
{
dirchs=document.forms[0].dirchoice.selectedIndex;
switch(dirchs)
	{
	case -1:
		{window.alert("Choose a directory, please");
		break;
		}
	case 0:
		{window.alert("Please, scroll down the selection list\n for choosing a directory");
		break;
		}
	case 1:
		{window.location.href="http://www.electricityforum.com/t&d/company.htm";
		break;
		}
	case 2:
		{window.location.href="http://www.electricityforum.com/t&d/product.htm";
		break;
		}
	case 3:
		{window.location.href="http://www.electricityforum.com/products_new/genco.htm";
		break;
		}
	case 4:
		{window.location.href="http://www.electricityforum.com/products_new/genprod.htm";
		break;
		}
		default:
		{window.location.href="http://www.electricityforum.com/t&d/company.htm";
		break;
		}
		
	}
}
