function validateForm(form) {
var d = parseInt( form.SrchFromDay.value );
var m = parseInt( form.SrchFromMonth.value );
var j = parseInt( form.SrchFromYear.value );

if ( !checkDate(d,m,j) ) {
alert("%l:quickfind/incorrectdate%") ;
form.SrchFromDay.focus();
return false;
}
}

function checkDate( d, m, j ) {
var dt = new Date( j, m-1, d );
if ( dt.getDate() != d || dt.getMonth()+1 != m ) return false;
return true;
}

function setCurrentDay() {
var today = new Date(); var today_day = today.getDate();
var today_month = today.getMonth();
var today_year = today.getFullYear();

frmQuickFind = document.getElementById('DOMfrmQuickFind');
frmQuickFind2 = document.getElementById('DOMfrmQuickFind2');

frmQuickFind.SrchFromDay.options[today_day-1].selected = true;
frmQuickFind.SrchFromMonth.options[today_month].selected = true;
frmQuickFind.SrchFromYear.options[0].value = today_year;
frmQuickFind.SrchFromYear.options[0].text = today_year;
frmQuickFind.SrchFromYear.options[1].value = today_year+1;
frmQuickFind.SrchFromYear.options[1].text = today_year+1;

frmQuickFind2.SrchFromDay.options[today_day-1].selected = true;
frmQuickFind2.SrchFromMonth.options[today_month].selected = true;
frmQuickFind2.SrchFromYear.options[0].value = today_year;
frmQuickFind2.SrchFromYear.options[0].text = today_year;
frmQuickFind2.SrchFromYear.options[1].value = today_year+1;
frmQuickFind2.SrchFromYear.options[1].text = today_year+1;
}

function checkIt( d, m, j ) {
        var dt = new Date( j, m-1, d );
        var date = new Date();
        if (dt < date) return false;
        return true;
}

function setFromToDate(value){
         var today = new Date();
         var today_day = today.getDate();
         var today_month = today.getMonth()+1;
         var today_year = today.getFullYear();
         var day = new String(today_day);
         var month = new String(today_month);
         var year = new String(today_year);
         var dayValue = today.getDay();

         if(day.length==1){
                 day = '0'+day;
         }
         if(month.length==1){
                 month = '0'+month;
         }


         if(value == 'TODAY'){
                 var str = year+month+day;
                 frmQuickFind2.DF.value=str;
                 frmQuickFind2.DT.value=str;
         }
         else if(value == 'THISWEEK'){
                 var newDay = today_day-dayValue+7;
                 var str1 = year+month+day;
                 var str2 = year+month+newDay;

                 frmQuickFind2.DF.value=str1;
                 frmQuickFind2.DT.value=str2;
         }
         else if(value == 'NEXTWEEK'){
                 var newDay1 = today_day-dayValue+7+1;
                 var newDay2 = today_day-dayValue+14;
                 var str1 = year+month+newDay1;
                 var str2 = year+month+newDay2;
                 frmQuickFind2.DF.value=str1;
                 frmQuickFind2.DT.value=str2;
         }
         else if(value > 0 && value < 22){
                 var valueDaysInFuture = parseInt(value);
                 var valueThisDay = parseInt(frmQuickFind2.SrchFromDay.value);

                 var d = frmQuickFind2.SrchFromDay.value;
                 var m = frmQuickFind2.SrchFromMonth.value;
                 var y = frmQuickFind2.SrchFromYear.value;
                 var correct = checkIt(d, m, y);
                 if(correct == false){
                         alert("You will search for events in the past!");
                 }
                 var day = new String(d);
                 var month = new String(m);
                 var year = new String(y);



                 if(day.length==1){
                         day='0'+day;
                 }
                 if(month.length==1){
                         month='0'+month;
                 }

                 var newDay3 = valueThisDay+valueDaysInFuture;
                 var str = year+month+day;
                 var str3 = year+month+newDay3;
                 frmQuickFind2.DF.value=str;
                 frmQuickFind2.DT.value=str3;
         }
         else{
                 alert("Error processing value of from-to date!");
         }

}

function setFromToDate2(){
         var days = new String(frmQuickFind2.SrchDays.value);
         setFromToDate(days);
}

function uncheck(){
         document.getElementById("check1").checked=false;
         document.getElementById("check2").checked=false;
         document.getElementById("check3").checked=false;   
}
