/*
The ultimate DHTML drop-down code
Nick Nettleton
www.computerarts.co.uk || www.fluid7.co.uk
--
This must be the single most requested bit of code in the history of Computer Arts, so we've decided to make it user-friendly and adaptable for everyone. Stacks more goodies to come too - head to one of the above sites for regular infoa nd updates.
Works with v4 and v5 browsers - both IE and NS. Update for NS6 coming. Also, be aware there's no way to automatically centre layers in the window - a JS for this coming soon. In the meantime, stick with left-aligned.
Keep an eye out for update for NS6.
--
You can adapt, use and distribute this code under GNU public licence, as long as:
(1) You leave all the comment and credit lines in, including these ones
(2) You don't sell it for profit
--
If you want to tweak the code yourself, use the dropLayer to set the names of the dropdowns, and just call showDrop(n) and f7_hidedrop from onmouseover, onmouseout and other events. Swap n for the number of the layer as in the array.
--
Enjoy!!!
*/

//names of dropdowns stored here
dropLayer=new Array(5)
dropLayer[0]="dlAbinasia"; 
dropLayer[1]="dlManual"; 
dropLayer[2]="dlReference"; 
dropLayer[3]="dlMarketPlace"; 
dropLayer[4]="dlCommunity"; 

dropLayerWidth=new Array(5)
dropLayerWidth[0]=160; 
dropLayerWidth[1]=160; 
dropLayerWidth[2]=160; 
dropLayerWidth[3]=160; 
dropLayerWidth[4]=160; 

pageWidth = 800;
dropLayerOffset=0;

//simple browser check
isV4=(parseInt(navigator.appVersion)>=4 && parseInt(navigator.appVersion)<=5)?1:0
isIE=(document.all && isV4)?1:0
isNS=(document.layers && isV4)?1:0

//code for drops

function showDrop(thelayer){
	keep=thelayer; hideAll(); showItNow=1
	showIt(thelayer)
	}

function showIt(thelayer){
		if(isIE){ eval(dropLayer[thelayer]+'.style.visibility="visible"') }
		if(isNS){ eval('document.'+dropLayer[thelayer]+'.visibility="show"');}
	}


function hideDrop(){
	keep=-1; setTimeout('hideAll()',500)
	}

keep=-1

function hideAll(){
	for(i=0;i<dropLayer.length;i++){  
		hideIt=0; checkMousePos(i)
		if(isIE && keep!=i){ 
			if(hideIt){ eval(dropLayer[i]+'.style.visibility="hidden"') } 
			}
		if(isNS && keep!=i){ 
			if(hideIt){ eval('document.'+dropLayer[i]+'.visibility="hide"') }
			}
		}
	}

//deal with cursor over layer
document.onmousemove = getMousePos
if (isNS) document.captureEvents(Event.MOUSEMOVE)

function getMousePos(e){
	if(isNS){mouseX=e.pageX; mouseY=e.pageY}
	if(isIE){mouseX=event.clientX; mouseY=event.clientY;}
	}

function checkMousePos(i){          
	if(isNS){     
		xMin=eval('document.'+dropLayer[i]+'.left')
		xMax=xMin+eval('document.'+dropLayer[i]+'.clip.width')
		yMin=eval('document.'+dropLayer[i]+'.top')
		yMax=yMin+eval('document.'+dropLayer[i]+'.clip.height')
		}    
	if(isIE){     
		xMin=eval(dropLayer[i]+'.style.pixelLeft')
		xMax=xMin+eval(dropLayer[i]+'.style.pixelWidth')
		yMin=eval(dropLayer[i]+'.style.pixelTop')
		yMax=yMin+eval(dropLayer[i]+'.style.pixelHeight')
		}
	if (mouseX>=xMin && mouseX<=xMax && mouseY>=yMin && mouseY<=yMax){
		hideIt=0; setTimeout('hideAll()',500)
		}
	else { hideIt=1 }
	return hideIt
	}

function redrawDropLayer(){
	if(isNS) {
		var docWidth = innerWidth;
	} 
	else {
		var docWidth = document.body.clientWidth;
	}
	pageOffset=((docWidth-pageWidth)/2)+dropLayerOffset
	for (x=0; x<dropLayer.length ;x++ )	{
		eval ("document.all." + dropLayer[x] + ".style.posLeft = " + pageOffset);
		pageOffset=pageOffset+dropLayerWidth[x];
		}
	}

