// $Revision: 1.72.2.1.2.2 $:

var WINDOW_REPOSITORY = new Array();

var WINDOW_FEATURES_REPOSITORY = new Array();

var IE_FLAG = document.getElementById && document.all && navigator.appVersion.toUpperCase().indexOf("MSIE") != -1;  
var IE_4_FLAG = IE_FLAG && navigator.appVersion.toUpperCase().indexOf("MSIE 4") != -1;  
var IE_5_FLAG = IE_FLAG && navigator.appVersion.toUpperCase().indexOf("MSIE 5") != -1;  
var IE_6_FLAG = IE_FLAG && navigator.appVersion.toUpperCase().indexOf("MSIE 6") != -1;  

putWindowFeatures("bid_report", "resizable=1,width=800,status=1,scrollbars=1,menubar=1,titlebar=1,location=1,height=525");

putWindowFeatures("maximize", "resizable=1,width=675,status=1,scrollbars=1,menubar=1,titlebar=1,location=1,height=300");

putWindowFeatures("standalone_tree", "resizable=1,width=194,status=1,height=425");

putWindowFeatures("select_language", "resizable=1,width=360,scrollbars=1,height=400");

if(IE_FLAG) {
  putWindowFeatures("options", "resizable=1,width=475,status=1,titlebar=1,height=435,scrollbars=1");
}
else {
  putWindowFeatures("options", "resizable=1,width=500,status=1,titlebar=1,height=510,scrollbars=1");
}

putWindowFeatures("recents", "resizable=1,width=360,status=1,scrollbars=1,titlebar=1,height=310");

putWindowFeatures("favorites", "resizable=1,width=360,status=1,scrollbars=1,titlebar=1,height=310");

putWindowFeatures("domain_search", "resizable=1,width=975,status=1,scrollbars=1,titlebar=1,height=635");

putWindowFeatures("tools", "resizable=1,width=800,status=1,scrollbars=1,height=600");

putWindowFeatures("utilities", "resizable=1,width=800,status=1,scrollbars=1,height=600");

putWindowFeatures("library", "resizable=1,width=800,status=1,titlebar=1,height=600");

putWindowFeatures("watch_list", "resizable=1,width=800,status=1,titlebar=1,height=600");

putWindowFeatures("report_caster", "resizable=1,width=800,status=1,scrollbars=1,titlebar=1,height=600");

putWindowFeatures("deferred_status", "resizable=1,width=800,status=1,scrollbars=1,titlebar=1,height=600");

putWindowFeatures("about", "width=500,height=185");

putWindowFeatures("help", "resizable=1,width=800,status=1,scrollbars=1,titlebar=1,height=600");

putWindowFeatures("properties", "resizable=1,width=520,status=1,scrollbars=1,height=715");

putWindowFeatures("domain_properties", "resizable=1,width=450,status=1,scrollbars=1,height=220");

putWindowFeatures("folder_properties", "resizable=1,width=450,status=1,scrollbars=1,height=170");

putWindowFeatures("editor", "resizable=1,width=600,status=1,height=550");

putWindowFeatures("new_folder", "resizable=1,width=480,status=1,height=220,scrollbars=0");

putWindowFeatures("new_domain", "resizable=1,width=480,status=1,height=220,scrollbars=0");

putWindowFeatures("mobile_email", "resizable=1,width=480,status=1,height=220,scrollbars=0");

putWindowFeatures("url", "resizable=1,width=450,status=1,height=280");

putWindowFeatures("import", "resizable=1,width=350,status=1,height=350");

putWindowFeatures("save_as", "resizable=1,width=500,status=1,height=550");

putWindowFeatures("group_views", "resizable=1,width=400,status=1,scrollbars=1,height=400");

putWindowFeatures("filter", "resizable=1,width=450,scrollbars=1,height=400");

putWindowFeatures("color_chooser", "width=480,status=1,height=500");

putWindowFeatures("domain_search_folder_viewer", "resizable=1,width=400,status=1,scrollbars=1,titlebar=1,height=400");

putWindowFeatures("scheduler", "width=500,height=560");

putWindowFeatures("scheduler2", "width=560,height=620,resizable=1");

putWindowFeatures("html_ra", "width=710,height=540,resizable=1");

putWindowFeatures("html_ga", "width=710,height=540,resizable=1");

putWindowFeatures("master_file_dialogue", "width=350,height=250,resizable=1");

putWindowFeatures("betty", "width=800,height=600,resizable=1");

putWindowFeatures("hollywood", "width=800,height=600,resizable=1");

putWindowFeatures("tool_dialog", "width=380,height=550,resizable=1");

putWindowFeatures("rotool_dialog", "width=500,height=400,resizable=1");

putWindowFeatures("library_versions", "resizable=1,width=700,status=1,titlebar=1,height=600");

putWindowFeatures("tools_domains_selection", "resizable=1,width=425,height=250,status=1,scrollbars=1,titlebar=1");

putWindowFeatures("domain_search_criteria_name_prompt", "width=350,height=150,status=1,scrollbars=1");

putWindowFeatures("ms_ppt_dialogue", "width=325,height=300,status=1,scrollbars=1");

putWindowFeatures("ms_ppt_run", "resizable=1,width=800,status=1,scrollbars=1,menubar=1,height=525");

if(IE_4_FLAG || IE_5_FLAG || IE_6_FLAG) {
  putWindowFeatures("metadata", "width=800,height=600,resizable=1,toolbar=1");
}
else {
  putWindowFeatures("metadata", "width=800,height=600,resizable=1,location=1");
}

if(IE_FLAG) {
  putWindowFeatures("datasource_import", "width=450,height=285,status=1,resizable=0,scrollbars=1");
}
else {
  putWindowFeatures("datasource_import", "width=450,height=310,status=1,resizable=0,scrollbars=1");
}

function putWindowFeatures(windowId, windowFeatures) {
  WINDOW_FEATURES_REPOSITORY[windowId] = windowFeatures;
}

function getWindowFeatures(windowId) {
  return WINDOW_FEATURES_REPOSITORY[windowId];
}

function openWindowById(url, windowId) {
  var windowFeatures = getWindowFeatures(windowId);
  if(windowFeatures == null) {
    alert('Error: window features for [' + windowId + '] do not exist');
    return;
  }
  var windowFeatures = getCenteredWindowFeatures(windowFeatures);
  closeWindowById(windowId);
  WINDOW_REPOSITORY[windowId] = window.open(url, windowId, windowFeatures);
  return WINDOW_REPOSITORY[windowId];
}

function closeWindowById(windowId) {
try {
  if(WINDOW_REPOSITORY[windowId] != null){
    WINDOW_REPOSITORY[windowId].close();
    WINDOW_REPOSITORY[windowId] = null;
  }
}
catch(e) {
//alert(e.message);
}
}


function closeAllOpenedWindows() {
  for(var windowId in WINDOW_REPOSITORY) {
    closeWindowById(windowId)
  }
}

function getCenteredWindowFeatures(windowFeatures) {
  var h = 0;
  var w = 0;
  var hIndx = windowFeatures.indexOf("height");
  var hPrefix = windowFeatures.slice(hIndx + 7);
  if(hPrefix.indexOf(',') == -1) {
    h = parseInt(hPrefix);
  }
  else {
    h = parseInt(hPrefix.slice(0, hPrefix.indexOf(',')));
  }
  var wIndx = windowFeatures.indexOf("width");
  var wPrefix = windowFeatures.slice(wIndx + 6);
  if(wPrefix.indexOf(',') == -1) {
    w = parseInt(wPrefix);
  }
  else {
    w = parseInt(wPrefix.slice(0, wPrefix.indexOf(',')));
  }
  var left = (screen.width - w) / 2;
  var top = ((screen.height - h) / 2) - (screen.height - screen.availHeight);
  return 'top=' + top + ',left=' + left + ',' + windowFeatures;
}

