/*
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
*/2

function getElementsByClassName(oElm, strTagName, strClassName){
	//if (oElm.getElementsByClassName) return oElm.getElementsByClassName(strClassName);
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

// Image captions

/*function captionsLeft() {
   wrapImagesInDiv( 'captionleft', [], [ 'float' ] );
}

if(typeof window.addEventListener != 'undefined') {
   window.addEventListener('load', captionsLeft, false);
}
else if(typeof document.addEventListener != 'undefined') {
   document.addEventListener('load', captionsLeft, false);
}
else if(typeof window.attachEvent != 'undefined') {
   window.attachEvent('onload', captionsLeft);
}
function captionsRight() {
   wrapImagesInDiv( 'captionright', [], [ 'float' ] );
}

if(typeof window.addEventListener != 'undefined') {
   window.addEventListener('load', captionsRight, false);
}
else if(typeof document.addEventListener != 'undefined') {
   document.addEventListener('load', captionsRight, false);
}
else if(typeof window.attachEvent != 'undefined') {
   window.attachEvent('onload', captionsRight);
}*/

function wrapImagesInDiv( className, attributes, styles ) {
    if (document.getElementById("poidetail")) { return false };
   var images = document.getElementsByClassName(className);
   for ( var i = 0; i < images.length; ++i ) {
      var img = images[i];
      // Lift the image out of the page and insert a div under it.
      var parent = img.parentNode;
      var frame = document.createElement('div');
      var para = document.createElement('p');
      var txt = document.createTextNode(img.getAttribute('title'));
      parent.insertBefore(frame, img);
      parent.removeChild(img);
      frame.appendChild(img);
      frame.appendChild(para);
      para.appendChild(txt);
      // These are special cases.  We always copy these from the image to the
      // div.
      frame.style.width = img.getAttribute('width') + 'px';
      para.style.width = img.getAttribute('width') + 'px';
      frame.className = img.className;
      // Copy specified attributes and style properties from the image to the
      // div.
      for ( var j = 0; j < attributes.length; ++j ) {
         frame.setAttribute(attributes[j], img.getAttribute(attributes[j]));
      }
      for ( var j = 0; j < styles.length; ++j ) {
         frame.style[styles[j]] = img.style[styles[j]];
      }
   }
}

function makePopupLinks()
{
	var ps = getElementsByClassName(document,'a','popup');
	for (var i=0;i<ps.length;i++)
	{
		ps[i].onclick= function() {window.open(this.href);return false;};
	}

}
