//The array is a binary statement of whether the restaraunt is open (1) or
// closed (0) at any given half-hour.
//
// Array 1 is for weekdays, Array 2 is for weekends.

// Argonne Cafeteria
var cafe1 = new Array(48);
cafe1 = [0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 1,1, 1,0, 0,0, 0,0, 0,1,
         1,1, 1,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0];
var cafe2 = new Array(48);
cafe2 = [0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
         0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0];
// Guest House
var gh1 = new Array(48);
gh1   = [0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 1,1, 1,0, 0,0, 0,0, 1,1,
         1,1, 1,0, 0,0, 0,0, 0,0, 1,1, 1,1, 1,1, 1,1, 0,0, 0,0, 0,0];
var gh2 = new Array(48);
gh2   = [0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 1,1, 1,1, 1,1, 1,1, 0,0,
         0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0];
// 401 Grille
var foo1 = new Array(48);
foo1  = [0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 1,1,
         1,1, 1,1, 0,0, 0,0, 0,1, 1,1, 1,1, 1,1, 0,0, 0,0, 0,0, 0,0];
var foo2 = new Array(48);
foo2  = [0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,1,
         1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 0,0, 0,0, 0,0, 0,0, 0,0];

var mydate = new Date();

function ocstat(arg) {
        if (arg) {
                document.write("<FONT color='green'>OPEN</FONT>");
        } else {
                document.write("<FONT color='red'>CLOSED</FONT>");
        }
}
function nextstat(arr,arg) {
        i = arg;
        while (arr[i] == arr[arg] && i<arr.length) {
                i++;
        }
        if (i == arr.length) {
                i = 0;
                while (arr[i] == arr[arg] && i<arr.length) {
                        i++;
                }
                if (i == arr.length) {
                        return -1;
                }
        }
        return i;
}
function displaystat(name,arr) {
        document.write(name+" is ");
        ti = parseInt(mydate.getHours()*2+mydate.getMinutes()/30.);
        ocstat(arr[ti]);
        nti = nextstat(arr,ti);
        if (nti != -1) {
                document.write(" and will be ");
                ocstat(1-arr[ti]);
                hr = parseInt(nti/2);
                min = 30*(nti-2*hr)
                if (min == 0) {
                        if (hr < 10) {
                                document.write(" at 0"+hr+":00<BR>");
                        } else {
                                document.write(" at "+hr+":00<BR>");
                        }
                } else {
                        if (hr < 10) {
                                document.write(" at 0"+hr+":"+min+"<BR>");
                        } else {
                                document.write(" at "+hr+":"+min+"<BR>");
                        }
                }
        } else {
                document.write(" today.<BR>");
        }
}
