// JavaScript Document
var ericWindow_eric_window = 'undefined';
var DEFAULT_WIDTH = 1014;
var DEFAULT_HEIGHT = 705;

function WindowParams()
{
  this.width = DEFAULT_WIDTH;
  this.height = DEFAULT_HEIGHT;
  this.scrollbars = 'no';
  this.top = 0;
  this.left = 0;
  this.toolbar = 'no';
  this.location = 'no';
  this.menubar = 'no';
  this.resizable = 'no';
  this.copyhistory = 'no';
  this.dependent = 'yes';

}
function setWindowProperties()
{
  var winProp = new WindowParams();
  // update the win params here
  var availableHeight = screen.availHeight;
  var availableWidth = screen.availWidth;
  if((availableWidth != null && availableWidth < DEFAULT_WIDTH) || (availableHeight != null && availableHeight < DEFAULT_HEIGHT))
  {
    winProp.width = availableWidth;
    winProp.height = availableHeight - 30;
    winProp.scrollbars = 'yes';
    winProp.resizable = 'yes';
  }
  else
  {
    winProp.top  = ( screen.height - DEFAULT_HEIGHT ) / 2;
      winProp.left = ( screen.width - DEFAULT_WIDTH ) / 2;
  }
  return winProp;
}
function concateURL(url, param)
{
  if(param == null || param.trim().length == 0)
  {
    return url;
  }
  pos = url.indexOf('?');
  return (pos == -1 ? url + '?' + param : url + '&' + param);
}

function openEricWindow(url, parameter)
{
  if (ericWindow_eric_window == 'undefined') {  
    var params = setWindowProperties();    
    ericWindow_eric_window = window.open(concateURL(url, parameter), 'ericwindow', "toolbar=" + params.toolbar + ",location=" + params.location + ",directories=" + params.directories +  ",status=" + params.status + ",menubar=" + params.menubar + ",scrollbars=" + params.scrollbars + ", resizable=" + params.resizable + ",copyhistory=" + params.copyhistory + ",dependent=" + params.dependent +  "top=" + params.top + ",left=" + params.left + ", width="+ params.width + ", height=" + params.height);
    ericWindow_eric_window = 'undefined'; //reset the var.
  }
  else {
    ericWindow_eric_window.location.href = concateURL(controllerURIPath, parameter);
  }

  
}

