window.onload = init;

var formSubmitted=false;
var focusId="";

function newWindow(source,title,width,height,toolbar,location,directories,status,menubar,scrollbars,resizable,copyhistory) {
  winOptions=eval("'width=" + width + ",height=" + height + ",toolbar=" + toolbar + ",location=" + location + ",directories=" + directories + ",status=" + status + ",menubar=" + menubar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",copyhistory=" + copyhistory + "'");
  
  popup = window.open(source,"_blank",winOptions);
  popup.openerFormId = "_blank";
  popup.focus();
}

function popup02(id,width,height) {
  winOptions=eval("'width="+ width +",height="+height+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no'");
  popup = window.open("",id,winOptions);
  popup.openerFormId = id;
  popup.focus();
}

function helpWindow() {
  var id="help";
  winOptions=eval("'width=450,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no'");
  popup = window.open("",id,winOptions);
  popup.openerFormId = id;
  popup.focus();
}

function historyBack() {
  history.back();
  // history.back(1);
  // history.go(-1);
  // window.history.go(-1);
}

function confirmSubmit(msg) {
  var agree=confirm(msg);
  if (agree)
    return true;
  else
    return false;
}

function checkSubmit(button) {
  var proceed=!formSubmitted;
  formSubmitted=true;
  //button.value = 'Please Wait';
  //button.disabled = true;
  return proceed;
}

function init() {
  //alert("init(): focusId = " + focusId);
  if (focusId.length>0) {
    document.getElementById(focusId).focus();
  }
}

function setFocusId(id) {
  //alert("setFocusId(): id = " + id);
  focusId=id;
}


function maillistSendTypeChange(type) {
  if (type.value=='basicText') {
    document.getElementById("form1:basicText").style.display="inline";
    document.getElementById("form1:htmlText").style.display="none";
  } else {
    document.getElementById("form1:basicText").style.display="inline";
    document.getElementById("form1:htmlText").style.display="inline";
  }
}
  
function maillistSendGroupCheck(group) {
  var groupList = document.getElementsByName("form1:Group");
  var i = 0;
  var node = groupList.item(i);
  if (group.value==" " && group.checked) {
    while (node!=null) {
      if (node.value!=" ") {
        node.checked = false;
        node.disabled = true;
      }
      node = groupList.item(++i);
    }
  } else {
    while (node!=null) {
      node.disabled = false;
      node = groupList.item(++i);
    }
  }
}

function checkAll(obj,name,check) {
  var form = document.getElementById("form1");
  for (i=0; i<form.length;i++){
    if (form[i].type == 'checkbox' && form[i].name.indexOf(name)>0) {
      form[i].checked = check;
    }
  }
}


