var current_page=window.document.location.href;
current_page=current_page.split("/");
current_page=current_page[current_page.length-1];

/* The following script checks to make sure the user is in the gallery */
/* window when browsing the E-Gallery */

/* Also, code for disabling all but left-clicking can be added below */


if (current_page.indexOf("index.html") == -1 && current_page.indexOf("fullimage.html") == -1)
{
  if (top.window.name != "gallery")
  {
    document.location.replace("index.html");
  }
  else
    {
      var pchk=unescape(document.cookie);
      pchk=pchk.split("=");
      pchk=pchk[1];
      if (pchk != "true")
      {
        window.document.location.replace("index.html");
      }
    }
}

var gallery_win;

function launch_gallery()
{
  if (!gallery_win)
  {
    document.cookie="InGallery=" + escape('true') + ";path=/;";
    gallery_win=window.open('terms.html','gallery','width=790,height=570,top=0,left=0,resizable=no');
    gallery_win.focus();
  }
  else if (gallery_win.closed)
        {
          document.cookie="InGallery=" + escape('true') + ";path=/;";
          gallery_win=window.open('terms.html','gallery','width=790,height=570,top=0,left=0,resizable=no');
          gallery_win.focus();
        }
        else
          {
            alert("You are already in the E-Gallery!\nReturning to your current session...");
            gallery_win.focus();
          }
}

/* code to disable right-clicks, text selects and KeyPresses */

var message="";
function clickIE()
{
  if (document.all) 
  {
    (message);
    return false;
  }
}

function clickNS(e)
{
  if (document.layers || (document.getElementById&&!document.all))
  {
    if (e.which==1 || e.which==2 || e.which==3)
    {
      (message);
      return false;
    }
  }
}

if (document.layers) 
{
  document.captureEvents(Event.MOUSEDOWN);
  document.onmousedown=clickNS;
}
else
  {
    document.onmouseup=clickNS;
    document.oncontextmenu=clickIE;
  }

document.oncontextmenu=new Function("return false;")

function disableselect(e)
{
  return false;
}

function reEnable()
{
  return true;
}

document.onselectstart=new Function ("return false");

if (window.sidebar)
{
  document.onmousedown=disableselect;
  document.onclick=reEnable;
}

/* End click protect */