﻿function zoom(id) {
    //Thumbnail Photo Click Event    

    var newsrc //For New src Attribute
    var srclen //To Store src Attribute String Length
    var screenwidth //To Store Screen Width
    var screenheight //To Store Screen Height
    var left //To Store Left Pixel
    var top //To Store Top Pixel

    //Obtain src from Clicked img, Convert to Zoomed Image
    srclen = document.getElementById(id).getAttribute("src").length
    newsrc = document.getElementById(id).getAttribute("src")
    newsrc = newsrc.slice(0, srclen - 4) + "_zoom.jpg"

    //Change src Attribute for Zoomed img element        
    document.getElementById("photozoom").setAttribute("src", newsrc)

    //Calculate Screen Width and Height to Determine Position
    screenwidth = screen.width
    left = (screenwidth - 800) / 2
    screenheight = screen.height
    top = (screenheight - 600) / 3
    document.getElementById("photoframe").style.top = top + "px"
    document.getElementById("photoframe").style.left = left + "px"

    //Make Zoomed Photo Elements Visible
    document.getElementById("blackout").style.height = getDocHeight()
    document.getElementById("photoframe").style.visibility = "visible"
    document.getElementById("blackout").style.visibility = "visible"
}

function closezoom() {
    //Zoomed Image Button Click Event    

    //Make Zoomed Photo Elements NOT Visible
    document.getElementById("photozoom").setAttribute("src", "/images/loading.jpg")
    document.getElementById("photoframe").style.visibility = "hidden"
    document.getElementById("blackout").style.visibility = "hidden"
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}
