// -----------------------
// 
// -----------------------

var orgColour ;
var currenttab = null;
var currentpage = null;

function scroll1()
{
 if (document.all)
 {
  if (document.body.scrollTop + menufloat.clientHeight < document.body.scrollHeight)
  {
    menufloat.style.top = document.body.scrollTop;
  }
 }
}

function openWin(s)
{
  window.open(s,"", "width=400,height=300,status=1,resizable=1;");
  return false;
}

function openWorld(s)
{
  window.open(s,"", "width=720,height=500,status=1,resizable=1;");
  return false;
}

function openBigWindow(s)
{
  window.open(s,"", "width=700, height=600, status=1, resizable=1");
  return false;
}

function ShowPage(tab, name)
{
 if (tab != currenttab)
 {
  if (currentpage != null)
  {
   currenttab.disabled = false;
   currenttab.className = 'tabinactive';
   currentpage.className = 'tabbedpage';
   currentpage.style.display = 'none';
  }
  currenttab = tab;
  currenttab.className = 'tabactive';

  // ie
  if (document.all)
  {
    currentpage = document.all[name];
  }
  else
  {
    currentpage = document.getElementById(name);
  }
  currentpage.className = 'tabbedpageactive';
  currentpage.style.display = '';
 }
}

function LoadPage()
{
  ShowPage(document.getElementById('t1'), 'tab1');
}

function ShowRightPanel(img)
{
  if (document.body.scrollWidth > 1050)
  {
    var h=document.body.scrollHeight;
    if (document.all)
    {
      var newDiv=document.createElement('<div id="testx" style="background-image:url(' + img  + ');position:absolute;top:0px;left:1024px;background-color:#FFF;width:100px;background-color:#FFF;height=' + h + ';" />');
      document.body.appendChild(newDiv);
    }
    else
    {
      // create a new div element and give it some content and a class
      newDiv = document.createElement("div");
      newDiv.className='rightpanel';
      newDiv.innerHTML = " ";
      newDiv.style.height = h;
      newDiv.style.backgroundImage ='url(' + img + ')';
      // add the newly created element and it's content into the DOM
      document.body.appendChild(newDiv);
    }
  }
}

function AddPluses(s)
{
  var i = s.indexOf(' ');
  while (i != -1)
  {
    s = s.replace(' ', '+');
    i = s.indexOf(' ');
  }
  return s;
}

function checkData(s)
{
  if (s.length > 0)
  {   
    document.location.href='http://www.timeref.com/search.php?q='+AddPluses(s);
  }
  else
  {
    alert('Enter some search text, E.g. Rochester Castle');
    return false;
  }
}

function doSearch()
{
  var oSearch=document.getElementById('searchTXT');
  if (oSearch) {
    checkData(oSearch.value);
  }
}

function fixup()
{

  // attach search routines

  var oSearch=document.getElementById('searchGO');
  if (oSearch) {

    if (document.getElementById && !document.all) {
      oSearch.addEventListener('click', doSearch, false);
    }
    else if (window.attachEvent) {
      oSearch.attachEvent('onclick', doSearch);
    }
  }
  else {
    alert('not found');
  }

}

if (document.getElementById && !document.all) {
  addEventListener('load', fixup, false);
}
else if (window.attachEvent) {
  window.attachEvent('onload', fixup);
}

function glossCatChange(s)
{
  var x = category.selectedIndex;
  if (x == 0) {
    location.href='gloss' + s + '.htm';
  }
  if (x == 1) {
    location.href='gloss' + s + 'a.htm';
  }
  if (x == 2) {
    location.href='gloss' + s + 'r.htm';
  }
  if (x == 3) {
    location.href='gloss' + s + 'm.htm';
  }
  if (x == 4) {
    location.href='gloss' + s + 'h.htm';
  }
}


function togBranch(e1, e2)
{
  var x1 = document.getElementById(e1);
  var s = 'span.#' + e2;
  var i = 'img.#' + e1;
  if (x1.src.indexOf('minus.gif') != -1)
  {
    $(i).attr('src', 'plus.gif');
    $(s).hide('slow');
  }
  else
  {
    $(i).attr('src', 'minus.gif');
    $(s).show('slow');
  }
}

