function ViewMap(url,w,h) {
  var xcoor = (screen.width-w)/2;
  var ycoor = (screen.height-h)/2;
  if (xcoor < 0) xcoor = 0;
  if (ycoor < 0) ycoor = 0;
  popattrib = "height="+h+",width="+w+",top="+ycoor+",left="+xcoor+",location=no,"
    +"scrollbars=yes,menubars=no,toolbars=no,resizable=no,status=yes";
  window.open(url, "MapWindow", popattrib);
}

function LaunchPreview(type,sex,id) {
  var w = 220;
  var h = 350;
  var xcoor = (screen.width-w)/2;
  var ycoor = (screen.height-h)/2;
  if (xcoor < 0) xcoor = 0;
  if (ycoor < 0) ycoor = 0;
  var page = "utilities/preview/preview.php?type=" + type + "&sex=" + sex + "&id=" + id;
  popattrib = "width="+w+",height="+h+",top="+ycoor+",left="+xcoor+",location=no,"
    +"scrollbars=no,menubars=no,toolbars=no,resizable=no,status=yes";
  window.open(page, "Preview", popattrib);
}

function checkSearch(form) {
  if (form.key.value == '' || form.key.value == null) {
    alert("Error: The search field is empty!");
    form.key.focus();
    return false;
  }

  if (!/^[-|+]?[\w\s]+$/.test(form.key.value)) {
    alert("Error: The input must be ALPHANUMERIC only!");
    form.key.focus();
    return false;
  }

  sString = form.key.value;
  while (sString.substring(0,1) == ' ') {
    sString = sString.substring(1, sString.length);
  }
  while (sString.substring(sString.length-1, sString.length) == ' ') {
    sString = sString.substring(0,sString.length-1);
  }

  if (sString == '' || sString == null) {
    alert("Error: The input must not be a space only!");
    form.key.focus();
    return false;
  } else {
    if (/^[\s]*[%]*[\s]*[%]+[\s]*$/.test(sString)) {
      alert("Error: The input must not be a wildcard only!");
      form.key.focus();
      return false;
    } else {
      form.key.value = sString;
    }
  }

  return true;
}