// Toolbox of Javascript funtionality
// Last updated 2 June 2005
// Author: Rob Hale

function setCookie(name, value, days)
{     
  millisecs = 1000 * 60 * 60 * 24 * eval(days)     
  expire = new Date();     
  expire.setTime (expire.getTime() + millisecs);     
  document.cookie = name + '=' + escape(value) +  '; expires=' + expire.toGMTString() + '; path=/';  
}

function getCookieVal(offset)
{
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  {
    endstr = document.cookie.length;
  }
  return unescape(document.cookie.substring(offset, endstr));
}

function getCookie(name)
{
  var arg = name + '=';
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen)
  {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
    {
      return getCookieVal (j);
    }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0)
    {
      break;
    }
  }
  return null;
}

function tmt_winLaunch(theURL, winName, targetName, features)
{ 
  eval(winName + "=window.open('" + theURL + "','" + targetName + "','" + features + "')");
}

function tmt_winComm(bers, ord)
{
  return eval(bers + "." + ord);
}

function showNTPLCredit(pictureNumber)
{
  tmt_winLaunch('/shared/ntplcredit.asp?number=' + escape(pictureNumber),'credits','credits','width=400,height=240,resizable=yes');
  credits.focus();
}

function showPictureCredit(pictureBox)
{
  tmt_winLaunch(pictureBox, 'credits','credits','width=400,height=180,resizable=yes');
  credits.focus();
}

function showPictureCredit2(credit, caption, ref)
{
  tmt_winLaunch('/shared/pictureCredit.asp?credit=' + escape(credit) + '&caption=' + escape(caption) + '&ref=' + escape(ref), 'credits','credits','width=400,height=180,resizable=yes');
  credits.focus();
}