// Hidden Earth Booking Form
// Copyright 2007,2008, 2009, 2010 David Gibson
// This file is catalogue-specific - not a 'shared' file
// This file contains text specific to the year 2010, which must be edited for 2011


var local_date = new Date;
var date_today = new Date(server_time * 1000);  // fetch time from server; the 'Olly Betts' bug

// month numbering starts at zero, so September is month 8 in the functions below.
var date_open   = new Date(2010,4,31,01,0,0,0); // 01:00 on     31 May  (sic) 2010 office opens
var date_postal = new Date(2010,8,10,17,0,0,0); // 17:00 on Fri 10 Sept (sic) 2010 postal bookings deadline
var date_closed = new Date(2010,8,18,23,0,0,0); // 23:00 on Sat 18 Sept (sic) 2010 office closes
var date_event  = new Date(2010,8,26,23,0,0,0); // 23:00 on Sun 26 Sept (sic) 2010 date of event
// NB: Cant say '08' for month 8, above, as leading zero is interpreted as Octal


function officeClosed()
// return true if bookings are not allowed at this date

{    
    if (date_today < date_open)
    {
       window.alert('The Advance Bookings office is closed. \n' +
    	     'It will not open until 1 June');
    	     
/*       window.alert('debug info (please ignore):\n' + 
       '\nserver time:    ' + server_time + 
       '\ninterpreted as: ' + date_today +
       '\nlocal time:     ' + local_date);
*/

       q = window.prompt('Hidden Earth staff who are testing this form, \n' +
       			  'please enter your id. (server_time = ' + server_time + ')');
       if (q == "adwg") 
       {
         window.alert('Form available for testing');
         return false;  // Ok, not at all secure, but adaquate!
       }

       return true;
    }

    if (date_today <= date_postal)
    { return false; }
      
    if (date_today <= date_closed)
    { window.alert('Please note that postal bookings have now closed for this year.\n' +
                     'If you continue, you will have to pay on-line');
       return false;
    }
      
    if (date_today <= date_event)
    { window.alert('Advance bookings have now closed for this year.\n'); 
       return true;
    }
      
    window.alert('The Advance Bookings office is closed for this year. \n' +
    		 'It will re-open on 1 June next year, we expect.');
    return true;
}

// returns true if postal bookings are allowed at this date

function postalOK()
{
    if (date_today > date_postal)
    { window.alert('Please note that postal bookings have now closed for this year.\n' +
                     'If you continue, you will have to pay on-line');
      return false;
    }
    return true;
}


