function getWidth(string)
{
	defaultWidth = 400;
	exp = /width=([\d]*)/;
	match = string.match(exp);
	if(match == null)  return(defaultWidth);
	else return(match[1]);
}
function getHeight(string)
{
	defaultHeight = 600;
	exp = /height=([\d]*)/;
	match = string.match(exp);
	if(match == null)  return(defaultHeight);
	else return(match[1]);
}

function getElementsByClass(name) {
  var found = 0;
  var elems = new Array();
  var alltags = document.getElementsByTagName("*");
  if (alltags) {
    for (i=0; i < alltags.length; i++) {
        if (alltags[i].className==name) {
          elems[found++]=alltags[i];
        }
    }
  }
  return(elems);
}
function addEvent(obj, evType, fn) {
  if (obj.addEventListener) {
    obj.addEventListener(evType, fn, true);
    return true;
  } else if (obj.attachEvent) {
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    return false;
  }
}
function classPopupHandler() {
  var elems=getElementsByClass('popup');
  for(i=0;i<elems.length;i++) 
  {
    if (elems[i].href && elems[i].href!='')
	 {
      addEvent(elems[i],'click',doPopup);
    }
  }
}

function doPopup(ev) {
  // vagy megkapjuk az esemény objektumot, vagy meg kell szereznünk
  ev || (ev = window.event);

  // mely objektum váltotta ki az eseményt?
  var source;
  if (typeof ev.target != 'undefined') {
    source = ev.target;
  } else if (typeof ev.srcElement != 'undefined') {
    source = ev.srcElement;
  } else { return(true); }

  width = getWidth(source.rel);
  height = getHeight(source.rel);
  winNew = window.open(source.href,'popup2','toolbars=no,width=' + width + ',height=' + height +',resizable=yes,scrollbars=yes');
 // window.alert("window.open(source.href,'popup2','toolbars=no,width=" + width + ",height=" + height +",resizable=yes');");
  winNew.focus();
  
  // eseménnyel mi foglalkoztunk, nem kell továbbvinni
  if (ev.preventDefault) {
    ev.preventDefault(); ev.stopPropagation();
   } else {
    ev.cancelBubble = true; ev.returnValue = false;
  }
  return false;
}
addEvent(window, 'load', classPopupHandler);
//classPopupHandler();
