<!--
// ********************************************************
// To Use this Script, simply insert the start and end hours,
// and your greetings
//
// That's all there is; no code to change.
//
// NOTE: use a \ before any ' or " characters that appear
//       in your greetings
// ********************************************************

// *********************************************
// Definition of our greeting object and methods
// *********************************************
window.onerror = myError;
function myError(message, url, line){

  return true;
}
function greeting(start,end,greet) {
  // check to see if values are reasonable
  if (start<0 || start>23) {
    alert("Invalid Hour: "+start);
    return;
    }
  else if(end<0 || end>23) {
    alert("Invalid Hour: "+end);
    return;
    }
  if (start <= end) {
    this.start=start;
    this.end=end;
  }
  else {
    this.start=end;
    this.end=start;
  }
  this.greet=greet;
}
function greetingToString() {
  return this.greet;
}
greeting.prototype.toString = greetingToString;

// **************************************
// Definition of an Array of link objects
// **************************************
function greetingArray() {
  var a = greetingArray.arguments;
  if (a.length%3!=0) {            // Make sure the number of arguments is a mulitple of three
    alert("Can not initialize Greeting Array: Incorrect number of strings");
    this.length=0;
  }
  else {                          // Loop thru the argments creating link objects
    for (ti=ai=0;ai<a.length;ti++,ai+=3) {
      this[ti]=new greeting(a[ai],a[ai+1],a[ai+2]);
    }
    this.length=a.length/3;
  }
}

var greetingList = new greetingArray(
  // *****************************************************
  // Place Times and Greetings Here, Separated by Commas
  // Format: start hour, end hour, Greeting
  // NOTE: use a \ before any ' or " characters that appear
  //       in your Greetings
  // *****************************************************

   0,11,"morning",
  12,17,"afternoon",
  18,23,"evening"

  // ************************************
  // !NOTE: No Comma after last Greeting!
  // ************************************
)
// ***********************************
// Function to return correct greeting
// ***********************************
function TODgreeting() {
  var today = new Date();
  var hr = today.getHours();
  for(i=0;i<greetingList.length;i++) {
    if (hr>=greetingList[i].start && hr<=greetingList[i].end) {
      return greetingList[i];
    }
  }
  return "Day"
}
// *******************************
// This code displays the greeting
// *******************************
document.write("Good "+TODgreeting()+"");

// -->

		
