//
// javascript_global.js
// --------------------
// Common JavaScript functions used throughout the site.
//
//
 

function offsitePopup(url) {
    var popUp = window.open(url, 'offsiteWindow', 'width=750,height=500,scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,location=yes');
    if (typeof popUp == 'object') {
        popUp.focus();
    }
}

function enlargementPopup(url, title) {
    var popUp = window.open('/lib/popups/enlargement.php?url=' + url + '&title=' + title, 'enlargementWindow', 'width=630,height=600,scrollbars=yes,resizable=yes,menubar=no,toolbar=no,location=no');
    if (typeof popUp == 'object') {
        popUp.focus();
    }
}

function popup(url, width, height) {
    var popUp = window.open(url, 'popupWindow', 'width=' + width + ',height=' + height + ',scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
    if (typeof popUp == 'object') {
        popUp.focus();
    }
    return false;
}




function verifyEmailAddress(address) {
}



function globalOnLoad() {

    // Assign link events
    for (var i = 0; i < document.links.length; i++) {
        if (document.links[i].className.match('PDF')) {
            document.links[i].onclick = function() { popup(this.href,'750','500'); return false; }
        }
        if (document.links[i].className.match('Offsite')) {
            document.links[i].onclick = function() { offsitePopup(this.href); return false; }
        }
        if (document.links[i].className.match('Enlargement')) {
            document.links[i].onclick = function() { enlargementPopup(this.href, this.title); return false; }
        }
    }

    // Run page onLoad function, if it exists
    if (typeof onLoad != 'undefined') {
        onLoad();
    }

}



// Every page should assign events
window.onload = globalOnLoad;

/* ben's hide n' show javascript */
function getRef(obj){
  if(typeof obj == "string") {obj= document.getElementById(obj);}
  else if (typeof obj == "object") {obj = obj;}

  return obj;
}

function setStyle(obj, style, value){
  getRef(obj).style[style]= value;
}

function getStyle(obj, style){
  return getRef(obj).style[style];
}

function move(elem,x,y) {
  getRef(elem).style.left = x + "px";
  getRef(elem).style.top = y + "px";
}

function hide(elem)
{
  setStyle(elem,'display','none');
  setStyle(elem,'visibility','hidden');

}

function show(elem)
{
  setStyle(elem,'display','inline');
  setStyle(elem,'visibility','visible');
}

function showhide(elem) {
  if (getStyle(elem, 'visibility') == "hidden")
    show(elem);
  else
    hide(elem);

}
