//function dn(){}
var agt=navigator.userAgent.toLowerCase();
var is_safari = agt.indexOf("safari")!=-1;


/**********************************************************************************************************
* CONFIGURATION SECTION. 
* 
* 1) You must place your menu items here using the full path to each page. 
*			Example of full path> 'http://yoursite.com/somedirectory/page.html'
*
* 2a) Adding a new menu is easy. First give the menu an id.
*			Example of menu id>	 dn = 'dbas'; (<-- must use dn here as the variable)
*
* 2b) Then create the 'div' element to hold the id by passing the variable you defined (must be dn) and the 
* width of the menu to the 'startdiv' function: 
*			Example of menu div>	startdiv( dn, '150');
*
* 2c) Put it together like so>	  dn = 'dbas'; startdiv( dn, '150' );
*
* 3) Adding a menu item is also easy. Use this format for each menu item: 'url', dn, 'label' 
* Notice that dn has no quotes here in this example:
*			Example of menu item>	bi('http://yoursite.com/index.html', dn, 'Home Page');
*
* 4) Finish by ending the 'div' element:
*			Example of end div>	enddiv();
*
* 5) Don't forget to add any menu you create to the style sheet!
*
\**********************************************************************************************************/

//Loads the full menu into memory.
function getdropdowns(){
	//DATABASE MENU
	var dn = 'dbas';startdiv(dn,'137');
	bi('http://www.oberlinpl.lib.oh.us/auto.html',dn,'Automotive');
	bi('http://www.oberlinpl.lib.oh.us/business.html',dn,'Business');
	bi('http://www.oberlinpl.lib.oh.us/careers.html',dn,'Career');
	bi('http://www.oberlinpl.lib.oh.us/edu.html',dn,'Education');
	bi('http://www.oberlinpl.lib.oh.us/genealogy.html',dn,'Genealogy');
	bi('http://www.oberlinpl.lib.oh.us/health.html',dn,'Health');
	bi('http://www.oberlinpl.lib.oh.us/taxes.html',dn,'Income Tax');

bi('http://www.oberlinpl.lib.oh.us/legal.html',dn,'Legal');
	bi('http://www.oberlinpl.lib.oh.us/magazine.html',dn,'Magazine/Journal');
	bi('http://www.oplin.lib.oh.us/home.php?a=&msg=',dn,'OPLIN');
	bi('http://www.oberlinpl.lib.oh.us/research.html',dn,'Research');
	bi('http://www.oberlinpl.lib.oh.us/ugrr.html',dn,'Underground Railroad');
	enddiv(); 
	
	//EDUCATION MENU
	dn = 'educ';startdiv(dn ,'136');
	bi('http://www.oberlinpl.lib.oh.us/computers.html',dn,'Computer Classes');
	bi('http://www.oberlinpl.lib.oh.us/edu.html',dn,'Educational Databases');
	bi('http://www.oberlinpl.lib.oh.us/homeschooling.html',dn,'Homeschooling');
	bi('http://www.oberlinpl.lib.oh.us/parent.html',dn,'Homework Help');
	bi('http://www.knowitnow.org/',dn,'Know-it-Now');
	bi('http://www.oberlin.edu/',dn,'Oberlin College');
	bi('http://www.oberlin.k12.oh.us/',dn,'Oberlin City Schools');
	bi('http://www.oberlinpl.lib.oh.us/onlinetest.html',dn,'Online Testing');
	bi('http://www.oberlinpl.lib.oh.us/scholarships.html',dn,'Scholarships');
	enddiv();

	//GENEALOGY MENU
	dn = 'gene';startdiv(dn,'136');
	bi('http://www.oberlinpl.lib.oh.us/african.html',dn,'African American Resources');
	bi('http://www.ancestrylibrary.com/default.aspx',dn,'Ancestry.com');
	bi('http://www.odh.state.oh.us/vitalstatistics/vitalstats.aspx',dn,'Birth and Death Records');
	bi('http://www.bostonathenaeum.org/',dn,'Boston Athenaeum');
	bi('http://www.cyndislist.com/',dn,'Cyndis List');
	bi('http://gdml-agent.auto-graphics.com/agent/SearchPages.asp?myses=905395&w=S&cuid=gdml&cusrvr=opus&s=LD',dn,'Godfrey Memorial Library');
	bi('http://www.heritagequestonline.com/ipbarcode?aid=3816',dn,'Heritage Quest');
	bi('http://www.oberlin.edu/cgi-bin/cgiwrap/library/ref/index.php?db=newsindex',dn,'Lorain County Newspapers');
	bi('http://www.oberlinheritage.org/',dn,'Oberlin Heritage Center');
	bi('http://index.rbhayes.org/hayes/index/',dn,'Rutherford B. Hayes');
	bi('http://oh0173.oplin.org/login?url=http://ohiodmc.ohiolink.edu/Sanborn/Login',dn,'Sandborn Fire Insurance Maps');
	bi('http://www.insurance.ca.gov/0100-consumers/0300-public-programs/0200-slavery-era-insur/',dn,'Slave Era Registry California');
	bi('http://www.webroots.org/',dn,'Web Roots');
	enddiv();

	//LIBRARIES MENU
	dn = 'libs';startdiv(dn,'136');
	bi('http://www.amherst.lib.oh.us/',dn,'Amherst Public Library');
	bi('http://www.avonlake.lib.oh.us/',dn,'Avon Lake Public Library');
	bi('http://cpl.org/',dn,'Cleveland Public Library');
	bi('http://www.elyria.lib.oh.us/',dn,'Elyria Public Library');
	bi('http://www.youseemore.com/herrick/default.asp',dn,'Herrick Memorial');
	bi('http://www.lorain.lib.oh.us/',dn,'Lorain Public Library');
	bi('http://www.oberlin.edu/library/',dn,'Oberlin College Library');
	bi('http://www.oberlinpl.lib.oh.us/opl.html',dn,'Oberlin Public Library');
	bi('http://www.oberlinpl.lib.oh.us/olr.html',dn,'Other Library Resources');
	enddiv();

	//PROGRAMS MENU
	dn = 'pgms';startdiv(dn,'137');
	bi('http://www.oberlinpl.lib.oh.us/adults.html',dn,'Adults');
	bi('http://www.oberlinpl.lib.oh.us/kids.html',dn,'Children');
	bi('http://www.oberlinpl.lib.oh.us/teens.html',dn,'Teens');
	bi('http://www.oberlin.net/~thebridge/',dn,'The Bridge');
	enddiv();
}


/**********************************************************************************************************
* END CONFIGURATION. Do not change anything below this line.
\**********************************************************************************************************/



//Each menu is a 'div' block which has a 'table' of menu items. 
//Start the 'div' and 'table' write here.
function startdiv(idval,w){
	var s = document.write ('<div id="'+idval+'"><table width="'+w+'" border="0" cellpadding="0" cellspacing="0" class="mt">');
}

//End 'div' and 'table' write.
function enddiv(){
	var s = document.write ("</table></div>");
}

//Create each menu item as a 'td' write with mouseover and mouseout actions.
function bi(link,div,name){
	var s = document.write ("<tr><td onClick=\"lnk('"+link+"');\" onMouseOver=\"menuovr('"+div+"','"+pn(name)+"',this);\" onMouseOut=\"menuout('"+div+"',this);\" class=\"nav2\">"+name+"</td></tr>");
}

//Error correcting for menu names.
function pn(name){
	var s=name;if(s.indexOf("<")>0) {return(s.slice(0,s.indexOf("<")-1));}return(s);
}

//Opens this window with specified location.
function lnk(link){
	internal_clicked = true;
	window.open(link,'_self');
}

//Sets status bar and timeout options when hovering over menu 'div'.
function mainovr(div,status){
	if(is_safari){
		bHover=status;window.status=status;setDD(div,status,false);}
	else{
		bHover=status;window.status=status;setTimeout('setDD(\'' + div + '\', \'' + status + '\', false)',400);}
}

//Cleans up status and timeout.
function mainout(div){
	bHover='';window.status='';setDDTimeout(div);
}

//Highlights the menu item background, changes text color and changes status bar text.
function menuovr(div, link, item){
//	window.status=link;item.style.backgroundColor='#CCCCCC';setDD(div,'',true);
	window.status=link;item.style.backgroundColor='#006600';item.style.color='white';setDD(div,'',true);
}

//Resets menu item background color and text color.
function menuout(div, item){
//	setDDTimeout(div);item.style.backgroundColor='#F0F0F0';
	setDDTimeout(div);item.style.backgroundColor='#FFFACD';item.style.color='#333333';
}

//Finds specified 'div' element in specified
function findDiv(n, d) { 
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findDiv(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}


function tNav() { 	
	var i,p,v,obj,args=tNav.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findDiv(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }    
}

//Hides all 'div' menus.
function hideDDs(sect) {
	tNav('dbas','','hide');tNav('educ','','hide');tNav('gene','','hide');tNav('libs','','hide');tNav('pgms','','hide');showElement('SELECT');
}

//Hides specified 'div' menu.
function hideDD(sect) {
	tNav(sect,'','hide');hideDDs(sect);
}
var secSet = null;
var activeTimer = null;
var bHover = '';
function setDD(sect, windowStatusVal, bshow) {
	hideDDs(sect);
	if ((bHover==windowStatusVal)||(bshow)){
		tNav(sect,'','show');
		if (secSet != null) window.clearTimeout(secSet);
		var dd = document.getElementById(sect) || document.all[sect]	
		hideElement('SELECT', dd); 
	}
}
function setDDTimeout(sect){
	if (secSet != null) window.clearTimeout(secSet);
	secSet = window.setTimeout('hideDD("' + sect + '")',500);
}
function hideElement( elmID, overDiv ) {
  if(document.all) {
    for(i = 0; i < document.all.tags( elmID ).length; i++) {
      obj = document.all.tags( elmID )[i];
      if(!obj || !obj.offsetParent) continue;
      // Find the element's offsetTop and offsetLeft relative to the BODY tag.
      objLeft   = obj.offsetLeft - overDiv.offsetParent.offsetLeft;
      objTop    = obj.offsetTop;
      objParent = obj.offsetParent;
      while(objParent.tagName.toUpperCase() != 'BODY') {
        objLeft  += objParent.offsetLeft;
        objTop   += objParent.offsetTop;
        objParent = objParent.offsetParent;}
      objHeight = obj.offsetHeight;
      objWidth  = obj.offsetWidth;
      if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft);
      else if((overDiv.offsetParent.offsetTop + overDiv.offsetHeight + 20) <= objTop);
      else if(overDiv.offsetTop >= eval(objTop + objHeight));
      else if(overDiv.offsetLeft >= eval(objLeft + objWidth));
      else {
        obj.style.visibility = 'hidden';
      }
    }
  }
}

function showElement(elmID) {
  if(document.all) {
    for(i = 0; i < document.all.tags( elmID ).length; i++) {
      obj = document.all.tags(elmID)[i];
      if(!obj || !obj.offsetParent) continue;
      obj.style.visibility = '';
    }
  }
}
