var xmlHttp;

function showThumb(encIID, alt){
    img = document.getElementById("baseThumb");
    img.src = "include/thumbnail.php?IID=" + encIID + "&type=M";
    setIID(encIID);
    anchor = document.getElementById("baseAnchor");
    anchor.title = alt;
    anchor.onclick = function () {enlargeThumb("'" + encIID + "'", alt);return(false);}
}

function enlargeThumb(encIID, alt){    
    showThumb(encIID, alt);
    imgsrc = "include/thumbnail.php?IID=" + encIID + "&type=L"
    showLightbox(imgsrc, alt);
}

function getIID(){
    anchor = document.getElementById("baseAnchor");
    IID = anchor.rel;
    return IID;
}

function setIID(encIID){
    anchor = document.getElementById("baseAnchor");
    anchor.rel = encIID;
}

function printImage(encIID){
    window.open('print/printImage.php?IID=' + encIID, '__', 'width=800, height=650, resizable=1, scrollbars=1, menubar=1');
}

function printRE(REID){
    window.open('print/printRE.php?REID=' + REID, '__', 'width=800, height=650, resizable=1, scrollbars=1, menubar=1, toolbar=0, status=0, location=0');
}

function PDFRE(REID){
    window.open('print/PDFRE.php?REID=' + REID, '__', 'width=800, height=650, resizable=1, scrollbars=1, menubar=1, toolbar=0, status=0, location=0');
}

function updateLightbox(encIID, type){
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
        alert ("Browser does not support HTTP Request");
        return;
    } 
    url="include/updatelb.php?IID=" + encIID + "&type=" + type;
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
} 

function stateChanged() { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
        temp = xmlHttp.responseText;
        valArray = temp.split("{;}");
        encIID = valArray[0];
        alt = valArray[1];
        setIID(encIID);
        //alert(encIID + ' - ' + alt);
        enlargeThumb(encIID, alt);
    } 
} 

function GetXmlHttpObject(){ 
    var objXMLHttp=null
    if (window.XMLHttpRequest){
        objXMLHttp=new XMLHttpRequest()
    } else if (window.ActiveXObject){
        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
    return objXMLHttp;
} 

