﻿
//window.onresize = resizeWindow;
//window.onload = resizeWindow;

//function resizeWindow()
//{
//  el = document.getElementById("lnavdiv");
//  if (el!=null) return;
 
//  if (el!=null) return;

//  t1 = document.getElementById("tleft");  
//  t2 = document.getElementById("tright");  
  
//  w = t1.offsetWidth + t2.offsetWidth;
//  w1  = Math.round (w / 2);
//  t1.setAttribute ("width",w1);
//  t2.setAttribute ("width",w - w1);
//}



function getYPos(elemId) 
{
      elem = document.getElementById(elemId);
      if (elem == null) return 0;
      var yPos = 0;
      if (elem.offsetParent)
      {
            while (elem.offsetParent)
            {
                  yPos += elem.offsetTop
                  elem = elem.offsetParent;
            }
      }
      else if (elem.y)
            yPos += elem.y;
      return yPos;
}

function getXPos(elemId) {
      elem = document.getElementById(elemId);
      if (elem == null) return 0;
      var xPos = 0;
      if (elem.offsetParent) 
      {
            while (elem.offsetParent) 
            {
                  xPos += elem.offsetLeft
                  elem = elem.offsetParent;
            }
      }
      else if (elem.x)
            xPos += elem.x;
      return xPos;
}

var ImageIndex =0 

function setLargeImagePos(ImageNum)
{
  _in = 'imginner' + ImageNum;
  _mid = 'imgmidder' + ImageNum;
  _out = 'imgouter' + ImageNum;
  _img = 'imgimage' + ImageNum;
  if (document.getElementById) 
  {
      sp = getXPos('tright')
    if (sp<=getXPos(_in)) 
    { // right side
        newpos = getXPos(_in) + document.getElementById(_in).offsetWidth / 2 - document.getElementById(_img).offsetWidth / 2;
      document.getElementById(_out).style.left= newpos + "px"
    }
    else
    {
      document.getElementById(_out).style.left = getXPos(_in);
    };
    document.getElementById(_out).style.top =  getYPos(_in) + "px"; 
  }
}

function showLargeImage(ImageNum)
{
  _out = 'imgouter'  + ImageNum;
  setLargeImagePos (ImageNum);
  document.getElementById(_out).style.visibility = 'visible'; 
}


function hideLargeImage(ImageNum)
{
  if (document.getElementById) 
  { 
    document.getElementById('imgouter' + ImageNum).style.visibility = 'hidden'; 
  }; 
}



function displayImage(Url, AltText, iWidth)
{
  ImageIndex = ImageIndex +1 ;
  document.writeln('<table id="imginner' +ImageIndex + '" style="margin-left:auto; margin-right:auto; float:none; z-index :2;" ><tr><td>');
  document.writeln('<b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b>');
  document.writeln('<div  style="background-color: #E8E8E8; padding: 7px 7px 0px 7px;">');
  document.writeln('  <table align="center" >');
  document.writeln('    <tr><td align="center"><img  width="' +iWidth + '" onclick = "javascript:showLargeImage(' +ImageIndex + ')" src="' +Url + '" alt="' +AltText + '" /></td></tr>');
  document.writeln('    <tr><td align="center"><div class="lesser"  onclick = "javascript:showLargeImage(' +ImageIndex + ')">Click image for full size.</div></td></tr>');
  document.writeln('  </table>');
  document.writeln('</div><b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b>');
  document.writeln('</td></tr></table>');
     

  document.writeln('<div id="imgouter' +ImageIndex + '" style="width: 1px; overflow :visible; position:absolute ;  z-index:3; visibility:hidden ">');
  document.writeln('<div id="imgmidder' +ImageIndex + '" style="float:left" >');
  document.writeln('<b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b>');
  document.writeln('<div  style="background-color: #E8E8E8; padding: 10px 5px 0px 5px;">');
  document.writeln('<table align="center" >');
  document.writeln('<tr><td align="center"><img id="imgimage'+ImageIndex+'" style="padding:0px 10px 0px 10px" onclick = "javascript:hideLargeImage(' +ImageIndex + ')" src="'+Url+'" alt="'+AltText +'" /></td></tr>');
  document.writeln('<tr><td align = "center" ><div class="lesser" onclick = "javascript:hideLargeImage(' +ImageIndex + ')">Click image to dismiss.</div></td></tr>');
  document.writeln('</table>');
  document.writeln('</div>');
  document.writeln('<b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b>');
  document.writeln('</div>');
  document.writeln('</div>');
  
  setLargeImagePos(ImageIndex)

}


function ShowHideId(elemId)
{
  elem = document.getElementById(elemId);
  newDisplay = 'none';
  if (elem.style.display=='none') { newDisplay = 'block'; };
  elem.style.display = newDisplay; 
}


