var clear_menu;
var menu_last;
var agt=navigator.userAgent.toLowerCase();
var mac_ie;
if((agt.indexOf('msie')!= -1)&&(agt.indexOf('mac')!= -1)){
mac_ie=1;
}
var mac_x=0;
if(mac_ie){mac_x=78}

// update IE4
if(document.all && !document.getElementById){
document.getElementById = function(id){
return document.all[id];}}

// these lines set the nav current section pointer

var loc=document.location.href;
var pointer_id;

var locArray=new Array('look_inside_the_book','appearances','news_and_reviews','about_dr_devane','resources');
for(var l=0;l<locArray.length;l++){
var m=loc.indexOf(locArray[l]);
pointer_id=locArray[l];
if(m>0){
setTimeout("document.getElementById(pointer_id).style.color='#ffd880'",810);

break;}
}


function makeMenu(item,ref){ref.style.color='#ffd880';
var top=DL_GetElementTop(ref);
var left=DL_GetElementLeft(ref);
left=left + mac_x;
if(document.body && typeof document.body.clientHeight!='undefined'){browser_height=document.body.clientHeight}
if(typeof window.innerHeight!='undefined'){browser_height=window.innerHeight;}

resetClearMenu();
var menu='<div class="navmenu">\n';
var j=0;var menu_count=0;
for(var i=0;i<menuArray.length;i++){
if(menuArray[i][0] == item){
menu_count++;
var h = menuArray[i][2] + '';
h=h.replace(/\/http/g,'http');

menu +='<div class="navitem" id="i'+j+'"> &bull; <a href="'+h+'" onMouseover="resetClearMenu()" onMouseout="clearMenu()">'+menuArray[i][1]+'</a></div>\n';
j++;
}
}
menu+='</div>';

if(! menu_count){menu =''}

var menu_div=document.getElementById('menu');

var offset=left + 0;
var top_=top + 17;

menu_div.innerHTML=menu;

menu_div.style.left=offset+'px';
menu_div.style.top=top_+'px';

setTimeout('jiggleIt()',10);

menu_div.style.width='190px';

// if(menu_last){document.getElementById(menu_last).style.visibility='hidden';}
// menu_last=item.replace(/ /g,'_');
// document.getElementById(menu_last).style.visibility='visible';
}

function jiggleIt(){
var menu_div=document.getElementById('menu');
menu_div.style.width='191px';
}

function clearMenu(item,ref){if((ref)&&(ref.id != pointer_id)){ref.style.color='#fff';}
clear_menu=setTimeout('clearTheMenu()',600);

}

function clearTheMenu(){
var menu_div=document.getElementById('menu');
menu_div.innerHTML='';
// document.getElementById(menu_last).style.visibility='hidden';
}

function resetClearMenu(){
clearTimeout(clear_menu);
}

function DL_GetElementLeft(eElement)
{var nLeftPos = eElement.offsetLeft;         
var eParElement = eElement.offsetParent;      
while (eParElement != null){nLeftPos += eParElement.offsetLeft;      
eParElement = eParElement.offsetParent;}
return nLeftPos;                             
}

function DL_GetElementTop(eElement){
var nTopPos = eElement.offsetTop;          
var eParElement = eElement.offsetParent; 
while (eParElement != null){                                         
nTopPos += eParElement.offsetTop;        
eParElement = eParElement.offsetParent;}
return nTopPos;                              
}

var NS = (navigator.appName=="Netscape")?true:false;

function setImageSize(){
iWidth = (NS)?window.innerWidth:document.body.clientWidth;
iHeight = (NS)?window.innerHeight:document.body.clientHeight;
iWidth = document.images[0].width - iWidth;
iHeight = document.images[0].height - iHeight;
window.resizeBy(iWidth, iHeight);
self.focus();
     }; 

function makePopup(image_path){
var win=window.open("","","width=500,height=500");
var contents='<html><head><style type="text/css">body{margin:0px}</style><script type="text/javascript" src="/menu.js"></script></head><body><img src="'+image_path+'" onload="setImageSize()"></body></html>';
win.document.open();
win.document.write(contents);
win.document.close();
win.focus();
}

