var session = new CJL_CookieUtil("lulibrary",60 * 24 * 365,"/","leeds.ac.uk"); 
/* var session = new CJL_CookieUtil("lulibrary",60 * 24 * 365,"/"); */

window.onload = libonload;
function libonload(e)
{
var startmenu="-"
var lastmenu = session.getSubValue("menushow");
//var reg = /^.*leeds.ac.uk\/(library\/|)$/i; /* force menu for home pages except cat only*/
var reg = /^.*leeds.ac.uk\/(library\/|)(?:spcoll\/)?$/i; /* force menu for home pages except cat only*/
  if (reg.exec(location.href) && lastmenu !="none")
    {    
    startmenu="lefthandmenu";
    }
pageinit(startmenu,"-");
initAtoZ();
onload_handler(); /* call the pages local init function */
}

function pageinit(menu,style)
{
/* if params not specified, read them from cookie */
if (menu == "-")
  {
  menu = session.getSubValue("menushow");
  menu = menu ? menu : "lefthandmenu";
  }
if (style == "-")
  {
  style=session.getSubValue("style"); 
  if (style != "textonly") 
    {style = "normal"} /* in case of old cookies [delete eventually] */
  }

switch(style) 
{
case "textonly": 
  if (menu == "helpindex")
    {menu="lefthandmenu";} /* no helpindex displayed for textonly */
  if (document.getElementById("toplogo") == null ) /* don't switch menu on cat results screen */
    {showmenu(menu);}
  setActiveStyleSheet("textonly")
break
default: /* normal style */

  if (document.getElementById("toplogo") == null ) /* don't switch menu on cat results screen */
    {
	showmenu(menu);
	if (menu != "none")	{fixlinks();}
	}
  setActiveStyleSheet("normal")
}

}
window.onunload = function(e) 
{
/***** styleswitcher unload ******/
/***** menuhide unload ******/
}

/************** initialising functions called from onload_handler *************/
function default_formfocus()
{
if (document.forms.length > 1)
  {
  var ct, inp, focused;
  for(ct=0; (inp = document.getElementsByTagName("input")[ct]); ct++) 
    {
    if (
       ((inp.getAttribute("name").indexOf("searcharg") != -1) || (inp.getAttribute("name").indexOf("SEARCH") != -1) || (inp.getAttribute("name").indexOf("extpatid") != -1))
    && ((inp.getAttribute("type").indexOf("hidden") == -1 ) || (inp.style.display == "inline" || inp.style.display == "block"))
       )
      {
      inp.focus();
      focused=1;
	  break;
      }
    }
  if (focused != 1)
    {
  if (
	 (document.forms[1].elements[0] != null) 
  && (document.forms[1].elements[0].style == "inline" || document.forms[1].elements[0].style == "block")
     )
    {document.forms[1].elements[0].focus(); }
    }
  }
}


function setcjkcharset()
{
if (navigator.appVersion.indexOf("MSIE") != -1)
  {
  if (window.location.port == 8082)
    {
    document.charset="UTF-8"
    }
  }
}


