// this table holds your special days, so that we can automatize
// things a bit:
var SPECIAL_DAYS = {
    0 : [ 1, 6 ],
3: [ 8,9,25 ],   
    4 : [ 1 ],     
    5 : [ 2 ],
    7 : [ 15 ],
    10: [ 1 ],
    11: [ 8,25,26]
};

// this function returns true if the passed date is special
function dateIsSpecial(year, month, day) {
    var m = SPECIAL_DAYS[month];
    if (!m) return false;
    for (var i in m) if (m[i] == day) return true;
    return false;
}

// this is the actual date status handler.  Note that it receives the
// date object as well as separate values of year, month and date, for
// your confort.
function dateStatusHandler(date, y, m, d) {
    today=new Date();
    if( date<(today-24*60*60*1000) ) return true;
    if (dateIsSpecial(y, m, d)) return 'special';
    //else return false;
    return false;
    // return true above if you want to disable other dates
}

function resetDate(datefield)
{
  var field=document.getElementById(datefield);
  field.value='(tutte)';
}
// configure it to the calendar
//calendar.setDateStatusHandler(dateStatusHandler);

function cleanForm()
{
  new Ajax.Updater('sidesearchbox', 'gensidesearchbox.php', 
    { 
      method: 'post',
      parameters: 
      {
        act: 'reset'
      },
      evalScripts: true
    });
}


function SetDataRitorno(valore)
{
    $('d2').value = valore;
}

function disabilitaDateDa(date)
{
    var y = $('d1').value.substr( 6,4 );
    var m = $('d1').value.substr( 3,2 )-1;
    var d = $('d1').value.substr( 0,2 );

    var ctr_date = new Date(y,m,d);
    if (date.getTime() < ctr_date.getTime()) return true;
    if (dateIsSpecial(y, m, d)) return 'special';

    return false;
}
