
        function setDates() {
         
         today = new Date();
         today_plus = new Date();
         today_plus.setDate(today.getDate( ) + 30);
         
         var month = today.getMonth();
         var day = today.getDate();
         var year = today.getFullYear();
         var month_plus = today_plus.getMonth();
         var day_plus = today_plus.getDate();
         var year_plus = today_plus.getFullYear();
         
         
         
         document.criteria_search.from_month.options[month].selected = true;
         document.criteria_search.from_day.options[day-1].selected = true;
         document.criteria_search.to_month.options[month_plus].selected = true;
         document.criteria_search.to_day.options[day_plus-1].selected = true;

         for (i=0; i < document.criteria_search.from_year.options.length; i++) {
             if (year == document.criteria_search.from_year.options[i].value)
               document.criteria_search.from_year.options[i].selected = true;
         }

         for (i=0; i < document.criteria_search.to_year.options.length; i++) {
             if (year_plus == document.criteria_search.to_year.options[i].value)
               document.criteria_search.to_year.options[i].selected = true;
         }
         
        }

      function setStickyDates(startYear, startMonth, startDay, endYear, endMonth, endDay) {
         document.criteria_search.from_month.options[startMonth-1].selected = true;
         document.criteria_search.from_day.options[startDay-1].selected = true;
         document.criteria_search.to_month.options[endMonth-1].selected = true;
         document.criteria_search.to_day.options[endDay-1].selected = true;
         
         for (i=0; i < document.criteria_search.from_year.options.length; i++) {
             if (startYear == document.criteria_search.from_year.options[i].value)
               document.criteria_search.from_year.options[i].selected = true;
         }
         
         for (i=0; i < document.criteria_search.to_year.options.length; i++) {
             if (endYear == document.criteria_search.to_year.options[i].value)
               document.criteria_search.to_year.options[i].selected = true;
         }
         
      }


        function submitRequest(type){
          window.location=baseurl + "&type=" + type;



        }

        function submitCriteria() {
          var frm=document.criteria_search;
          fromYear = getSelVal(frm.from_year);
          fromMonth= getSelVal(frm.from_month);
          fromDay =  getSelVal(frm.from_day);
          toYear = getSelVal(frm.to_year);
          toMonth = getSelVal(frm.to_month);
          toDay = getSelVal(frm.to_day);
          loc = getMultiSelVal(frm.location);
          type=getMultiSelVal(frm.type);
          paramType="";
          paramLoc="";
          
          //alert("to Month" + parseInt(toMonth));
          //alert("to Year:" + parseInt(toYear));
          
          //start = new Date(parseInt(fromYear),parseInt(fromMonth)-1,parseInt(fromDay));
          //end = new Date(parseInt(toYear),parseInt(toMonth)-1,parseInt(toDay));
          start = new Date(fromYear,fromMonth-1,fromDay);
          end = new Date(toYear,toMonth-1,toDay);
          
          
          if (end < start) {
            alert("End Date Must Be Later Than Start Date");
            return false;

          }

          paramDateStart="&dateStart=" + formatDate(fromYear, fromMonth, fromDay);
          paramDateEnd="&dateEnd=" + formatDate(toYear, toMonth, toDay) + "%2023:59:59" ;
 
         

          if (loc != ""){
            paramLoc = "&location=" + escape(loc);

          }
         
          
          if (type != "") {
            paramType = "&query_type=" + escape(type);
          }
        
          
         window.location = "dynamic.php?categoryFilter=TAE&click=search" + paramDateStart + paramDateEnd + paramType + paramLoc;
          

        }



        function getMultiSelVal(opt) {
          
          result="" ;
          for (var idx=0; idx < opt.length; idx++) {
             current = opt[idx];
            if (current.selected && current.value != '') {
              result += opt[idx].value + ",";
              
             }
          }
          return result.substring(0, result.length - 1);
        }

        
        function formatDate(y,m,d) {
          return y + '-' + m + '-' + d;
        }

        function deleteOption(object,index) {
       
         object.options[index] = null;
        }

       
        function populateDays(selMonth, selDay, selYear) {
          isLeapYear(getSelVal(selYear));
           
          month = getSelVal(selMonth);
          days_now = selDay.length;
          days_needed=31;
          
          switch(month) {
            
           case '04':
           case '06':
            case '09':
            case '11':
              days_needed=30;
            break;

            case '02':
              days_needed=28 ;
              if (isLeapYear(getSelVal(selYear))){
              days_needed=29;
              }
            break;                 
          }
           
          
          if(days_needed < days_now){
             for (x=days_now; x>=days_needed; x--){
               deleteOption(selDay, x);
            }

          }
          else {
              for (x=days_now+1; x<=days_needed; x++){
               
              addOption(selDay, x+'', x+'');
            
              }
          } 


           


         

        }
        
        function adjustForLeap(selYear, selMonth, selDay){
         
          month = parseInt(getSelVal(selMonth));
          isLeap= isLeapYear(getSelVal(selYear));
         
          if (month==2) {
              if (isLeap  && selDay.length==28) {
                  addOption(selDay, '29', '29');
              }
            if ((isLeap==false) && selDay.length==29) {
                
                 deleteOption(selDay, 28);
              }
         }
              
        }
  
  
  function isLeapYear(strYear) {
     yr = parseInt(strYear);
     
    
     if ((yr % 4) == 0) {
       return true;
     
     }
     return false;
  
  }         

function addOption(object,text,value) {
    var defaultSelected = false;
    var selected = false;
    var optionName = new Option(text, value, defaultSelected, selected)
    object.options[object.length] = optionName;
}

        

        

        function getDate(selYear, selMonth, selDay) {
          year = getSelVal(selYear);
          month =getSelVal(selMonth);
          day = getSelVal(selDay);
          return (year + '-' + month + '-' + day)


        }

         function getSelVal(sel) {
         return sel.options[sel.selectedIndex].value;

        }

function bigNewWindow(a) {
      strWidth = screen.width + '';
      strHeight = screen.height + '';


      str_atts = "width=" + strWidth + ", height=" + strHeight + ", location=yes, menubar=yes, resizable=yes, left=0, top=0, resizable=yes, scrollbars=yes"

    //alert(str_atts);
  
  if (window.popUp && window.popUp.open && !window.popUp.closed) {
    popUp.location = a.href;
    popUp.focus();
    

  }
  else {
    popUp=window.open(a.href,
    '',str_atts)
    popUp.focus();
    
    

  }
}
 
function smallNewWindow(a) {
  if (window.popUp1 && window.popUp1.open && !window.popUp1.closed) {
    popUp1.location = a.href;
    popUp1.focus();

    }

   else {
    popUp1=window.open(a.href,
    '', 'width=350, height=350, resizable=yes, menubar=yes, location=yes, scrollbars=yes')
    popUp1.focus();
    
    

  }

}



        
