var lhPix = new Array("images/photos/0.jpg",
                "images/photos/1.jpg",
                "images/photos/2.jpg",
                "images/photos/3.jpg",
                "images/photos/4.jpg",
                "images/photos/5.jpg",
                "images/photos/6.jpg",
                "images/photos/7.jpg",
                "images/photos/8.jpg",
                "images/photos/9.jpg",
                "images/photos/10.jpg",
                "images/photos/11.jpg",
                "images/photos/12.jpg"
                );
var lhPixText = new Array("Welcomes Road");
var picPointer = 0;

function picForward(picName,callType) {
    //alert("picName.src = " + picName.src);

    picPointer = (++picPointer) % lhPix.length;
    picName.src = lhPix[picPointer];

    //Change text
    picText.innerHTML = getTheText();

    //Change opener's pic if thePictureWindow's pic changes
    if (callType=="Remote") {
        document.images['lhColImg'].src = "./lh_pix/" + lhPix[picPointer];
        thePictureWindow.bigPicText.innerHTML = getTheText();
        thePictureWindow.focus();
    }
}

function picBackward(picName,callType) {
    //alert("picName.src = " + picName.src);

    if (picPointer==0) {
        picPointer = lhPix.length-1;
    } else {
        --picPointer;
    }
    picName.src = lhPix[picPointer];

    //Change text
    picText.innerHTML = getTheText();

    //Change opener's pic if thePictureWindow's pic changes
    if (callType=="Remote") {
        document.images['lhColImg'].src = "./lh_pix/" + lhPix[picPointer];
        thePictureWindow.bigPicText.innerHTML = getTheText();
        thePictureWindow.focus();
    }
}


function getTheText() {
    //This function gets the corresponding text caption
    //from the picPointer value
    var theText = "";
    //if (picPointer <= 6) {
        theText = lhPixText[0];
    //}
    //else if (picPointer >= 7) {
    //	theText = lhPixText[1];
    //}
    //else {
    //	theText = "Picture Caption Here";
    //}

    //OK to display it on THIS page in forward/backward functions
    //BUT how to display it on thePictureWindow???

    return theText;
}

var $picWindowOpen = false;

function picWin() {
    thePictureWindow = window.open("picWin.htm","Pictures","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=466,height=341");
    $picWindowOpen = true;
}

function cleanUp() {

    if($picWindowOpen) {
        thePictureWindow.close();
        $picWindowOpen = false;
    }
}
