function chgDate(thisSelect,theDateSelect,theYearSelect){
 var blank = new Option("");
 var d31 = new Option("31");
 var d30 = new Option("30");
 var d29 = new Option("29");
 
 yr =parseInt(theYearSelect.options[theYearSelect.selectedIndex].value);


 if (yr/400*400==yr || (yr/4*4==yr && yr/100*100 != yr)){leap =1;} 
 else{leap=0;}
 
 
 ind = thisSelect.selectedIndex+1;
 if(ind == 4 || ind== 6 || ind == 9 || ind==11){
  theDateSelect.options[30]=blank;
  theDateSelect.options[29]=d30;
  theDateSelect.options[28]=d29;
  
 }
 else if (ind==2){
  theDateSelect.options[30]=blank;
  theDateSelect.options[29]=blank;
      theDateSelect.options[28]=blank;
 }
 else{
  theDateSelect.options[30]=d31;
  theDateSelect.options[29]=d30;
  theDateSelect.options[28]=d29;
  }
}
function checkForm(thisForm,thisButton){
  info = parent.info;
  info.document.clear();
  info.document.write("<html><body text='#fffff2' bgcolor='#aa2222'>");
  rtn_val = 0;
  
  fy = thisForm.fyear.selectedIndex;
  ty = thisForm.tyear.selectedIndex;
  
  if (fy>ty)
  {
   info.document.write("<center>Please select the From/To time again</center>");
   rtn_val = 1;
  }
  
  else if (fy == ty){
     fm = thisForm.fmon.selectedIndex;
     tm = thisForm.tmon.selectedIndex;
      
     if (fm > tm)
     {                 
      info.document.write("<center>Please select the From/To time again</center>");
      rtn_val = 1 ;
     }
     
     else if (fm == tm)
     {
       fd = thisForm.fday.selectedIndex;
       td = thisForm.tday.selectedIndex;
       
       if ( fd > td )       
       {                 
       info.document.write("<center>Please select the From/To time again</center>");
       rtn_val = 1;
       }
     }
 }
 
 if (thisForm.vara.selectedIndex == 0 && thisButton.name == "plot")
     {                 
       info.document.write("<center>Please select a variable</center>");
       rtn_val = 1;
     }
 if (thisForm.avr.selectedIndex == 0 )
     {                 
       info.document.write("<center>Please select an interval of averaging</center>");
       rtn_val = 1;
     }

if (thisForm.avrType.selectedIndex == 0 && thisForm.avr.selectedIndex != 1)
     {
       info.document.write("<center>Please select a type of averaging.</center>");
       rtn_val = 1;
     }

     
 if (rtn_val == 0)
    {info.document.write("<Center>You have made a valid selection</Center>");}
 info.document.close();    
 return rtn_val;
 
}

function submitForm(thisButton){

theForm = thisButton.form;

if (!checkForm(theForm,thisButton)) {
     
     theForm.action='http://marine.rutgers.edu/rodan-cgi/Metdata.pl'; 
     theForm.method='post';
     
	
	newWin=window.open("","MetData","menubar=1,scrollbars=1,width=600,height=400");
        theForm.target= 'MetData';
        infoW = newWin;
      

        infoW.document.clear();
	infoW.document.write("<html><body text='#fffff2' bgcolor='#aa2222'>");
	infoW.document.write("We are processing your request...");
	infoW.document.close();

        theForm.requestType.value=thisButton.name;
	theForm.submit();
          parent.info.document.clear();
    
          parent.info.document.write("<html><body text='#fffff2' bgcolor='#aa2222'>");
          parent.info.document.write("Thank you for using RODAN");
}

}
function drawFront(){

 parent.info.document.clear();
 parent.info.document.write("<html><body bgcolor='#aa2222' text='#fffff2'>");
 parent.info.document.write("<center><img src='../anim/fish23.gif'> </center>");
 parent.info.document.close();
}
function RODAN(theForm){
  parent.history.back();
}
