function addEvent( obj, type, fn )
{
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	} else {
		obj["on"+type] = obj["e"+type+fn];
	}
}

function removeEvent( obj, type, fn )
{
	if (obj.removeEventListener)
		obj.removeEventListener( type, fn, false );
	else if (obj.detachEvent)
	{
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	} else {
		obj["on"+type] = '';
	}
}

// set links with class "external" to open in a new window
function buildExternalLinks() {
	var links = document.getElementsByTagName("a");
	for(var index = 0; index < links.length ; index++) {

		if(links[index].className.indexOf("external") != -1) {
			//links[index].addEventListener("click",openNew,true);
			addEvent(links[index],"click",openNew);
		}

	}
}

function openNew(e) {
	e = e || window.event;
	window.open(this.href,'_blank');
	e.preventDefault? e.preventDefault() : e.returnValue = false;
	return false;
}

addEvent(window,"load",buildExternalLinks);
addEvent(window,"load",startList);

function startList() {
	if (document.all&&document.getElementById) {
		myList = document.getElementById('menuBar').getElementsByTagName('li');
		for (i=0; i < myList.length; i++) {
			node = myList[i];
			if (myList[i].nodeName=="LI") {
				node.onmouseover=function(ev) {
					ev = window.event;
					target = ev.srcElement;
					while(target.nodeName != "LI" && target.nodeName != "BODY") {
						target = target.parentNode;
					}
//					target.className = "yeshover";
				}
				node.onmouseout=function(ev) {
					ev = window.event;
					target = ev.srcElement;
					while(target.nodeName != "LI" && target.nodeName != "BODY") {
						target = target.parentNode;
					}
//					this.className=this.className.replace(" sfhover", "");
//					this.className = this.className.substring(0,(this.className.length - 8));
//					target.className = 'nohover';
				}
			}
		}
	}
}


/***********************************************
* AnyLink Vertical Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
//dynamically create url path based on location
var url=location.href.split('/');
var path='../';
var printedpath='';
for(i=1;i<(url.length-3);i++){
	printedpath=printedpath+path;
}

///////////////////////////////////////////////////////////////
////////				HOMEPAGE MENU				///////////
///////////////////////////////////////////////////////////////
var menu0 = new Array() // Who We Are
menu0[0] = '<a href="/About_Us/">Office of the State Librarian</a>'
menu0[1] = '<a href="/LDB/">Library Development Bureau</a>'
menu0[2] = '<a href="http://www.njlbh.org">Library for the Blind and Handicapped</a>'
menu0[3] = '<a href="/Cyberdesk/">State Library Information Center</a>'
menu0[4] = '<a href="/LDB/Technology/hblbtoc.php">Statewide Library Hub Network</a>'

var menu1=new Array()//What We Have
menu1[0]='<a href="CyberDesk/">CyberDesk</a>'
menu1[1]='<a href="http://capemay.njstatelib.org/ipac20/ipac.jsp?profile=njl--1" target=_blank>Library Catalog</a>'
menu1[2]='<a href="Electronic_Resources/">Electronic Resources</a>'
menu1[3]='<a href="NJ_Information/">NJ Information</a>'
menu1[4]='<a href="NJLH/">NJ Legislative Histories</a>'
menu1[5]='<A href="Research_Guides/">Selected Web Sites<BR>&amp; Research Guides</A>'
menu1[6]='<A href="New_Books/">New Books</A>'
menu1[7]='<a href="Collections_and_Services/">Collections &amp; Services</a>'
menu1[8]='<A href="How_Do_I/">How Do I...?</A>'

var menu2=new Array()//What We Do
menu2[0]='<A href="Ask_a_Librarian/" >Ask a Librarian</A>'
menu2[1]='<a href="/LDB/Construction/">Construction Grant</a>';
menu2[2]='<a href="LDB/factsheet.php" >Consultant Services</a>'
menu2[3]='<a href="LDB/Grants/" >Grants</a>'
menu2[4]='<a href="LDB/State_Aid/" >Per Capita State Aid</a>'
menu2[5]='<a href="LDB/Events/" >Training</a>'
menu2[6]='<a href="http://www.njyac.org" class="external">Youth Services</a>'
menu2[7]='<a href="NJSL_Strategic Plan_2007-2010_final.pdf" class="external">NJSL Strategic Plan</a>'

var menu3=new Array()//What's New
menu3[0]='<a href="'+printedpath+'LDB/Events/">Events/Conferences</a>'
menu3[1]='<a href="http://careers.tesc.edu/">Job Openings</a>'
menu3[2]='<a href="'+printedpath+'News/">Marketing & Communication for Media</a>'
menu3[3]='<a href="'+printedpath+'http://nancydowd.wordpress.com/">Marketing & Communication for Libraries</a>'

var menu4=new Array()//Library Community
menu4[0]='<a href="LDB/Library_Certification.php" >Library Certification</a>'
menu4[1]='<a href="LDB/Reference/" >NJ Library Network</a>'
menu4[2]='<a href="LDB/Reference/njlibsot.php" >NJ Library Organizations</a>'


///////////////////////////////////////////////////////////////
////////				LDB MENU				///////////
///////////////////////////////////////////////////////////////
var menu5=new Array()//About LDB
menu5[0]='<a href="'+printedpath+'LDB/aboutldb.php">About the LDB</a>' 
menu5[1]='<a href="'+printedpath+'LDB/factsheet.php">Contact Information</a>'
menu5[2]='<a href="'+printedpath+'LDB/News/">What\'s New?</a>'

var menu7=new Array()//Grants
menu7[0]='<a href="'+printedpath+'LDB/Gates/">Gates Foundation Grant Pogram</a>' 
menu7[1]='<a href="'+printedpath+'LDB/Grants/">Grant Information</a>'
menu7[2]='<a href="/LDB/Construction/">Construction Grants</a>';

var menu8=new Array()//Law
menu8[0]='<a href="'+printedpath+'LDB/Library_Law/">Library Laws of NJ</a>' 
menu8[1]='<a href="'+printedpath+'LDB/E-Rate/ufilter.php">Filtering Legislation</a>'
menu8[2]='<a href="'+printedpath+'LDB/opra.php">Open Public Records Act</a>' 
menu8[3]='<a href="'+printedpath+'LDB/E-Rate/ucita01.php">UCITA</a>'

var menu9=new Array()//Learn More About?
menu9[0]='<a href="'+printedpath+'LDB/E-Rate/">E-Rate/Universal Service Discounts</a>' 
menu9[1]='<a href="http://www.jerseycat.org/faq/#bar_codes" target="_blank">Bar Code Registry</a>'
menu9[2]='<a href="'+printedpath+'LDB/Library_Certification.php">Librarian Certification</a>' 
menu9[3]='<a href="'+printedpath+'LDB/listservs.php">Join NJSL listservs</a>'

var menu10=new Array()//Marketing - "Media Room"
menu10[0]='<a href="'+printedpath+'LDB/Marketing/Acknowledgement_Guidelines.php">Acknowledgment Guideline and Publicity Packets</a>' 
menu10[1]='<a href="'+printedpath+'LDB/Awards/">Awards</a>'
menu10[2]='<a href="'+printedpath+'LDB/Download/">Downloadable files</a>' 
menu10[3]='<a href="'+printedpath+'LDB/News/">News</a>'
menu10[4]='<a href="'+printedpath+'LDB/News/Newsletter/Fall_Winter_05_Impressions.pdf" target="_blank">Newsletter</a>'
menu10[5]='<a href="'+printedpath+'LDB/Reference/libpubln.php">Publications</a>' 
menu10[6]='<a href="http://www.njlibraries.org/" class="external">Super Librarian</a>'

var menu11=new Array()//News
menu11[0]='<a href="'+printedpath+'LDB/News/">LDB News</a>' 
menu11[1]='<a href="'+printedpath+'LDB/listservs.php">Listservs</a>'
menu11[2]='<a href="'+printedpath+'LDB/News/Newsletter/Fall_Winter_05_Impressions.pdf" target="_blank">Newsletter</a>' 
menu11[3]='<a href="'+printedpath+'LDB/News/">Press Releases</a>'

var menu13=new Array()//Resources
menu13[0]='<a href="'+printedpath+'LDB/Databases/">Databases-Statewide</a>' 
menu13[1]='<a href="http://www.jerseycat.org/" class="external">JerseyCat</a>' 
menu13[2]='<a href="'+printedpath+'LDB/JerseyClicks/">JerseyClicks</a>'
menu13[3]='<a href="http://www.njdigitalhighway.org/" class="external">NJ Digital Highway</a>' 
menu13[4]='<a href="'+printedpath+'LDB/NJKI/">NJKI</a>'
menu13[5]='<a href="'+printedpath+'LDB/Trustees/">NJ Trustees</a>' 
menu13[6]='<a href="'+printedpath+'LDB/NJULS/">NJ Union List of Serials</a>'
menu13[7]='<a href="'+printedpath+'LDB/Preservation/">Preservation</a>'
menu13[8]='<a href="'+printedpath+'LDB/Reference/libpubln.php">Publications</a>' 
menu13[9]='<a href="'+printedpath+'LDB/Statistics/">Statistics for NJ<br>Public Libraries</a>'
menu13[10]='<a href="'+printedpath+'LDB/GALCO/">Get a Library Card Online</a>'



var menu14=new Array()//Services
menu14[0]='<a href="/LDB/Construction/">Construction Bond Fund</a>'
menu14[1]='<a href="http://www.jerseycat.org/" class="external">JerseyCat</a>' 
menu14[2]='<a href="'+printedpath+'LDB/JerseyClicks/">JerseyClicks</a>'
menu14[3]='<a href="'+printedpath+'LDB/Events/">Events &amp; Professional Opportunities</a>' 
menu14[4]='<a href="http://www.njyac.org" class="external">Youth Services</a>'
menu14[5]='<a href="'+printedpath+'LDB/Statewide_Services_Handbook/">Statewide Services Handbook</a>' 
menu14[6]='<a href="'+printedpath+'LDB/Disabilities/">Service for People with Disabilities</a>'
menu14[7]='<a href="/LDB/Diversity_Initiatives/">Diversity Initiatives</a>'
menu14[8]='<a href="http://www.njlbh.org/" target="_blank">Library for the Blind & Handicapped</a>'
menu14[9]='<a href="'+printedpath+'LDB/GALCO/">Get a Library Card Online</a>' 

var menu15=new Array()//SLIC
menu15[0]='<a href="'+printedpath+'CyberDesk/">CyberDesk</a>'

var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var horizontaloffset=1 //horizontal offset of menu from default location. (0-5 is a good value)

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width: 160px" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x-obj.offsetWidth < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move menu up?
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either? (position at top of viewable window then)
edgeoffset=dropmenuobj.y
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+horizontaloffset+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}