// we have these global so we can re-use them again in the calling scripts ;-)
var set=''; var i=0; var sx=0; var sy=0;
function openwindow(src,win_name,width,height,features) {
 //  alert(src+'\n'+win_name+'\n'+width+'\n'+height);
 var this_win = null;
 var screenOBJ = top.window.screen;
 sx  = (screenOBJ.width)  ? (screenOBJ.width  - width )/2 : 10;
 sy  = (screenOBJ.height) ? (screenOBJ.height - height)/2 : 10;
 // alert(screenOBJ.width+'('+width+')'+screenOBJ.height+'('+height+') = '+sx+' '+sy);
 var d_set = 'scrollbars=no,dependent=yes,resizable=yes,status=no,toolbar=no,location=no,menubar=no,top='+sy+',left='+sx+',height='+height+',width='+width;
 if(features)
 {
  var tmp_array = new Array();
  if(features.match(/,/))
   tmp_array = features.split(",");
  else
   tmp_array[0] = features;
  for(i=0;i<tmp_array.length;i++)
  {
   var k = tmp_array[i].split("=");
   var ptn = new RegExp("("+k[0]+")=\\w+");
   d_set = d_set.replace(ptn,'$1='+k[1]);
  }
 }
 var url = "";
 if(typeof(src) != 'undefined')
  url=src;
 set = d_set;
 // open the window 
 this_win = window.open(url,win_name,set);
 if(this_win==null)
 {
  // barf!
  self.location.href='/php/javascript_window_failed.php?title=window did not open!';
  return this_win;
 }
 this_win.moveTo(sx,sy);
 // accoding to my research == doing it IE and FIREFOX disagree in the final dimension!
 // DO NOT INCLUDE THIS< IT F's up EVERYTHING!!!!!!!!!!!
 this_win.resizeTo(width,height);
 return this_win;
}
