// Display Hidden Icon

var spans = document.getElementsByTagName("span");
  spans[0].innerHTML = '<img id="invisible" src="' + urlPrefix + 'gif/invisible.gif" alt="" width="18" height="24" />';
  spans[1].innerHTML = '<a id="lnk" href="' + urlPrefix + 'text/poem058.html"><img id="girl" src="' + urlPrefix + 'gif/girl' + fileSuffix + '.gif" alt="" title="To My Unseen Love" width="18" height="24" /></a>';

var invisibleImage = document.getElementById("invisible");
var iconLink = document.getElementById("lnk");
var iconImage = document.getElementById("girl");

spans[0].style.marginRight = "0.5em";
spans[1].style.marginLeft = "0.5em";

invisibleImage.style.visibility = "hidden";
iconImage.style.visibility = "hidden";

function show() {
  iconImage.style.visibility = "visible";
}

function hide() {
  iconImage.style.visibility = "hidden";
}

iconLink.onmouseover = show;
iconLink.onmouseout = hide;
iconLink.onfocus = show;
iconLink.onblur = hide;


// Scroll to Bottom and Top of Page

var areaOne = document.getElementById("area1");

areaOne.onclick = function() {
  window.scrollTo(0, 100000);
  return false;
};

if (imageName3 == "bar" || imageName3 == "bar2" || imageName3 == "095_Richard_and_Elise") {
  var areaTwo = document.getElementById("area2");

  areaTwo.onclick = function() {
    window.scrollTo(0, 0);
    return false;
  };
}


// Change Main Image

if (imageName2 != "" && imageName2 != "095_Somewhere_in_Time" && imageName2 != "061_BOUGUEREAU_Girl") {
  var linkOne = document.getElementById("primary");
  var imageOne = document.getElementById("main");
  var c = 0;

  var changeImage = function() {
    linkOne.href = (c % 2) ? urlPrefix + "art/" + imageName1 + ".JPG" : urlPrefix + "art/" + imageName2 + ".JPG";
    imageOne.src = (c % 2) ? urlPrefix + "images/" + imageName1 + ".jpg" : urlPrefix + "images/" + imageName2 + ".jpg";
    c++;
  };

  linkOne.onmouseout = changeImage;
  linkOne.onblur = changeImage;
}


// Change Random Link

if (!imageName3) {
  var poems = new Array();
    poems[0]  = "Epigram for the Battlefield";
    poems[1]  = "Day to Night";
    poems[2]  = "On the Death of My Grandfather";
    poems[3]  = "Variance";
    poems[4]  = "Morning Comes";
    poems[5]  = "Passing Outdoors on a Summer Night";
    poems[6]  = "Existence";
    poems[7]  = "A Variation on a Theme by Moses";
    poems[8]  = "Lone Stanza to Nature";
    poems[9]  = "Somnolence";
    poems[10] = "A Wish";
    poems[11] = "A Minor Prelude";
    poems[12] = "On Awakening One Morning";
    poems[13] = "Forever Contained";
    poems[14] = "Adam's First Words";
    poems[15] = "Road to Nowhere";
    poems[16] = "Our Past";
    poems[17] = "Reply to a Curse";
    poems[18] = "Love and Shyness";
    poems[19] = "Love Comes";
    poems[20] = "And Then";
    poems[21] = "There More Real";
    poems[22] = "Where Once You Were";
    poems[23] = "Summer Night";
    poems[24] = "Transience";
    poems[25] = "Sometimes When You Look in His Eyes";
    poems[26] = "Since You Are Gone";
    poems[27] = "Said of Love";
    poems[28] = "Epitaph";
    poems[29] = "I Suppose They Weren't Really Lies";
    poems[30] = "Self Portrait";
    poems[31] = "A Longing";
    poems[32] = "My Fondest Desire";
    poems[33] = "Nights with You";
    poems[34] = "A Pleasure";
    poems[35] = "Divorce Poem";
    poems[36] = "Spring Dance";
    poems[37] = "How Do I Know?";
    poems[38] = "My Beloved One";
    poems[39] = "Good-bye Poem";
    poems[40] = "My Remembrance of Thee";
    poems[41] = "Together";
    poems[42] = "In All the World";
    poems[43] = "This Day";
    poems[44] = "Perchance We've Met";
    poems[45] = "A Broken Date";
    poems[46] = "In Future Tense";
    poems[47] = "My Heart's Condition";
    poems[48] = "After the Fall";
    poems[49] = "These Three Things";
    poems[50] = "To Begin Again";
    poems[51] = "Still";
    poems[52] = "No Words Can Come";
    poems[53] = "What Goes Around Comes Around";
    poems[54] = "Love's Paradox";
    poems[55] = "Metamorphosis";
    poems[56] = "Wasted";
    poems[57] = "To My Unseen Love";
    poems[58] = "Bach's Music";
    poems[59] = "Our Forgotten Love";
    poems[60] = "The Decadence of Modern Art";
    poems[61] = "My Secret Love";
    poems[62] = "To Sara";
    poems[63] = "To the Pseudo-Christians";
    poems[64] = "Directionless";
    poems[65] = "I Would Board the Titanic";
    poems[66] = "From My Dream of You";
    poems[67] = "My Wish Tonight";
    poems[68] = "My Desire for You";
    poems[69] = "Your Dear, Sweet Letters";
    poems[70] = "My Consolation";
    poems[71] = "Obscurity";
    poems[72] = "Frustration Superhighway";
    poems[73] = "Marooned";
    poems[74] = "The Night Before Christmas";
    poems[75] = "Never Far";
    poems[76] = "Only You";
    poems[77] = "No One More Real";
    poems[78] = "The Wind Speaks Your Name";
    poems[79] = "In My Beloved";
    poems[80] = "Let Me Stay";
    poems[81] = "Long Ago I Saw the Sea";
    poems[82] = "Ever Farther";
    poems[83] = "You Are the Best";
    poems[84] = "Near to You";
    poems[85] = "You Have Touched Me";
    poems[86] = "Heaven";
    poems[87] = "The Beauty of Your Hair";
    poems[88] = "Three Little Words";
    poems[89] = "With You";
    poems[90] = "White Clouds";
    poems[91] = "Lost to Me";
    poems[92] = "A Really Good Friend";
    poems[93] = "Thinking of You";
    poems[94] = "If I Could Choose";
    poems[95] = "Too Little Too Late";

  var p = poems.length;
  var containerTD = document.getElementById("container");
  var r = Math.floor(Math.random() * p);
  var titleText = poems[r++];

  var format = function(x) {
    if (x < 10)
      return "00" + x;

    if (x < 100)
      return "0" + x;

    return "" + x;
  };

  containerTD.innerHTML = '<a id="random" href="poem' + format(r) + '.html" title="' + titleText + '">Select at Random</a>';

  var randomLink = document.getElementById("random");
  randomLink.style.cursor = "help";

  var changeRandomLink = function() {
    r = Math.floor(Math.random() * p);
    randomLink.title = poems[r++];
    randomLink.href = "poem" + format(r) + ".html";
  };

  randomLink.onmouseout = changeRandomLink;
  randomLink.onblur = changeRandomLink;
}


// Change Alternating Images

if (imageName1 == "075_BOUGUEREAU_The_Lost_Pleiad") {
  var x;
  var y = 0;

  if (document.getElementsByClassName) {
    var alternatingImages = document.getElementsByClassName("alternating");
    var surroundingLinks = document.getElementsByClassName("surrounding");
  }
  else {
    var imgElements = document.getElementsByTagName("img");
    var aElements = document.getElementsByTagName("a");

    var alternatingImages = new Array();
      for (x = 0; x < imgElements.length; x++) {
        if (imgElements[x].className == "alternating") {
          alternatingImages[y] = imgElements[x];
          y++;
        }
      }

    y = 0;

    var surroundingLinks = new Array();
      for (x = 0; x < aElements.length; x++) {
        if (aElements[x].className == "surrounding") {
          surroundingLinks[y] = aElements[x];
          y++;
        }
      }
  }

  x = 0;

  var changeImages = function() {
    for (var y = 0; y < alternatingImages.length; y++) {
      if (y % 2)
        alternatingImages[y].src = (x % 2) ? urlPrefix + "images/" + imageName3 + ".jpg" : urlPrefix + "images/" + imageName1 + ".jpg";
      else
        alternatingImages[y].src = (x % 2) ? urlPrefix + "images/" + imageName1 + ".jpg" : urlPrefix + "images/" + imageName3 + ".jpg";
    }
    x++;
  };

  for (y = 0; y < surroundingLinks.length; y++) {
    surroundingLinks[y].onmouseout = changeImages;
  }
}


// Change Triple Images

if (imageName1 == "095_DELLA-MORETTA_Lilacs") {
  var imageNames = new Array();
    imageNames[0] = imageName2;
    imageNames[1] = imageName3;
    imageNames[2] = imageName1;

  var linkOne = document.getElementById("primary");
  var imageOne = document.getElementById("main");
  var c = 0;

  var changeImage = function() {
    linkOne.href = urlPrefix + "art/" + imageNames[c % 3] + ".JPG";
    imageOne.src = urlPrefix + "images/" + imageNames[c % 3] + ".jpg";
    c++;
  };

  linkOne.onmouseout = changeImage;
  linkOne.onblur = changeImage;
}


// Change Modern Art Image

if (imageName1 == "061_DE_KOONING_Woman") {
  var linkOne = document.getElementById("primary");
  var imageOne = document.getElementById("main");
  var c = 0;

  var changeImage = function() {
    linkOne.href = (c % 2) ? urlPrefix + "art/" + imageName1 + ".JPG" : urlPrefix + "art/028_BOUGUEREAU_Girl.JPG";
    imageOne.src = (c % 2) ? urlPrefix + "images/" + imageName1 + ".jpg" : urlPrefix + "images/" + imageName2 + ".jpg";
    imageOne.title = (c % 2) ? "Click to Enlarge" : "Click to Compare";
    c++;
  };

  linkOne.onmouseout = changeImage;
  linkOne.onblur = changeImage;
}


// Hide Onscreen Graphics

if (imageName1 != "MICHELANGELO_The_Creation_of_Adam" && imageName1 != "GOYA_Clothed_Maja") {
  var dynamicStyles = document.getElementById("dynamic");
  var poemHeading = document.getElementById("heading");
  var n = 0;

  poemHeading.onclick = function() {
    dynamicStyles.media = (n % 2) ? "print" : "all";
    poemHeading.title = (n % 2) ? "by Michael Langston" : "Restore Graphics";
    poemHeading.blur();
    window.scrollTo(0, 0);
    n++;
    return false;
  };
}

