
function popup(url,winId,w,h,l,t) {
  // l, t : optionals
  // omitted -> default
  // -1 -> centered
  var winl = 0;
  var wint = 0;
  
  h+=30;	// due to address bar in moz
  
  var settings;
  
  if (l>=0) {			// specific x,y position
    winl=l;
	  wint=t;
  }
  else if (l==-1){	// centered
     if(screen.width){
        winl = (screen.width-w)/2;
        wint = (screen.height-h)/2;
     }
     if (winl < 0) winl = 0;
     if (wint < 0) wint = 0;
  }
  
  if (l>=-1)
  	  settings = 'top=' + wint + ',left=' + winl + ',';
  else 
     settings = '';
	  
  if (w>1000) {
     sb=1;
	  h=h+30;
	  w=1000;
  }
  else
     sb=0;
  
  settings += 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'scrollbars=' + sb + ',';
  settings += 'status=0,';
  settings += 'resizable=1';
    
  win = window.open(url,winId,settings);
  win.window.resizeTo(w+70,h+140);	// 8, 29
  if (l>=-1) 
     win.window.moveTo(winl, wint);
  win.window.focus();
}


function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}