function validate(){
    // Function to validate form values etc
    // Grab any form params we are gonna use
    var fromday=document.form1.fromday.value;
    var frommon=document.form1.frommon.value;
    var fromyear=document.form1.fromyear.value;
    
    
    // check from date simple AND adv
    if((fromday && (!frommon || !fromyear))||(frommon && (!fromday && !fromyear))||(fromyear && (!fromday && !frommon))){
       alert("You must enter a complete and valid date\ni.e. 01/01/2005");
       return false;
    }
    
    
    //If from date entered, check that it is a valid date
    if (fromday && frommon && fromyear) {
        var dateString = fromday + "\/" + frommon + "\/" + fromyear; 
        if (isDate(dateString)==false){
		    return false;
	    }
    }
    // Pad single digit date elements
    if(fromday.length<2)
        fromday="0"+fromday;
            
    if(frommon.length<2)
        frommon="0"+frommon;
    
    var myFromDate = fromyear+frommon+fromday;
    
    // Compare to system time
    
   
    if(myFromDate>systemTime){
        alert("You may only search for News Stories with Dates up to and including the current date."); 
        return false;
    }
    
    
    
    if (document.form1.today){ // Must be adv search
        var today=document.form1.today.value;
        var tomon=document.form1.tomon.value;
        var toyear=document.form1.toyear.value;
        
        // check to date
        if((today && (!tomon || !toyear))||(tomon && (!today && !toyear))||(toyear && (!today && !tomon))){
            alert("You must enter a complete and valid date\ni.e. 01/01/2005");
            return false;
        }
        if(today.length<2)
            today="0"+today;
            
        if(tomon.length<2)
            tomon="0"+tomon;
               
        var myToDate = toyear+tomon+today;
        
        if(myToDate>systemTime){
            alert("You may only search for News Stories with Dates up to and including the current date."); 
            return false;
        }
        
        //If complete to date entered, check that it is a valid date
        if (today && tomon && toyear) {
            var dateString = today + "\/" + tomon + "\/" + toyear; 
            if (isDate(dateString)==false){
		        return false;
	        }
        }
        
    }
    return true;
}