// JavaScript Document

<!-- OPEN CENTER WINDOW SCRIPT -->

function openCenterWindow(URL,winName,w,h,features) {

  // if screen.dimension is true (available), 
  // then calculate the position using that value, else use a fixed value
  xPos = (screen.width) ? (screen.width-w)/2 : 50;
  yPos = (screen.height) ? (screen.height-h)/2 : 50;
  
  // assemble all window settings from calculations and parameters
  settings = 'height='+h+',width='+w+',top='+yPos+',left='+xPos+','+features
  
  // open the window and bring it to front
  thisWin=window.open(URL,winName,settings);
  thisWin.focus();
}

function hov(loc,cls){
   if(loc.className)
      loc.className=cls;}
	  
//Workaround to make document.getElementById() follow W3C standard and only match on id (IE6,7 & Opera)//
//IE was returning the meta tag name "description" as well as the id "description" causing the script to fail//
var isOpera, isIE = false;
if(typeof(window.opera) != 'undefined'){isOpera = true;}
if(!isOpera && navigator.userAgent.indexOf('Internet Explorer')){isIE = true;}

//fix both IE and Opera (adjust when they implement this method properly)
if(isOpera || isIE){
  document.nativeGetElementById = document.getElementById;
  //redefine it!
  document.getElementById = function(id){
    var elem = document.nativeGetElementById(id);
    if(elem){
      //verify it is a valid match!
      if(elem.attributes['id'] && elem.attributes['id'].value == id){
        //valid match!
        return elem;
      } else {
        //not a valid match!
        //the non-standard, document.all array has keys for all name'd, and id'd elements
        //start at one, because we know the first match, is wrong!
        for(var i=1;i<document.all[id].length;i++){
          if(document.all[id][i].attributes['id'] && document.all[id][i].attributes['id'].value == id){
            return document.all[id][i];
          }
        }
      }
    }
    return null;
  };
}
	  
<!-- PHOTO GALLERY SCRIPT -->
function showPic(whichpic) {
  if (!document.getElementById("placeholder")) return true;
  var source = whichpic.getAttribute("href");
  var placeholder = document.getElementById("placeholder");
  placeholder.setAttribute("src",source);
  if (!document.getElementById("description")) return false;
  if (whichpic.getAttribute("title")) {
    var text = whichpic.getAttribute("title");
  } else {
    var text = "";
  }
  var description = document.getElementById("description");
  if (description.firstChild.nodeType == 3) {
    description.firstChild.nodeValue = text;
  }
  return false;
}

function prepareGallery() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("showcase")) return false;
  var gallery = document.getElementById("showcase");
  var links = gallery.getElementsByTagName("a");
  for ( var i=0; i < links.length; i++) {
    links[i].onclick = function() {
      return showPic(this);
	}
    links[i].onkeypress = links[i].onclick;
  }
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(prepareGallery);


