loadEvents = [];
function addLoadEvent(f)
{
  loadEvents.push(f);
}
window.onload = function(){
  for(i=0;i<loadEvents.length;i++){
    loadEvents[i]();
  }
}


function initPopupLinks()
{
  allLinks = document.getElementsByTagName('A')
  for(i=0;i<allLinks.length;i++){
    if(allLinks[i].className.indexOf('popup') > -1){
      allLinks[i].onclick = function(){
        size_pattern = /size_(\d+)x(\d+)/;
        if( matches = this.className.match(size_pattern) ){
          width = matches[1];
          height = matches[2];
        }
        else {
          width = 470;
          height = 500;
          }                
        left = Math.round((screen.width/2)-(width/2));
        top = Math.round((screen.height/2)-(height/2));
        features = 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top;
        window.open(this.href,'popoup',features);
        return false;
      }
    }
  }
}
loadEvents.push(initPopupLinks);

