<script type="text/javascript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function popupwindow(url)
{
   mywindow = window.open(url, 'Hoved','status=no,toolbar=no,location=yes,menubar=no,scrollbars=yes,resizable=yes, left=150,top=50,width=800,height=750');
                mywindow.location = url;

	if (mywindow.frames.length!=0)
	mywindow.location=mywindow.document.location;
	mywindow.moveTo(0,0);
	mywindow.resizeTo(screen.availWidth,screen.availHeight);
}
-->
</script>

<script type="text/javascript">
<!--
window.onerror=logError;

browserCapable = (document.all);


/**********************************************************************
 * Entry Points
 */ 

function beforeLoad()
{
  if (browserCapable)
  {
    menus_BeforeLoad();
  }
}


function afterLoad()
{
  if (browserCapable)
  {
    menus_AfterLoad();
  }
}


var thisLink;

var parentLink;

function menus_BeforeLoad()
{
  if (browserCapable)
  {
    //****************************************
    //establish the target link

    var href = typeof parentPage != 'undefined' ? parentPage.length > 0 ? filename(parentPage) 
                                                : ''                    : '' ;
    parentLink = href.length != 0

    if (!parentLink) href = filename(window.location.pathname);


    //****************************************
    //look for the target link in level 1

    if (document.all.menuitem1)
    {
      if (document.all.menuitem1.length)
      {
        for (i=0; i<document.all.menuitem1.length; i++)
        {
          link = document.all.menuitem1[i];

          if (link && link.pathname)
          {
            if (href == filename(link.pathname))
            {
              thisLink = link;
              break;
            }
          }
        }
      }
      else
      {
        link = document.all("menuitem1");

        if (link && link.pathname)
        {
          if (href == filename(link.pathname))
          {
            thisLink = link;
          }
        }
      }
    }

    //****************************************
    //look for the target link in level 2

    if (!thisLink)
    {
      if (document.all.menuitem2)
      {
        for (i=0; i<document.all.menuitem2.length; i++)
        {
          link = document.all.menuitem2[i];
    
          if (link && link.pathname)
          {
            if (href == filename(link.pathname))
            {
              thisLink = link;
              break;
            }
          }
        }
      }
    }

    //****************************************
    //if level 2s previously open or contains target link
    //then open otherwise close

    if (document.all.menu1)
    {
      for (i=0; i<document.all.menu1.length; i++)
      {
        source = document.all.menu1[i];

        if (source)
        {
          source.custom = i;          

          submenu = source.all("menu2");

          if (submenu)
          {
            handle = source.all(0);
  
            handle.style.cursor = "hand";

            openMenu = thisLink ? source.contains(thisLink) 
                                : false;

            if (document.cookie.indexOf("menu" + i + "=1") != -1) openMenu = true;

            if (openMenu)
            {
              document.cookie = "menu" + source.custom + "=1";

               submenu.style.display = "";
             }
            else
            {
           
              submenu.style.display = "none";
            
            }
          }
        }
      }
    }
  }
}


function menus_AfterLoad()
{
  //****************************************
  //highlight the current menu item
  //note we do this stuff here for IE4.0 compatibility, in IE5.0 we can do it earlier

  if (browserCapable)
  {
    if (thisLink) 
    {
      //insert pointer graphic to current link

      thisLink.insertAdjacentHTML('AfterEnd', 
                                  (thisLink.id == "menuitem1" ? ""
                                                              : ""));

      //if the page matches the menu link and is not a child page then kill the link

      if (!parentLink) thisLink.outerHTML = "<em class=thispage>" + thisLink.innerHTML + "</em>";
    }
  }
}


function toggleMenu1(source)
{
  //****************************************
  //toggle menu between open and closed states

  if (browserCapable)
  {
    if (source)
    {
      submenu = source.all("menu2");

      if (submenu)
      {    
        handle = source.all(0);

        if (submenu.style.display == "")
        {
			document.cookie = "menu" + source.custom + "=0"

	        submenu.style.display = "none";
        }
        else
        {
          document.cookie = "menu" + source.custom + "=1"

          submenu.style.display = "";
        }
      }
    }
  }
}

function toggleMenu2(source)
{
  //****************************************
  //toggle menu between open and closed states

  if (browserCapable)
  {
    if (source)
    {
      submenu = source.all("menu2");

      if (submenu)
      {    
        handle = source.all(0);

        if (submenu.style.display == "")
        {
          document.cookie = "menu" + source.custom + "=0"

          submenu.style.display = "none";
        }
        else
        {
          document.cookie = "menu" + source.custom + "=1"

          submenu.style.display = "";
        }
      }
    }
  }
}

function filename(path)
{
  //****************************************
  //extract terminal filename from pathname

  href = path.substr(path.lastIndexOf('\\') + 1);
  href = href.substr(href.lastIndexOf('/') + 1);
  href = unescape(href.toLowerCase());
  if (href.length == 0) href = "index.html"
  return href;
}


/**********************************************************************
 * Error Handler and Logger
 */ 

var firstMessage = true;
var firstError = true;

function logError(message, url, line)
{
  if (firstError)
  {
    firstError = false;

    log('<b>JavaScript Errors</b><hr>', false);

    log('browser: ' + navigator.userAgent)
    log('page: ' + url + '<hr>', false);
  }

  log('line: ' + line);
  log(message + '<hr>', false);
  return false;
}


/*function log(message)
{
  var JSConsole = window.open("", "CirkadiaJSConsole", "height=400,width=300,scrollbars,resizable");

  JSConsole.focus();

  var d = JSConsole.document;

  if (firstMessage)
  {
    firstMessage = false;

    d.open();
    d.writeln('<title>Cirkadia JavaScript Console</title>');
  }

  d.writeln(message + (arguments.length == 1 ? '<br>' : ''));

  JSConsole.scrollBy(0, 1000);
}*/
-->
</script>

