var agt=navigator.userAgent.toLowerCase();
function displayBio(obj) {
    var docURL = location.href;
    if (obj.checked) {
        if (docURL.indexOf('showBibliography') == -1) {
            location.href = docURL+"&showBibliography=Y";
        }else {
            location.href = docURL.replace( /showBibliography=N/, "showBibliography=Y" );
        }
    }
    else {
        if (docURL.indexOf('showBibliography') == -1) {
            location.href = docURL+"&showBibliography=N";
        }else {
            location.href = docURL.replace( /showBibliography=Y/, "showBibliography=N" );
        }
    }
}


function printArticle() {
    var prn = new Image();

    prn.src="articles.html";

    if (window.print) {
        setTimeout('window.print();',200);
    }
    else if (agt.indexOf("mac") != -1) {
        alert("Press 'Comand+p' on your keyboard to print article.");
    }
    else {
        alert("Press 'Ctrl+p' on your keyboard to print article.")
    }
}

function hidePrint() {
    if (document.all) {
        document.all.hideTop.innerHTML = "";
        document.all.hideBottom.innerHTML = "";
    }
}

function showPrint() {
    if (document.all) {
        document.all.hideTop.innerHTML = str;
        document.all.hideBottom.innerHTML = str;
    }
}

function showLayer() {
    if (document.layers) {
        document.layers.layerTop.visibility = "show";
        document.layers.layerBottom.visibility = "show";
    }
}


function isblank(s)
{
  for (var i = 0; i < s.length; i++){
    var c = s.charAt(i) ;
    if ((c != ' ') && (c != '\n') && (c != '\t')) return false ;
  }
  return true ;
}

function form_isok(f){
  var msg ;
  var empty_fields="";
  var errors="";
  var f_name=new Array() ;
  f_name[1]="name";
  f_name[2]="company"
  f_name[3]="REmail";
  f_name[4]="csz";
  f_name[5]="phone";
  f_name[6]="dept";
  f_name[7]="message";
  for(var i=0; i<f.length-1; i++){
    var e = f.elements[i];
// deal with text input
    if((e.type=="text"||e.type=="textarea") && !e.optional && e.name!="REmail"){
      if((e.value==null)||(e.value=="")||isblank(e.value)){
        empty_fields +="<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + f_name[i] ;      }
    }
// check format of email
    if(e.name=="REmail"){
      while ((e.value==null)||(e.value=="")||isblank(e.value))
        e.value = prompt("Pleas enter Email address", e.value);
      while ( (e.value.indexOf("@") == "-1") ||
        (e.value.indexOf(".") == "-1") &&
        !((e.value==null)||(e.value=="")||isblank(e.value)) )
        e.value = prompt("Email form is Name@Address.xxx - correct & reenter", e.value);
    }
  }
  if(!empty_fields && !errors){
      var verwx=window.open("","verf");
      verwx.close();
      return confirm("Form is ready for submittal. OK?") ;
    }
// if errors or omissions found post message and abort submission
  msg  ="<FONT COLOR='red' FACE='arial'>"
  msg +="----------------------------------<BR>"
  msg +=" You may move/resize this window. <BR>"
  msg +=" Use list as guide - correct and  <BR>"
  msg +=" re-submit the form <BR>"
  msg +="----------------------------------</font><br><br>"

  if (empty_fields) {
    msg +=" The following required field(s) were empty:<br>"+empty_fields+"<br>";
  }
  if (errors) {
    msg += "<br>   The following error(s) were found" ;
    msg += errors ;
  }
  var verw=window.open("","verf");
  verw.close(); // make sure we do not add to existing window   (l. 75)
  alert(" form could not be submitted") ;
  verw=window.open("","verf","width=280,height=200,scrollbars,resizable=n");
  verw.document.write(msg);
  return false;
}

