function setQueryText(inForm)
{
   var vars = [], hash;
   vars=getUrlVars();
				  var advFromDay=inForm.advFromDay.options[inForm.advFromDay.selectedIndex].text;
				   var advFromMonth=inForm.advFromMonth.options[inForm.advFromMonth.selectedIndex].value;
				   var advFromYear=inForm.advFromYear.options[inForm.advFromYear.selectedIndex].text;
				   var advToDay=inForm.advToDay.options[inForm.advToDay.selectedIndex].text;
				   var advToMonth=inForm.advToMonth.options[inForm.advToMonth.selectedIndex].value;
				   var advToYear=inForm.advToYear.options[inForm.advToYear.selectedIndex].text;
				   var toadd=1;
				   advFromMonth = toadd + parseInt(advFromMonth);
				   
				   advToMonth = toadd+parseInt(advToMonth);
				   if(advFromMonth < 10){
				   	 advFromMonth = "0" +advFromMonth;
					}
				   if(advToMonth <10){
				   	 advToMonth = "0"+ advToMonth;
					 }
				   if(advFromDay < 10){
				   	 advFromDay = "0" +advFromDay;
					}
				   if(advToDay <10){
				   	 advToDay = "0"+ advToDay;
					 }
					   if(advFromDay != "Day"){
				        var daterange = "inmeta:effective_date:daterange:"+advFromYear+"-"+advFromMonth+"-"+advFromDay+".."+advToYear+"-"+advToMonth+"-"+advToDay
				     	inForm.q.value = inForm.queryText.value +" "+ daterange;
						}
					else{
						inForm.q.value = inForm.queryText.value;
						}
    inForm.action="notices.html";
    inForm.submit();
}


function microsoftKeyPress(inForm) 
{  
   if (window.event.keyCode == 13) 
   {                                         
      inForm.submit();                                
     
   }	                                                
}  

function pageChangeMarker(inForm)
{	
	inForm.pageChange.value = "true";
}

function queryTextEntered(inForm)
{
	if (inForm.queryText.value != "")
	{
	  inForm.pageChange.value = "true";	
  }
  else
	{
		inForm.pageChange.value = "false";
	}			
}	


   
function advAllCheckBox(inForm)
{	
	
   if(inForm.advAllDates.checked == true)
   {
      inForm.advAllDatesHidden.value = "true";   
     
      //create new options in the drop down with thecorrect label
       if(inForm.advFromDay.options[0].value != "Day")
       {
          AddMeDay = new Option("Day", "Day");        
 
          inForm.advFromDay.add(AddMeDay, 0);
          inForm.advFromDay.options[0].selected =true;
       }
       
       if(inForm.advToDay.options[0].value != "Day")
       {
          AddMeDay2 = new Option("Day", "Day");   
          inForm.advToDay.add(AddMeDay2, 0);
          inForm.advToDay.options[0].selected = true; 
 
       }
       
       if(inForm.advFromMonth.options[0].value !="Month")
       {      
          AddMeMonth = new Option("Month", "Month");  
          inForm.advFromMonth.add(AddMeMonth, 0);
          inForm.advFromMonth.options[0].selected =true;  
       }
 
       if(inForm.advToMonth.options[0].value !="Month")
       {
          AddMeMonth2 = new Option("Month", "Month"); 

          inForm.advToMonth.add(AddMeMonth2, 0);
          inForm.advToMonth.options[0].selected =true; 
       }
 
       if(inForm.advFromYear.options[0].value !="Year")
       {
          AddMeYear = new Option("Year", "Year");  
          inForm.advFromYear.add(AddMeYear, 0);
          inForm.advFromYear.options[0].selected =true;   
       }
       
       if(inForm.advToYear.options[0].value != "Year")
       {
          AddMeYear2 = new Option("Year", "Year");  
          inForm.advToYear.add(AddMeYear2, 0);
          inForm.advToYear.options[0].selected = true;

       } 
       
       inForm.advFromDay.disabled = true;      
       inForm.advToYear.disabled = true;   
       inForm.advFromYear.disabled = true;   
       inForm.advToMonth.disabled = true; 
       inForm.advFromMonth.disabled = true;  
       inForm.advToDay.disabled = true;  
    }
    else
  	{ 		
       inForm.advAllDatesHidden.value = "false";		
       inForm.advFromDay.disabled = false;
       inForm.advFromMonth.disabled = false;
       inForm.advFromYear.disabled = false;
       inForm.advToMonth.disabled = false;
       inForm.advToDay.disabled = false;
       inForm.advToYear.disabled = false;  		
  	}	           
}         
   


function advDates(field, newValue, inForm)
{ 
	
	 inForm.advAllDates.checked=false;
   
   if(inForm.advFromMonth.options[0].value == "Month")
   {	
      inForm.advFromMonth.options[0] = null;
      
      //set the user selected value as selected    
      if (field.name =="advFromMonth"){inForm.advFromMonth.options[field.selectedIndex].selected= true;}
      else{inForm.advFromMonth.options[0].selected =true;}         
   }
   
   if(inForm.advFromDay.options[0].value == "Day")
   {	
      inForm.advFromDay.options[0] = null;
      
      //set the user selected value as selected    
      if (field.name =="advFromDay"){inForm.advFromDay.options[field.selectedIndex].selected= true;}
      else{inForm.advFromDay.options[0].selected =true;}         
   }
   
   if(inForm.advFromYear.options[0].value == "Year")
   {	
      inForm.advFromYear.options[0] = null;
      
      //set the user selected value as selected    
      if (field.name =="advFromYear"){inForm.advFromYear.options[field.selectedIndex].selected= true;}
      else{inForm.advFromYear.options[0].selected =true;}        
   }
   
   if(inForm.advToDay.options[0].value == "Day")
   {	
      inForm.advToDay.options[0] = null;
      
      //set the user selected value as selected    
      if (field.name == "advToDay"){inForm.advToDay.options[field.selectedIndex].selected= true;}
      else{inForm.advToDay.options[0].selected =true;}        
   }
   
   if(inForm.advToMonth.options[0].value == "Month")
   {	
      inForm.advToMonth.options[0] = null;
     inForm.advToMonth.options[field.selectedIndex].selected= true;
   }
   
   if(inForm.advToYear.options[0].value == "Year")
   {	
      inForm.advToYear.options[0] = null;
      //set the user selected value as selected    
      if (field.name =="advToYear"){inForm.advToYear.options[field.selectedIndex].selected= true;}
      else{inForm.advToYear.options[0].selected =true;}  
   }   
}	

function checkChoice(field, i) 
{
	
   // "All" checkbox selected.
   if (i == 0) 
   {
      if (field[0].checked == true)
      {
         for (i = 1; i < field.length; i++)
         {  
            field[i].checked = false;
         } 
      }		      
   }
   else// A checkbox other than "Any" selected.  
   {  
      if (field[i].checked == true)  
      {	
         field[0].checked = false;
      }
   }	
}


//javascript source
function populateAdvDropDowns(inForm)
{
	
      var today= new Date();
      var day= today.getDate();
      var month= today.getMonth();
      var year= today.getFullYear();
      
      if (inForm.advFromDay.length <= 1)
      {        
         //days
         for (var i=1; i <32 ; i++)
         {
         	 inForm.advFromDay.options[i] = new Option(i,i);
         	 inForm.advToDay.options[i] = new Option(i,i);  	 	 
         }    
         //display 5 years
         for (var i=1,j=year; i < 6 ; i++, j--)
         {
         	 var y= String(j);
         	 inForm.advFromYear.options[i] = new Option(y,y);
         	 inForm.advToYear.options[i] = new Option(y,y);
         } 
      }   
}


//javascript source
function populateAdvToDay(inForm2)
{

   var numDays =0;
   
   if(inForm2.advToMonth.options[1].selected)
   {
      //February
      numDays=29;
   }
   else if(inForm2.advToMonth.options[8].selected||inForm2.advToMonth.options[3].selected||inForm2.advToMonth.options[5].selected||inForm2.advToMonth.options[10].selected)
   {
      //March, August, May, October
      numDays=30;
   }
   else
   {	
      numDays=31;
   }
   
   //set all to null
   for(i=0;i<31;i++)
   {
      inForm2.advToDay.options[i]=null;
   }
   
   //only populate those needed
   for (var i=0; i < numDays ; i++)
   {
   	 var x= String(i+1);
   	 inForm2.advToDay.options[i] = new Option(x);
   }
}

//javascript source
function populateAdvFromDay(inForm2)
{
   var numDays =0;
   
   if(inForm2.advFromMonth.options[1].selected)
   {
      //February
      numDays=29;
   }
   else if(inForm2.advFromMonth.options[8].selected||inForm2.advFromMonth.options[3].selected||inForm2.advFromMonth.options[5].selected||inForm2.advFromMonth.options[10].selected)
   {
      //March, August, May, October
      numDays=30;
   }
   else
   {	
      numDays=31;
   }
   
   //set all to null
   for(i=0;i<31;i++)
   {
      inForm2.advFromDay.options[i]=null;
   }
   
   //only populate those needed
   for (var i=0; i < numDays ; i++)
   {
   	 var x= String(i+1);
   	 inForm2.advFromDay.options[i] = new Option(x);
   }
}

function getUrlVars(){    
	var vars = [], hash;    
	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');     
	for(var i = 0; i < hashes.length; i++)    
		{        
			hash = hashes[i].split('=');
			vars.push(hash[0]);        
			vars[hash[0]] = hash[1];    
	}     
	return vars;
	}
function allDatesCheck(inForm, category)
{
	//category 1 is advisory
	if (category == 1 && inForm.category[1].checked == false)
	{
	  inForm.advAllDates.checked = true; 	
	  advAllCheckBox(inForm);
	} 


} 