function __DoPostBack(form_name, event_name, event_value, confirmation) {

  if ((confirmation != null) && (confirmation != ""))
    doit = (confirm(confirmation))
  else
    doit = true;
  if (doit) {
    form = document.getElementById(form_name);
    if ((event_name != null) && (event_name != "")) {
      form.__event_name.value = event_name;
    }
    if ((event_value != null) && (event_value != "")) {
      form.__event_value.value = event_value;
    }
//    canvas = document.getElementsByTagName((document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "BODY")[0];
//    form.__scroll_top = canvas.scrollTop;
    form.submit();
  }

}

function __OnSubmit() {

  return false;

};

function __NotImplemented() {

  alert('This function is not implemented yet');

};

function Browser_DoDelete(form_name, id, name) {

  __DoPostBack(form_name, "delete", id, 'Are you sure you want to delete "' + name + '"?');

};

function __Browser_DoCheck(container, prefix, checked) 
{

  for(i = 0; i < container.all.length; i++) {
    if ((container.all[i].id != null) && (container.all[i].id.indexOf(prefix) == 0))
      container.all[i].checked = checked;
  }

}

function Browser_DoCheck(form_name, prefix, checked) 
{

  var container;
  container = document.getElementById(form_name);
  if (container == null)
    container = document;
  __Browser_DoCheck(container, prefix, checked);

}

function Browser_CalcSelection(form_name, prefix) 
{
  var container;
  container = document.getElementById(form_name);
  if (container == null)
    container = document;
  result = 0;

  for(i = 0; i < container.all.length; i++) {
    if ((container.all[i].id != null) && (container.all[i].id.indexOf(prefix) == 0) && container.all[i].checked)
      result++;
  }

  return result;

}

function Browser_DoSelectAll(form_name, prefix) {

  Browser_DoCheck('', prefix, true);

};

function Browser_DoUnselectAll(form_name, prefix) {

  Browser_DoCheck('', prefix, false);

};

function Browser_DoDeleteSelected(form_name, prefix) {

  count = Browser_CalcSelection('', prefix);

  if (count == 0)
    alert('Please select at least one record')
  else
    __DoPostBack(form_name, 'delete_selected', null, 'Are you sure you want to delete ' + count + ' selected record(s)?');

};

function Browser_Hide(form_name, postfix) {

  var container;

  container = document.getElementById(form_name + "_" + postfix);
  if (container != null) {
    if ((container.style.display == "") || (container.style.display == "inline"))
      container.style.display = "none";
    else
      container.style.display = "inline";
  }

  container = document.getElementById(form_name + "_" + postfix + "_line");
  if (container != null) {
    if ((container.style.display == "") || (container.style.display == "inline"))
      container.style.display = "none";
    else
      container.style.display = "inline";
  } 

}

function Browser_DoFileSelected(form_name, key_value) {

  __DoPostBack(form_name, 'file_selected', key_value);

};


function __Browser_RowOver(ctrl, call_after) {

  ctrl.style.cursor = 'hand';
  ctrl.oldClassName = ctrl.className;   
  ctrl.className    = 'default_row_selected'; 

  if (call_after != null)
    eval(call_after);

}

function __Browser_RowOut(ctrl, call_after) {

  ctrl.style.cursor = 'default';    
  ctrl.className    = ctrl.oldClassName; 

  if (call_after != null)
    eval(call_after);

}

function __Browser_RowClick(ctrl) {


}

function __NewWnd(url, w, h, mb) {

  if (w==null) w=600;
  if (h==null) h=400;
  if (mb==null) mb=0;
  var w = window.open(url, '_blank', 'menubar='+mb+',resizable=0,scrollbars=0,top=50,left=50,width='+w+',height='+h, true);
  w.focus();

}

function __OpenUrl(url, full_window) {
  
  wnds_params = 'menubar=1,resizable=1,scrollbars=1';
  if (full_window)
    wnds_params = '';
  w = window.open(url, '_blank', wnds_params, true);
  w.focus();

}

function __OpenUrlFrom(form_name, control_name, full_window) {

  form = document.getElementById(form_name);
  if ((control_name != null) && (control_name != "")) {
    ctrl = document.getElementById(control_name);
    if (ctrl != null) {
      url = ctrl.value;
      __OpenUrl(url, full_window);
    }
  }

}

function __SelectPage(id, newPage) {

  control = document.getElementById("page_control_" + id + "_selected_page");
  currentPage = control.value;

  control = document.getElementById("page_" + id + "_Row_" + currentPage);
  control.className = "default_tab";
  control = document.getElementById("page_" + id + "_" + currentPage);
  control.className = "invisible";
  control = document.getElementById("page_" + id + "_Title_" + currentPage);
  control.className = "invisible";
  control = document.getElementById("page_" + id + "_Selector_" + currentPage);
  control.className = "visible";

  currentPage = newPage;
  
  control = document.getElementById("page_" + id + "_Row_" + currentPage);
  control.className = "default_selected_tab";
  control = document.getElementById("page_" + id + "_" + currentPage);
  control.className = "visible";
  control = document.getElementById("page_" + id + "_Title_" + currentPage);
  control.className = "visible";
  control = document.getElementById("page_" + id + "_Selector_" + currentPage);
  control.className = "invisible";

  control = document.getElementById("page_control_" + id + "_selected_page");
  control.value = currentPage;

}