// Document on load

function docOnLoad()
{
 // stub code
}

// Document on unload

function docOnUnload()
{
 // stub code
}

// Get Section Index functions

function getIndexPage(p)
{
 var slashindex = window.location.href.lastIndexOf("/");
 var hometext = "Back to NHS Exposed Home</A>";
 var homelink = "<A HREF='http://www.nhs-exposed.com' CLASS='SNML'>";
 var imagelink = "<IMG SRC='images/backarrow2white.gif' ALT='Back' WIDTH='26' HEIGHT='16' ALIGN='ABSMIDDLE' HSPACE='2' BORDER='0'></A>";
 if ((slashindex > -1) && (slashindex < window.location.href.length))
 {
  if (window.location.href.substring(slashindex+1,window.location.href.length) == "index.shtml") 
  {
   return homelink + imagelink + homelink + hometext;
  }
  else
  {
   var indexlink = "<A HREF='"+window.location.href.substring(0,slashindex)+"/index.shtml' CLASS='SNML'>";
   return indexlink + imagelink + indexlink + p + "</A>";
  }
 }
 else
 {
  return homelink + imagelink + homelink + hometext;
 }
}


// Mail To Friend functions

function testemail(t)
{
 var atindex = t.indexOf("@");
 var maillength = t.length;
 if (atindex>=1)
 {
  if ((atindex+1) != (maillength))
  {
   var username = t.substring(0,atindex);
   var domainname = t.substring(atindex+1,maillength);
   var dotindex = domainname.lastIndexOf(".");
   if (dotindex > 0)
   {
    if ((dotindex == (domainname.length - 3)) || (dotindex == (domainname.length -4)))
    {
     return true;
    }
    else
    {
     return false;
    }
   }
   else
   {
    return false;
   }
  }
  else
  {
   return false;
  }
 }
 else
 {
  return false;
 }
}

function validate()
{
 if (document.mailform.yourname.value=="")
 {
  alert ("You must fill in your name!")
  document.mailform.yourname.focus()
  return false
 }
 else
 {
  if (!testemail(document.mailform.youremail.value))
  {
   alert("Please input your email address!") 
   document.mailform.youremail.focus()
   return false
  }
  else
  {
   if (document.mailform.friendname.value=="")
   {
    alert ("You must fill in the name of your friend!")
    document.mailform.friendname.focus()
    return false
   }
   else
   {
    if (!testemail(document.mailform.friendemail.value))
    {
     alert("Please input your friends email address!") 
     document.mailform.friendemail.focus()
     return false
    }
    else
    {
     document.mailform.referer.value=window.opener.location
    }
   }   
  }
 }
}

function cancelbutton()
{
 window.close()
}

function centerwin()
{
window.moveTo(screen.width/2-140,screen.height/2-95)
window.document.mailform.yourname.focus()
}

// Popup Window Functions

function centerwin2(w,h)
{
// window.moveTo(screen.width/2-w/2,screen.height/2-h/2)
window.moveTo((screen.width-w)/2,(screen.height-h)/2)
}

function CloseWin()
{
 parent.close()
}

function popupIt(cn,picfile)
{
 var picname = window.location.href;
 slashindex = picname.lastIndexOf("/");
 if (slashindex > -1)
 {
  picname = picname.substring(0,slashindex) + "/"+picfile;
  popupWin=window.open('http://www.nhsexposed.com/pcgi-bin/dialogs/popupwinframes.cgi?CN='+cn+'&P='+picname+'&W=550&H=500','','width=550,height=500')
 }
}

function popupFile(cn,fname)
{
 var filename = window.location.href;
 slashindex = filename.lastIndexOf("/");
 if (slashindex > -1)
 {
  filename = filename.substring(0,slashindex) + "/"+fname;
  popupWin=window.open('http://www.nhsexposed.com/pcgi-bin/dialogs/popupfileframes.cgi?CN='+cn+'&P='+filename+'&W=550&H=500','','width=550,height=500')
 }
}


