// NOTE - the Google scholar header includes
// a form, so the first form in the page is actually forms[1]

// Enable text fields
function enableMW()
{
    document.forms[1].minMW.disabled=false;
    document.forms[1].maxMW.disabled=false;
    document.forms[1].minMW.style.background="#ffffcc";
    document.forms[1].maxMW.style.background="#ffffcc";
    document.forms[1].minMW.style.color="#000000";
    document.forms[1].maxMW.style.color="#000000";
}

//disable other enrollment status dropdown list and input field
function disableMW()
{
   document.forms[1].minMW.disabled=true;
   document.forms[1].maxMW.disabled=true;
   document.forms[1].minMW.style.background="#dcdcdc";
   document.forms[1].maxMW.style.background="#dcdcdc";
   document.forms[1].minMW.style.color="#dcdcdc";
   document.forms[1].maxMW.style.color="#dcdcdc";
}

function GoTo(data,target){

   document.digestion.action=target;
   document.digestion.target="_self";
   document.digestion.selectedData.value=data;
   document.digestion.submit();
}

//validate at least one radio button is selected
function ckRadioFm(fm, e) {
var flag = -1;
form=fm;
field=e;
var len=form.field.length; 
   if(!len){ 
        form.field.focus();
        if(form.field.checked){flag=1;}
        }
   else{
        for (var i=0;i<len; i++) {
          if (form.field[i].checked) {flag = 1;}
        }
    }
 if (flag> -1) {
     return true;
 }else {
     alert("Please select at least one radio button");
     return false;
 }
}


//validate the proteome motif scanning form
// - Data source is filled in
// - One or two digestions selected
function ckProteomeFm(){

  if((!document.motifPage.source.value)) {
      alert("Please select the data source!");
      return false;
  }
  var counter=0;
  var len=document.motifPage.digestion.length;
  var i=0;
  for (i=0; i<len; i++){
    if(motifPage.digestion[i].checked){
       counter++;
    }
  }
  if((counter>2)||(counter==0)){
   alert("Please select one or two digestions!");
   return false;
  } else{
   return true;
  }

}

function checkSearchProteinForm(){
   if(!document.searchProtein.pid.value && !document.searchProtein.aa.value){
      alert("Please enter a protein ID or Amino Acid Sequence for sesarch!");
      return false;
   }
}


function ckGoFm(){
   if(!document.go.go.value){
      alert("Please enter a GO term for search!");
      return false;
   }
}
