﻿// JScript File
    
var s;
var WhichImageOpen = "";
var x = "";
var AltURL = "";
var PictureClick = "False";

function MouseOverPicture(pic, url) 
{
    x = pic;
    AltURL = url;
    
    if (x.id == WhichImageOpen)
    {
        window.status = "Click to close picture.";
        x.title = "Click to close picture.";
    }
    else 
    {
        window.status = "Click for larger image.";
        x.title = "Click for larger image.";
    }

    return true;
}

function MouseOutPicture(pic, url)
{
    x = pic;
    AltURL = url;

    if (WhichImageOpen == "")
    {
        window.status = "";
    }
    else 
    {
        window.status = "Click to close picture.";
    }

    return true;
}

function MouseClickPicture(pic, url)
{
    x = pic;
    AltURL = url;

    PictureClick = "True";

    Zoom();
    return true;
}

function BodyClick()
{
    if (PictureClick == "True")
    {
        PictureClick = "False";
    }
    else
    {
        ClearZoom();
    }

    return true;
}

function Zoom()
{
    var img;
    var TopTable;
    var xLeft;

    //the clearzoom function is called for a div (or body element, if so coded) click
    //if a picture is clicked, cancel the event so that the higher div onclick
    //does not clear the zoom
    //event.cancelBubble = true
    //replaced by "PictureClick"

    //if we are re-clicking on the source picture, then
    //close the zoom picture
    //otherwise open the zoom picture
    if (x.id == WhichImageOpen)
    {
        ClearZoom();
        return true;
    }

    WhichImageOpen = x.id;
    window.status = "Click to close picture.";
    x.title = "Click to close picture.";
    img = document.ZoomImage;

    if (AltURL) {
        img.src = AltURL;
    }
    else {
        img.src = x.src;
    }

    TopTable = document.getElementById("TopTable");

//alert(TopTable.offsetWidth)
//alert(x.offsetWidth)



    //xLeft = (document.body.offsetWidth - 1002) / 2
    //subtract table width from screen width
    xLeft = (document.body.offsetWidth - 778) / 2;
    
    if (xLeft < 0)
    {
        xLeft = 0;
    }


    //mac needs "px", ie does not
    //img.style.left = xLeft + x.width + 10 + "px"
    img.style.left = xLeft + 10 + "px";

    FloatPicture();
    img.style.visibility = "visible";
//    s = window.setInterval('floatpicture()', 100);

    return true;
}    
    
function ClearZoom()
{
    WhichImageOpen = "";
    window.status = "Click for larger image.";
    x.title = "Click for larger image.";
    document.ZoomImage.style.visibility = "hidden";
    document.ZoomImage.style.left = "-2500px";
//    window.clearInterval(s);

    return true;
}

function FloatPicture()
{
  
// set the top of the picture  
  
  	if (window.innerHeight)
	{
	    //mac
	    pos = window.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
	    pos = document.documentElement.scrollTop;
	}
	else if (document.body)
	{
	    pos = document.body.scrollTop;
	}

  
    if (pos < 90)
    {
        //ie
        pos = 90;
    }

    pos = pos + 10;
    
    //mac needs "px", ie does not
    document.ZoomImage.style.top = pos + "px";
    
 //   alert(pos)

    return true;

}



