function spawnWindow(url, windowname, attributes, mainwindowname) {
  remote = window.open(url,windowname, attributes);
  remote.location = url;
  remote.focus();
  if (remote.opener == null) {
    remote.opener = window;
  }
  if (remote.opener.name == null){
  remote.opener.name = mainwindowname;
  }
}

function spawnWordWindow(url) {
  help = spawnWindow(
    url,
    "atw_wordlist",
    "width=150,height=700,screenX=5,screenY=5,top=5,left=5,resizable=yes,toolbar=no,scrollbars=yes",
    "atwmain");
}
function spawnWordAsSubmittedWindow(url) {
  help = spawnWindow(
    url,
    "atw_otherwordlist",
    "width=250,height=400,screenX=25,screenY=25,top=25,left=25,resizable=yes,toolbar=no,scrollbars=yes",
    "atwmain");
}

function isBlank(s) {
  if (s==null) {return true;}
  for (var i = 0; i < s.length; i++) {
    var c = s.charAt(i);
    if ((c != ' ') && (c != '\n') && (c != '\r')) {return false;}
  }
  return true;
}
function isOKWord(string) {
    return (string.search(/^[a-zA-Z -]*$/) != -1);
}
function isNaughtyWord(string) {
    var badWords = /(fuck)|(shit)|(cunt)/i;
    var result = string.match(badWords);
    if (result != null ) {
     return true;
    } else {
     return false;
    }
}
function isReady(form) {

     if (isBlank(form.w1.value)||isBlank(form.w2.value)||isBlank(form.w3.value)) {
    alert("Come on! You can think of three words, can't you?");
    form.w1.focus();
    return false;
  }
     if (!isOKWord(form.w1.value)||!isOKWord(form.w2.value)||!isOKWord(form.w3.value)) {
    alert("I think you know that one of your words isn't a word.");
    form.w1.focus();
    return false;
  }
     if (isNaughtyWord(form.w1.value)||isNaughtyWord(form.w2.value)||isNaughtyWord(form.w3.value)) {
    alert("Please enter something else.\n\n And don't bother putting in any other bad words, I just end up deleting them. Have fun with this, but don't just sit there making more work for one poor guy.");
    form.w1.focus();
    return false;
  }

return true;
}
