﻿// imgs_layout.js

//----------------------------------------------------
// Control of enlarged windows
//----------------------------------------------------
// Class definition
function PopupObject() {
    var ID;        // ID of interval timer.
    var newWin;    // Reference to 'pop up window'.
    var divRef;    // Reference to 'loading' <div>.
    this.SetImgWinParams = setImgWinParams;
    
    /* See note 5/24/2010 below.
    ShowProgress;
    function ShowProgress() {
        // Following line replaces the whole content of the
        // pop up window.
        // document.write("This is a test");
        //
        //document.write("Reached");
        
        if (pop.newWin.document.images.complete) {
            pop.divRef.innerHTML = "               ";
            // window.ClearInterval(ID);
            return 1;
        }
        return 0;
    }
    */
}

function setImgWinParams(imgSrc) {
    
    newWin = window.open("", "Enlarged", "toolbar=no,locationbar=no");
    
    // window.alert(screen.availWidth + "x" + screen.availHeight);
    // window.alert(screen.width + "x" + screen.height);
    // Set size.
    var newWinWidth = screen.availWidth - 210;
    var newWinHeight = screen.availHeight - 110;
    newWin.resizeTo(newWinWidth, newWinHeight);

    // Set location.
    var newWinLeft =
    Math.round((screen.availWidth - newWinWidth) / 2);
    var newWinTop = 
    Math.round((screen.availHeight - newWinHeight) / 2);
    newWin.moveTo(newWinLeft, newWinTop);
    newWin.focus();


    // See not 5/24/2010 below. 
//    newWin.document.write('<div id="loading" style="' 
//     + 'position: absolute;'
//     + 'location: no;'
//     + 'left:' + /*400*/ 12 + 'px;'
//     + 'top:' + /*85*/ 40 + 'px;'
//     + 'color: blue;" >');
//     newWin.document.write('loading...');
//     newWin.document.write('</div>');
//    divRef = newWin.document.getElementById("loading");
//    divRef.innerHTML = "Erasing Loading"; // for test

    
    // Load image into window.
    newWin.document.write('<img src="' + imgSrc + '">');

    /* 5/24/2010 Decided to load 1024 size images upon entering 
    window. Popup of each image shows the progress report. 
    Upon enlarging the image is already in buffer memory, 
    hence it loads fast.
    */

    /* See note 5/24/2010 above.
    ID = window.setInterval("ShowProgress();", 100);
    or
    for ( ; ; ) {
        var Done = 0;
        ShowProgress();
        if (Done == 1) {
        return;
        }
    }
    */
}

var pop = new PopupObject();

//-----------------------------------------
function showImg(hrefVal, description) 
{
    document.write('<a href="hrefVal"'
        + 'onclick="pop.SetImgWinParams(this.href); return false;">');
    docment.write('<img src="hrefVal" alt="description" class = "styleImg"/>');
    docment.write('</a>');
}

/*
<a href="images/DSC00295.JPG"
onclick="pop.SetImgWinParams(this.href);
return false;">
<img src="images/DSC00295.JPG" 
alt="Ivrit Alfon and Ivrit Min Hahatchala
"
class = "styleImg"/>
</a>
*/

//-----------------------------------------

//----------------------------------------------------


//    setTimeout("newWin.document.write('Done')", 500);


/* ------------------------------------------------------------   
        <a href="../images/Yadaim/yadaim1.JPG"
            onclick="Test()">
            <img src="../images/Yadaim/yadaim1.JPG"
            alt="Yadaim Page" class = "styleImg" />
        </a>

        <a href="../images/Yadaim/yadaim1.JPG" 
            onclick= "window.open (this.href, 'child', 
            'height=500,width=400,left=200,top=200'); 
            return false;">
            <img alt="Yadaim Page" class = "styleImg"
            src="../images/Yadaim/yadaim1.JPG"/>
        </a>
*/                    

/*    
Old way
        <a href="../images/Yadaim/yadaim1.JPG">
        <img src="../images/Yadaim/yadaim1.JPG" 
        alt="Assorted yadaim
        "
        class = "styleImg"/>
        </a>
*/                  

/* 
Works, same window and needs one click to enlarge in 
place and double click to reduce.                

        <img src="../images/Yadaim/yadaim1.JPG" 
        width="150" height="200"  
        onclick="this.src='../images/Yadaim/yadaim1.JPG';
        this.height=400; this.width=300" 
        ondblclick="this.src='../images/Yadaim/yadaim1.JPG';
        this.height=200;this.width=150">
*/                    

