  var dimages = new Array();
    var req;
    var vImages = new Array();
    var nImages = 0;
    var t;
    var tt;
    var timer = null;
    var WinRef;
    var newWindow;
    var cnt = -1;   //incrementing counter for images slide show. -1 is for selecting winner as opening image
    var strDetails = "";
    var firstImage = true;

    var tbl1;

    var end_opacity = 50; //end opacity, 25 = 25%, 50 = 50%, 100 = 100%, etc.
    var increase_opacity_by = 10; //how much to increase by each time the timeout ends
    var timeout = 100; //timeout in milliseconds, 0 = instant fade-out
    var win;            //= document.getElementById("thewindow");
    var winbackground;          //= document.getElementById("thewindowbackground");
    var wincontent;                 //= document.getElementById("thewindowcontent");
    var cur_opacity = 0;
    var logo = "Pembroke Pines Art Guild";
    var msg = "";
    var R1C1innerHTML = "";

function wm_onmouseover(obj) {
    obj.style.textDecoration = 'underline';
    }

function wm_onmouseout(obj) {
    obj.style.textDecoration = 'none';
    }

function wm_click(obj) {
    window.location = "mailto:Marianne@nidm.org";
    }

function UnTt() {
    clearTimeout(tt);
    UnTip();
    }

function curImage_onmouseover(obj) {
    obj.style.borderColor = '#C0C0C0';          //Grey
    UnTt();
    clearTimeout(t);
    Tip("Slide Show on Hold...");
    tt = setTimeout("UnTt()",1500);
    }

function curImage_onmouseout(obj) {
    obj.style.borderColor = 'rgb(220,220,220)';     //Off-White
    UnTt();
    t = setTimeout("swapPicture()", 3500);
    Tip("Slide Show Proceeding...");
    tt = setTimeout("UnTt()",1500);
    if (typeof(win) == "object") {
        if (win.style.display !== "none") {
            clearTimeout(t);
            UnTt();
            }
        }
    }

function curImage_onmousedown(obj) {
    clearTimeout(t);
    if (strDetails.length > 0) {
        //document.getElementById("details").innerHTML = strDetails;
        strDetails = "";
        }
    showWindow();
    }

function img_onmouseover(obj) {
    clearTimeout(t);
    obj.style.borderColor = 'rgb(220,220,220';          //Silver
    obj.style.backgroundColor = 'rgb(0,150,150)';
    Tip('Slide Show on Hold...');
    }

function img_onmouseout(obj) {
    obj.style.borderColor = '#AAAAAA';      //lighter silver
    obj.style.backgroundColor = 'Transparent';
    t = setTimeout("swapPicture()", 3500);
    Tip('Slide Show Proceeding...');
    }

function btn_click(obj) {
    clearTimeout(t);            //always stop Slide Show
    //select target button
    var openPage = "";
    switch (obj) {          //obj is innerText, eg, Slides
    case ("Home"): {
        txt = obj.toLowerCase();
        if (txt.indexOf("home") == 0) {         //return to Home page
            openPage = "Default.html";
            }
        break;
        }
    case ("Slide Show"): {
           //superimpose Window with info about controlling Slide Show
            //assemble HTML for about window
            // only show instructions for controlling slide show when page title is Home
            if (document.title.indexOf("Default") > -1) {
                var hdText = document.getElementById("leftCol").innerHTML;
                //if showing Winner then show instrustions for controlling slide show  else swap back and start timer
                if (hdText.indexOf("Pause") > -1 ) {        //restore previous instructions
                    document.getElementById("leftCol").innerHTML = strDetails;
                    swapPicture();
                    }
                else {
                   strDetails = document.getElementById("leftCol").innerHTML;      //save Details to restore later?
                   var hdText = "<em>Slide Show</em><ul>";
                   hdText = hdText + "<li>to Pause:  move cursor over painting</li>";
                   hdText = hdText + "<li>to Continue:  move cursor off painting</li>";
                   hdText = hdText + "<li>to Display Details:  click anywhere on painting</li>";
                   hdText = hdText + "</ul>";
                   hdText = hdText + "<em>Full Screen View</em><ul>";
                   hdText = hdText + "<li>F11 to toggle</li></ul>";
                   document.getElementById("leftCol").innerHTML = hdText;
                   }
            }
            break;
        }
    case ("btn_Calendar"): {openPage = "Calendar.htm"; break;}
    case ("btn_Awards"): {openPage = "Awards.htm";break;}
    case ("Gallery"): {
        txt = document.title.toLowerCase();
        if (txt.indexOf("default") > -1) {
            window.location = "#gallry";break;}
        else    {
            openPage = "Default.html#gallry";break;}
        }   
    case ("btn_Board"): {openPage = "Board.htm"; break;}
    //case ("btn_Links"): {openPage = "ArtistsLinks.htm"; break;}
    //case ("btn_News"): {openPage = "News.htm"; break;}
    //case ("btn_History"): {openPage = "History.htm"; break;}
    //case ("Youths"): {alert("youths");openPage = "Youth.htm"; break;}
    //case ("btn_Newsletters"): {openPage = "Newsletter.htm"; break;}
    //case ("btn_Members"): {openPage = "Membership.htm"; break;}
    //case ("btn_About"): {openPage = "Youth.htm"; break;}
    default: {break}
    }       //closes switch
    WinRef = window.open(openPage,"_self") //,
    //'left=0,top=0,width=500,height=500,toolbar=1,resizable=1');

}

function scrollLogo() {     //not used Feb/09
    var ss = "";
    if (msg.length < 7 ) {
        clearTimeout(t);
        document.getElementById("R1C1").innerHTML = R1C1innerHTML;
        swapPicture();          //loads first image and sets timer
        }
    else {
        if (!msg.substring(0,1) == " ") {
            msg = msg.substring(1,msg.length);}         //msg.length 44 characters before wrap
        else {
            msg = msg.substring(1,msg.length);}
            ss = msg.substring(0,44).replace(/ /g,"&nbsp;");
            //ss = msg.replace(/ /g,"x");
//alert("ss = " + ss);
        document.getElementById("R1C1").innerHTML = ss;
        t = setTimeout("scrollLogo()",300);
        }
    }


function readImageList() {
    var i = 0;
    var ss = "";
    //grab innerHTML in cell R1C1 and hold till scrolling function ends
    //R1C1innerHTML = document.getElementById("R1C1").innerHTML;
    // scroll message and logo into heading
    // get message msg
    msg = logo;     //document.getElementById("R1C1").innerHTML;
    //add spaces to msg
    //for  (i = 0; i <= msg.length; i++)
    for  (i = 0; i <= 30; i++)
        {
            ss = " " + ss;
        }
    msg = ss + msg;
    //alert("msg = " + msg + "   i = " + i + "R1C1 = " + R1C1innerHTML);

    //Feb/09scrollLogo();
    
    req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest && !(window.ActiveXObject)) {
        try {
            req = new XMLHttpRequest();
        } catch(e) {
            req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e) {
            try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e) {
                req = false;
            }
        }
        }
    if(req) {
        sURL  = "http://" + self.location.hostname + "/Gallery/ImageList.txt";
        req.onreadystatechange = processReqChange;
        req.open("GET", sURL, true);            //async = true
        req.send("");
    }
}


function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {          //4=request Complete
        // only if "OK"
        if (req.status == 200) {        // Server response Ok
            // ...processing statements go here...
                        // load global variable with image file urls
                        vImages = req.responseText.split(/\r\n/);
                        nImages = vImages.length;
// IE and FF arrive at different nImages, possibly due to final crlf in ImageList.txt
// test for blank line and reduce by one
                if (vImages[nImages-1] == "" ) nImages = nImages-1;     
                        loadImages();
        } else {
            alert("There was a problem retrieving the XML data:\n" +
                req.statusText);
        }
    }
}



function loadImages() {
    if (document.images) {
        var atext = "", txt = "";
        for (i=0; i<nImages; i++) {
            dimages[i]=new Image(600,316);
            dimages[i].src="Gallery/" + vImages[i];
            //detect file name containing "winner" and assign a value to cnt
            txt = vImages[i].toLowerCase();
            if ((txt.indexOf("winner") > -1) && (cnt < 0)) {
                cnt = i;
                }
                //leaves out the winner picture as it is a repeat of one already in the ImageList
            else {
                //assemble string for Gallery HTML for each image
                atext = atext + "<a href = 'Gallery/" + vImages[i] + "' ";
                atext = atext + "class='highslide' onclick='return hs.expand(this)' >";
                atext = atext + "<img src='Gallery/Thumbnails/" + vImages[i] + "' ";
                atext = atext + "alt='Highslide JS' title='Original art.  Click to enlarge' ></a>";
            }
        }
        document.getElementById("the-images").innerHTML = atext;
        t = setTimeout("swapPicture()", 5500);            //loads first image and sets timer
    }
}


function swapPicture() {
  if (document.images)          //ensures that Images object is supported
  {
        if (cnt > (nImages - 1)) cnt = 0;

    if (dimages[cnt] && dimages[cnt].complete)
    {
      var target = false;
      if (document.images.curImage)
        {target = document.images.curImage;}
      else if (document.all && document.getElementById("curImage"))
        {target = document.getElementById("curImage");}

      // make sure target is valid.  It might not be valid
      //   if the page has not finished loading
      if (target)
      {
                //swap image
                target.src = dimages[cnt].src;
                if (firstImage) {
                    t = setTimeout("swapPicture()", 1000);
                    firstImage = !firstImage;
                    return;
                    }
                else {
                    target.style.height = '260px';
                    target.style.width = '';
                    target.style.border = '30px solid #AAAAAA';
                }


                //split array for author title and copyright information for superimposing on picture
                var atc = vImages[cnt].split("_");
                var hdText = "<span style='font-weight: bold;'>" + atc[0] + "<br></span>";
                //strip .jpg
                var yyyy = atc[2].split(".");
                hdText = hdText + "<span style='font-style: italic;'>&nbsp;&nbsp;&nbsp;&nbsp;" + atc[1]  + "<br>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
                hdText = hdText + "<font size='-2'>Copyright ©" + yyyy[0] + "<br>&nbsp;&nbsp;&nbsp;&nbsp;Image #" + cnt + " of " + (nImages - 1) + "</font>";

                document.getElementById("details").innerHTML = hdText;

                //assemble HTML for "leftCol" info about artist and picture
                hdText = "<p style='font-style: italic; font-weight: bold; font-size:16px;'>Painting</p><ul>";
                hdText = hdText + "<li>Artist - " + atc[0] + "</li>";
                hdText = hdText + "<li>Title - " + atc[1] + "</li>";
                hdText = hdText + "<li>Year - " + yyyy[0] + "</li>";
                hdText = hdText + "<li>Medium - " + atc[3] + "</li>";
                hdText = hdText + "<li>Size - " + atc[4] + "</li>";
                hdText = hdText + "<li>Price - $" + atc[5].split(".")[0] + "</li></ul>";
                document.getElementById("leftCol").innerHTML = hdText;

      }

                t = setTimeout("swapPicture()", 3500);
                //increment image counter
                cnt++;
    }
    else
    {
      t = setTimeout("swapPicture()", 500);
    }
  }
}


function showWindow() {
        win = document.getElementById("thewindow");
        winbackground = document.getElementById("thewindowbackground");
        wincontent = document.getElementById("thewindowcontent");
        img = document.getElementById("curImage")
        
        win.style.position = 'absolute';
        win.style.visibility = 'visible';
        win.style.width = String(Number(img.width) + 2*30) + "px";      
        win.style.height = String(Number(img.height) + 2*30) + "px";    
        win.style.left = findPosX(img);     
        win.style.top = findPosY(img);

        winbackground.style.width = win.style.width;        
        winbackground.style.height = win.style.height;  
        winbackground.style.top = "0";      //win.style.top;
        winbackground.style.left = "0";     //win.style.left;
        if(timeout > 0) {
            cur_opacity = 0;
            winbackground.style.opacity = cur_opacity / 100;
            winbackground.style.filter = "alpha(opacity=" + cur_opacity + ")";

            win.style.display = 'block';
            wincontent.style.display = 'none';
            timer = setTimeout("increase_opacity()",timeout);
        }
        else {
            winbackground.style.opacity = end_opacity / 100;
            winbackground.style.filter = "alpha(opacity=" + end_opacity + ")";
            win.style.display = 'block';
            wincontent.style.display = 'block';
        }
    }

function increase_opacity() {
    cur_opacity += increase_opacity_by;
    winbackground.style.opacity = cur_opacity / 100;
    winbackground.style.filter = "alpha(opacity=" + cur_opacity + ")";
    if(cur_opacity < end_opacity) {
    timer = setTimeout("increase_opacity()",timeout);
    }
    else {
    wincontent.style.display = 'block';
    }
    }


function hideWindow() {
    win.style.display = 'none';
    t = setTimeout("swapPicture()",3500);
    }


function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
