document.write("<div id='popImgWindow' class='divFixed' style='display:none;' onSelectStart=this.style.cursor='not-allowed'; align='center'></div>");
document.write("<style type='text/css'>");
document.write(".popImageIn { ");
document.write("  cursor: url('/images/cursors/zoomin.cur'),default;");
document.write("  border-top-style: dashed;");
document.write("  border-bottom-style: dashed;");
document.write("  border-left-style: dashed;");
document.write("  border-right-style: dashed;");
document.write("  border-top-width: 2px;");
document.write("  border-bottom-width: 2px;");
document.write("  border-left-width: 2px;");
document.write("  border-right-width: 2px;");
document.write("  border-color: #bbbbbb;");
document.write("  margin-right: 5px;");
document.write("  margin-left: 5px;");
document.write("}");
document.write(".popImageOut { ");
document.write("  cursor: url('/images/cursors/zoomout.cur'),default;");
document.write("}");
document.write("#divFixed { ");
document.write("  position: absolute;");
document.write("  top: expression(0+((e=document.documentElement.scrollTop)?e:document.body.scrollTop)+'px');")
document.write("  left: expression(0+((e=document.documentElement.scrollLeft)?e:document.body.scrollLeft)+'px');");
document.write("}");
document.write("</style>");

function openPopImage(id,pic,width,height)
{
    winW = 0;
    if (typeof window.innerWidth != 'undefined')
    {
        winW = window.innerWidth-20;
        winH = window.innerHeight-20;
    }
    else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
    {
        winW = document.documentElement.clientWidth;
        winH = document.documentElement.clientHeight;
    }
    else
    {
        winW = document.getElementsByTagName('body')[0].clientWidth;
        winH = document.getElementsByTagName('body')[0].clientHeight;
    }
    document.getElementById(id).style.filter = "alpha(opacity=50)";
    document.getElementById(id).style.MozOpacity = "0.5";
    if (navigator.appVersion.indexOf("MSIE 6")!=-1)
    {
        document.getElementById("popImgWindow").style.position = 'absolute';
    }
    else
    {
        document.getElementById("popImgWindow").style.position = 'absolute';
    }
    document.getElementById("popImgWindow").style.left = (winW-width)/2 +"px";
    document.getElementById("popImgWindow").style.top = (winH-height)/2 +"px";
    document.getElementById("popImgWindow").style.display = "block";
    document.getElementById("popImgWindow").innerHTML = "<br><br><br><img src=http://www.chuckontour.ca/images/loading_text.gif width=86 height=15>"
    document.getElementById("popImgWindow").style.backgroundImage = "url('http://www.chuckontour.ca/resizeImg.asp?filename=http://www.chuckontour.ca/"+ pic +"&height="+ height +"&width="+ width +"')";
    document.getElementById("popImgWindow").style.height = height +"px";
    document.getElementById("popImgWindow").style.width = width +"px";
    document.getElementById("popImgWindow").style.borderBottomStyle = "outset";
    document.getElementById("popImgWindow").style.borderBottomWidth = 6 +"px";
    document.getElementById("popImgWindow").style.borderLeftStyle = "outset";
    document.getElementById("popImgWindow").style.borderLeftWidth = 6 +"px";
    document.getElementById("popImgWindow").style.borderRightStyle = "outset";
    document.getElementById("popImgWindow").style.borderRightWidth = 6 +"px";
    document.getElementById("popImgWindow").style.borderTopStyle = "outset";
    document.getElementById("popImgWindow").style.borderTopWidth = 6 +"px";
    document.getElementById("popImgWindow").style.cursor = "url('/images/cursors/zoomout.cur'),default";
    document.getElementById("popImgWindow").title = "Click to close image";
    document.getElementById("popImgWindow").onclick = function() { closePopImage(id); };
    setTimeout("hideLoadingMessage()", 800);
  }
  function closePopImage(id)
  {
    document.getElementById("popImgWindow").style.display = "none";
    document.getElementById(id).style.filter = "alpha(opacity=100)";
    document.getElementById(id).style.MozOpacity = "1.0";
  }
  function hideLoadingMessage()
  {
    document.getElementById("popImgWindow").innerHTML = " ";
  }
  function checkPopImage(e)
  {
    winW = 0;
    winW = (!document.all)?window.innerWidth-20:document.documentElement.clientWidth;
    winH = (!document.all)?window.innerHeight-20:document.documentElement.clientHeight;

    TMP_top = (document.getElementById("popImgWindow").offsetTop) ;
    TMP_bottom = (TMP_top + document.getElementById("popImgWindow").offsetHeight);
    TMP_left = (document.getElementById("popImgWindow").offsetLeft) ;
    TMP_right = (TMP_left + document.getElementById("popImgWindow").offsetWidth);

    if (document.getElementById("popImgWindow").style.display == "block")
    {
      if (event.button == 1)
      {
        if ((event.x >= TMP_left && event.y >= TMP_top) && (event.x <= TMP_right && event.y <= TMP_bottom))
        {
          return true;
        }
        else
        {
          alert("Please close image window to continue.");
        }
      }
    }
  }

  if (document.layers) 
  {
      document.captureEvents(Event.MOUSEDOWN);
  }
  document.onmousedown=checkPopImage;
