var showflag=false; // true if menu is displayed
var id=null; // timer id
var onname=""; // name of the showed div

function getObject(id){ // returnes ref to object
if(document.getElementById) // IE >= 5.0 or NN >= 6.0 
return document.getElementById(id); 
else if(document.all) // IE 4 
return document.all(id); 
else if(document.layers) // NN 4 
return document.layers[id]; 
else 
return false; 
} 

function show(name, x){ // shows name div with x horiz. offset
killtimer(); // reset timer
if(showflag) hide(); 

if(document.all) // IE
getObject(name).style.left=(x+=(document.body.clientWidth/2>150)?(Math.floor(document.body.clientWidth/2-150)):0); 
else if(!document.layers) // new NS 
getObject(name).style.left=(x+=(window.innerWidth/2>150)?(Math.floor(window.innerWidth/2-150)):0); 
else // old NS 
getObject(name).left=(x+=(window.innerWidth/2>150)?(Math.floor(window.innerWidth/2-150)):0); 

if(!document.layers) { // IE and new NS 
getObject(name).style.top=140; 
getObject(name).style.visibility='visible'; 
} else { // old NS 
getObject(name).top=26; 
document.layers[name].visibility='show'; 
} 

showflag=true; 
onname=name; // save the name of the displayed div
} 

function killtimer(){ // resets timer
if(id!=null){ 
clearTimeout(id); 
id=null; 
} 
return true; 
} 

function hide(){ // hides the displayed div 
if(id!=null) 
killtimer(); 

if(showflag){ 
if(document.layers) 
getObject(onname).visibility='hide'; 
else 
getObject(onname).style.visibility='hidden'; 
} 
showflag=false; 
onname=""; 
} 

function reset(){ // sets new timer 
killtimer(); 
id = setTimeout('hide()', 500); 
} 

