var tabnames=new Array("Home","Families","Links","Search","SiteMap","Downloads","Info","Print","Print","","Transcripts");
var PrintSubMenu="<a href='#'>undefined</a>",path, LastUpdate, selectedtab=-1, mouseonprint=false, mouseonsub=false;
var ileft=5, blindex="",trData="0,1,125";

var tabgo=new Array("index.html","Family.html","Links.html","SearchLocal.html","SiteMap.html",
"Downloads.html","About.html","Print.html","","","Transcripts.html");

var tabtitle=new Array("Return to the home page for this family","Choose a different family",
"Open a list of links to other web sites","Open my family names search page","Open the site map for this family",
"Download GEDCOM and PDF files etc","Open the notes page for this family",
"Open a printer friendly PDF file of this chart","Open a printer friendly file","","View transcripts of supporting documents");

function SetToolbar(tabs,barColour){
//if(ie_ver()==-1 || ie_ver()>7){document.body.style.fontSize="108%"} else {document.body.style.fontSize="90%"};
    var hideDiv=window.document.getElementById("pageDescription");if (hideDiv){document.body.removeChild(hideDiv)};
    var tablist="", i=0;
    createTopDiv(barColour);
    for (i=0; i<tabs.length; i++){
    if (tabs[i]==9){tablist+=addSearcher(i)} else {tablist+=makeTab(i,tabs[i]);};}
    var d=window.document.getElementById("TopDiv");d.innerHTML=tablist;
    var footer=window.document.createElement("div"); document.body.appendChild(footer);
    var o=footer.style;o.position="absolute";o.left="10px";o.top="30px";
    o.FontFamily="Verdana, Arial, sans-serif"; o.fontSize="75%"
    //footer.font="9pt,Tahoma, Arial, sans-serif";
    o.width="700px";
    var footercontent="<div style='position: absolute; left: 1px' ><a href='mailto: origins@mcskimming.org.uk'"+
        " title='contact me by email'>send me an email</a></div>"
        if(blindex){footercontent+="<div style='position: absolute; left: 150px' ><a href='../blindex.html#"+blindex+"'"+
        "title='View a list of indexes of related records found at the British Library.'>Related British Library Indexes</a></div>"}
        footercontent+="<div style='position: absolute; width: 100%; left: 200px; text-align: right'>updated: "+LastUpdate+"</div>";
    footer.innerHTML=footercontent;
}

function createTopDiv(barColour){
  var TopDiv = window.document.createElement("div"); document.body.appendChild(TopDiv); TopDiv.id="TopDiv";
  var o=TopDiv.style; o.position="absolute"; o.top="0px";o.height="23px"; o.left="0px";
  if (barColour){o.background="#99CCFF";o.width=screen.width+"px";};
}

function makeTab(i,t){
    var lpos=ileft+"px",imgsrc="",divstr="";
    if (t==selectedtab){
        imgsrc=path+tabnames[t]+"Selected.gif";
        divstr= "<div class='TopMenuTab' id='tab"+t+"' style='left:"+lpos+"'><img id='img"+t+"' src='"+imgsrc+"' border='0'></div>"
    }
     else{
        imgsrc=path+tabnames[t]+"Normal.gif";
        divstr= "<div class='TopMenuTab' id='tab"+t+"' style='left:"+lpos+"' onmouseover='imgOver("+t+")' onmouseout='imgOut("+t+")'"+
        "onclick='TabClick("+t+")'><img id='img"+t+"' src='"+imgsrc+"' border='0'  title='"+tabtitle[t]+"'></div>"
    }
    ileft+=100;
   return divstr;
}

function addSearcher(i){
var lpos=ileft+"px";
var rstring='<div id="sdiv" style="left:'+lpos+'"><form name="input" action="'+path+'SearchLocal.html" method="get">'+
  '<input type="text" name="SearchText" id="sboxm" value="Search" onfocus="ClearSearchBox()">'+
  '<input type="submit" value=" "  id="sbtn" title="Submit Search"></form></div>';
ileft+=168;
return rstring
}

function ClearSearchBox(){
var d=window.document.getElementById("sboxm");
if (d.value=="Search"){d.style.color="#000000";d.value=""}
}

function imgOver(n){
window.document.getElementById("img"+n).src=path+tabnames[n]+"Hover.gif";
if (n==8){dropPrintMenu(n)};
}

function imgOut(n){
    if (n!=8){window.document.getElementById("img"+n).src=path+tabnames[n]+"Normal.gif";}
    else{mouseonprint=false;subMouseoff();}
}

function TabClick(n){
  switch (n){
    case 0: window.open(tabgo[0],'_self','scrollbars=yes, resizable=yes'); break;
    case 1: window.open(path+tabgo[1],'_self','scrollbars=yes, resizable=yes'); break; 
    case 4: tpath="";window.open(tabgo[n],'_self','scrollbars=yes, resizable=yes');  break;
    case 6: ef_OpenNotes(tabgo[6]); break;
    case 7: window.open(tabgo[7],'_self','scrollbars=yes, resizable=yes'); break;
    case 8: break; //this line is required to disable the print tab when using the sub menu
    case 10: window.open(path+tabgo[10]+"?"+trData,"","height=500, width=800,top=150,left=50,scrollbars=yes, resizable=yes, toolbar=yes");break;
    default: window.open(path+tabgo[n],'','scrollbars=yes, resizable=yes');
    }
}

function dropPrintMenu(n){
  var lpos=window.document.getElementById("tab"+n).style.left;
  var d=window.document.getElementById("SubMenu");
  if(!d){createPsub(n);d=window.document.getElementById("SubMenu");};
  d.style.visibility="visible"; mouseonprint=true;
}

function createPsub(n){
  PrintSubMenu=PrintSubMenu.replace(/<a href=/g,"<a target='_blank' href=");
  var lpos=window.document.getElementById("tab"+n).style.left;
  var subDiv = window.document.createElement("div"); document.body.appendChild(subDiv); subDiv.id="SubMenu";
  var d=window.document.getElementById("SubMenu");
  var o=d.style;o.position="absolute";o.background="#FFFFCC";o.zindex=100;
      o.width="100px";o.left=lpos;o.top="23px";o.visibility="hidden";
  d.innerHTML="<div onmouseover='subMouseon()' onmouseout='subMouseoff()'>"+PrintSubMenu+"</div>";
}

function subMouseon(){mouseonsub=true;if(typeof holdoff!="undefined"){clearTimeout(holdoff)};}

function subMouseoff(){mouseonsub=false; holdoff=setTimeout("slowhide()",150)}

function slowhide(){
if(!mouseonprint && !mouseonsub){
  window.document.getElementById("SubMenu").style.visibility="hidden";
  window.document.getElementById("img8").src=path+"PrintNormal.gif";}
}
function ef_OpenNotes(f){window.open(f,"","height=500, width=800,top=150,left=50, scrollbars=yes, resizable=yes,toolbar=yes")}

function ie_ver(){var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer') {
    var ua = navigator.userAgent;
    var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
        rv = parseFloat(RegExp.$1);
    }
return rv;}

