function setwm(fitsScreen) {
  var windowHeight, windowWidth;
  var nwidthDelta = fitsScreen? 10:26;
  //var iwidthDelta = fitsScreen? 0:20;
  var iwidthDelta = 0;  // offsetHeight/windowHeight test below takes care of it.
  windowWidth = winWidth();
  windowHeight = winHeight();
  var divObj;
  var hscroll = 0;
  var vscroll = 0;
  
  wmObj = findObjByName("wmimage");
  wmDiv = findObjByName("wm");
  divObj = findObjByName("main");
  //alert("main w,h:" + divObj.offsetWidth + "," + divObj.offsetHeight + ";" + "win w,h:" + windowWidth + "," + windowHeight);
  
  if (!wmObj) {
    wmObj = wmDiv.document["wmimage"];
  }
  if (wmObj) {
    if (is.ns4) {
      wmObj.width = 100;
      wmObj.height = 200;
    }
    else if (is.ns) {
      wmObj.width = windowWidth - nwidthDelta;
      wmObj.height = windowHeight - 20;
    }
    else {
      if (divObj.offsetWidth > (windowWidth-4)) {
        //alert("main width will exceed window, adjust wm for horiz scrollbar");
        hscroll = 16;
      }
      if (!(divObj.offsetHeight < (windowHeight-4))) {
        //alert("main height will exceed window, adjust wm for vert scrollbar");
        vscroll = 16;
      }
      wmObj.width = windowWidth - iwidthDelta - 4 - vscroll;
      wmObj.height = windowHeight - 7 - hscroll;
    }
  }
  else {
    if (!is.ns4) alert("Couldn't find watermark image object by name");
  }

  if (wmDiv) {
    if (wmDiv.style) {
      wmDiv = wmDiv.style
    }
    if (is.ns4) {
      /* don't bother, doesn't work
      alert("We're ns4, clipping watermark layer");
      wmDiv.clip.top = wmDiv.clip.left = 0;
      wmDiv.clip.width = 200;
      wmDiv.clip.height = 100;
      alert("We're ns4, wm layer should now be clipped");
      */
    }
    else if (is.ns) {
      wmDiv.width = windowWidth - nwidthDelta;
      wmDiv.height = windowHeight - 20;
    }
    else {
      //wmDiv.width = "" + windowWidth + "px";
      //wmDiv.height = "" + (windowHeight+20) + "px";
      //wmDiv.left = wmDiv.top = "0px";
      //wmDiv.borderWidth = "0px";
    }
  }
  else {
    if (!is.ns4) alert("Couldn't find watermark layer object");
  }
  //show("wm");
  wmDiv.visibility = 'visible';
}

function setmain() {
  var windowHeight, windowWidth;
  windowWidth = winWidth();
  windowHeight = winHeight();
  //alert("winw, h:" + windowWidth + "," + windowHeight);
  
  mainDiv = findObjByName("main");
  
  var divObj = mainDiv;
  var hscroll = 0;
  var vscroll = 0;
  if (mainDiv) {
    if (mainDiv.style) {
      mainDiv = mainDiv.style;
    }
    if (is.ns4) {
      /*
      don't bother, nothing works!
      */
    }
    else if (is.ns) {
      mainDiv.top = mainDiv.left = 0;
      mainDiv.width = windowWidth - 10;
      mainDiv.height = windowHeight - 20;
    }
    else {
      mainDiv.top = mainDiv.left = "0px";
      /*
      alert("for reference, div & win dims:" + 
	divObj.offsetWidth + "," + divObj.offsetHeight + "|" +
	divObj.clientWidth + "," + divObj.clientHeight + "|" +
	windowWidth + "," + windowHeight);
      */
      if (divObj.offsetWidth > (windowWidth-4)) {
	//alert("main will exceed window, expect horiz scrollbar");
	hscroll = 16;
      }
      if (!(divObj.offsetHeight < windowHeight-4)) {
	//alert("main will exceed window, expect vert scrollbar");
	vscroll = 16;
      }
      mainDiv.height = "" + (windowHeight-4-hscroll) + "px";
      mainDiv.width = "" + (windowWidth-4-vscroll) + "px";
    }
  }
  else {
    alert("Couldn't find main layer object");
  }
  mainDiv.visibility = 'visible';
}

// function for email form
function checkContactRequest() {
  var missing = new Array();
  var i=0;
  if (!document.emailform['reqname'].value ||
       document.emailform['reqname'].value == "") {
    missing[i++] = "Name";
  }
  if ((!document.emailform['dayphone'].value ||
       document.emailform['dayphone'].value == "") &&
      (!document.emailform['evephone'].value ||
       document.emailform['evephone'].value == "")) {
    missing[i++] = "Day or Evening Phone";
  }
  /*
  if (!document.emailform['email'].value ||
       document.emailform['email'].value == "") {
    missing[i++] = "Email";
  }
  */
  if (missing.length > 0) {
    var msg = "Sorry, you must fill in the following field(s):";
    for (i=0; i<missing.length; i++) {
      if (i) msg += ",";
      msg += missing[i];
    }
    alert(msg);
    return false;
  }
  else if (document.emailform['reqemail'].value ==
      document.emailform['emailc'].value) {
    /*
    successVal += "&amp;email=";
    successVal += document.emailform['required-email'].value;
    document.emailform.success.value = successVal;
    */
    return true;
  }
  else {
    alert("Sorry!  You must enter a confirmation email address that exactly matches.");
    return false;
  }
}

// function for pamphlet request form
function stepsReqCheck() {
  var missing = new Array();
  var i=0;
  if (!document.reqform['reqname'].value ||
       document.reqform['reqname'].value == "") {
    missing[i++] = "Name";
  }
  if (!document.reqform['reqa1'].value ||
       document.reqform['reqa1'].value == "") {
    missing[i++] = "Name";
  }
  if (!document.reqform['reqcity'].value ||
       document.reqform['reqcity'].value == "") {
    missing[i++] = "Name";
  }
  if (!document.reqform['reqstate'].value ||
       document.reqform['reqstate'].value == "") {
    missing[i++] = "Name";
  }
  if (!document.reqform['reqzip'].value ||
       document.reqform['reqzip'].value == "") {
    missing[i++] = "Name";
  }
  if (missing.length > 0) {
    var msg = "Sorry, you must fill in the following field(s):";
    for (i=0; i<missing.length; i++) {
      if (i) msg += ",";
      msg += missing[i];
    }
    alert(msg);
    return false;
  }
  else {
    return true;
  }
}

function emailsReqCheck() {
  var missing = new Array();
  var i=0;
  if (!document.emailsreq['reqname'].value ||
       document.emailsreq['reqname'].value == "") {
    missing[i++] = "Name";
  }
  if (!document.emailsreq['email'].value ||
       document.emailsreq['email'].value == "") {
    missing[i++] = "Email";
  }
  if (!document.emailsreq['pw'].value ||
       document.emailsreq['pw'].value == "") {
    missing[i++] = "Password";
  }
  if (missing.length > 0) {
    var msg = "Sorry, you must fill in the following field(s):";
    for (i=0; i<missing.length; i++) {
      if (i) msg += ",";
      msg += missing[i];
    }
    alert(msg);
    return false;
  }
  else if (document.emailsreq['email'].value !=
      document.emailsreq['emailc'].value) {
    alert("Sorry!  You must enter a confirmation email address that exactly matches.");
    return false;
  }
  else if (document.emailsreq['pw'].value !=
      document.emailsreq['pw-conf'].value) {
    alert("Sorry!  You must enter a confirmation password that exactly matches.");
    return false;
  }
  else {
    return true;
  }
}

// function for private messaging request form
function pmReqCheck() {
  var missing = new Array();
  var i=0;
  if (!document.reqform['reqname'].value ||
       document.reqform['reqname'].value == "") {
    missing[i++] = "Name";
  }
  if (!document.reqform['reqphone'].value ||
       document.reqform['reqphone'].value == "") {
    missing[i++] = "Phone";
  }
  if (!(document.reqform['reqcounselor'].selectedIndex > 0)) {
    missing[i++] = "Counselor";
  }
  if (!document.reqform['reqlogin'].value ||
       document.reqform['reqlogin'].value == "") {
    missing[i++] = "Login";
  }
  if (missing.length > 0) {
    var msg = "Sorry, you must fill in the following field(s):";
    for (i=0; i<missing.length; i++) {
      if (i) msg += ",";
      msg += missing[i];
    }
    alert(msg);
    return false;
  }
  else if (document.reqform.notify[1].checked  ||
       (document.reqform['email'].value &&
        (document.reqform['email'].value != "") &&
        (document.reqform['email'].value == document.reqform['emailc'].value))) {
    return true;
  }
  else {
    alert("Sorry!  To receive email notices, you must enter an email address and a confirmation that matches exactly.");
    return false;
  }
}

// function for checking message account preferences update request
function updateReqCheck() {
  if (document.updateform['close'].checked) {
    alert("You are closing your account.");
    return true;
  }
  if (!document.updateform['phone'].value ||
       document.updateform['phone'].value == "") {
    var msg = "Sorry, you must fill in the Phone field.";
    alert(msg);
    return false;
  }
  else if (document.updateform['userPasswd'].value &&
        (document.updateform['userPasswd'].value != document.updateform['passwordc'].value)) {
    alert("Sorry!  To change passwords, your new password and confirmation must match exactly.");
    return false;
  }
  else if (document.updateform.notify[1].checked  ||
       (document.updateform['email'].value &&
        (document.updateform['email'].value != "") &&
        (document.updateform['email'].value == document.updateform['emailc'].value))) {
    return true;
  }
  else {
    alert("To receive notices, you must enter an email address, and your email & confirmation must match exactly.");
    return false;
  }
}

