function setStyle(newFontSize,newColor,elemID)
{ 
 document.getElementById(elemID).style.fontSize=newFontSize;
 elem = document.getElementById(elemID);
 elem.style.background = newColor;
}

function resetStyle(newFontSize,elemID)
{ 
  //alert ("newFontSize " + newFontSize );
 document.getElementById(elemID).style.fontSize=newFontSize;
 elem = document.getElementById(elemID);

  x=document.getElementsByTagName('body')[0];
  switch (x.className){
     case "blue":
      elem.style.background = '#CCCCFF';
      break;
     case "red2":
      elem.style.background = '#FFB4BB';
      break;
     case "orange":
      elem.style.background = '#FFBA7E';
      break;
    case "teal":
     elem.style.background = '#B6D4DD';
    break;
  }
 
}
function sizeBox(elemID){
  if (/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
    document.getElementById(elemID).cols="21";
  } else 
     document.getElementById(elemID).cols="24";
  
  if(document.getElementById(elemID).value.length < 140){
     document.getElementById(elemID).style.overflow="hidden";
     if (/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
         document.getElementById(elemID).cols="23";
     } else 
        document.getElementById(elemID).cols="26";
  }
}
function FindAQuote(){
   var quote = new Array();
   quote[0] = "We make a living by what we do, but we make a life by what we give.  Winston Churchill";
   quote[1] = "How can we expect our children to know and experience the joy of giving unless we teach them that the greater pleasure in life lies in the art of giving rather than receiving.  James Cash Penny";
   quote[2] = "If you want to lift yourself up, lift up someone else.  Booker T. Washington";
   quote[3] = "No act of kindness, no matter how small, is ever wasted.  Aesop";
   quote[4] = "Never doubt that a small group of thoughtful, committed citizens can change the world; indeed, its the only thing that ever has.  Margaret Mead";
   quote[5] = "You cannot help someone get up a hill without getting closer to the top yourself.  General H. Norman Schwarzkopf";
   quote[6] = "How wonderful it is that nobody need wait a single moment before starting to improve the world.  Anne Frank, Diary of a Young Girl";
   quote[7] = "The moral test of a society is how that society treats those who are in the dawn of life- the children; those who are in the twilight of life- the elderly; and those who are in the shadow of life-the sick, the needy and the handicapped.   Hubert Humphrey";
   quote[8] = "We can do no great things, only small things with great love.  Mother Theresa";
   quote[9] = "There is a tremendous strength that is growing in the world through sharing together, praying together, suffering together and working together.  Mother Theresa";
   quote[10] = "The miracle is this - the more we share, the more we have.  Leonard Nimoy";
   quote[11] = "It is one of the most beautiful compensations of this life that no man can sincerely try to help another without helping himself. Ralph Waldo Emerson";
   quote[12] = "You cannot do a kindness too soon, for you never know how soon it will be too late.  Ralph Waldo Emerson";   
   quote[13] = "Never before has man had such a great capacity to control his own environment, to end hunger, poverty and disease, to banish illiteracy and human misery. We have the power to make the best generation of mankind in the history of the world.  President John F. Kennedy"

	var randomnumber=Math.floor(Math.random()*13);//gen a random number 1 thru 15 
	
	if (randomnumber > -1 && randomnumber < 14){
	   return quote[randomnumber];
	} else {
		return " ";
	}
}
function DaysUntil(FontSize,NewDate,elemID,Description){
//alert ("Description " + Description);
var d = new Date(NewDate);
//var date = new Date("January 1, 2003");
//var description = NewDate;
var now = new Date();
//alert ("now " + now);
var diff = d.getTime() - now.getTime();
//alert ("d.getTime() " + d.getTime());
//alert ("diff " + diff);
var days = Math.floor(diff / (1000 * 60 * 60 * 24));
//alert ("Description " + Description);
if (isNaN(days) || days<0){ 
   document.getElementById(elemID).value=FindAQuote();  //If nothing is scheduled put in a random quote
} else {
   Description =  Description + 'on '
   switch (days){   
     case 0:
      document.getElementById(elemID).value="Tomorrow is " + Description + NewDate;
	  break;
     case 1:
        document.getElementById(elemID).value="Only two days until " + Description + NewDate;
	  break;
	  default:
        document.getElementById(elemID).value="There are " + (days+1) + " days until " + Description + NewDate;
   }
 }
//document.getElementById(elemID).value="There are 15 days until our next event which is scheduled on March 2, 2009 There are 15 days until our next event which is scheduled on March 2, 2009 There are 15 days until our next event which is scheduled on March 2, 2009 There are 15 days until our next event which is scheduled on March 2, 2009 "
 //document.getElementById(elemID).value="There are " + (days+1) + " days until " + Description + NewDate;
 //document.getElementById(elemID).value=document.getElementById(elemID).value + "There are " + (days+1) + " days until " + Description + NewDate";
 
 document.getElementById(elemID).readOnly=true;

 resetStyle(FontSize,elemID);
 sizeBox(elemID);
 
/*document.write("<center><h3>")
if (days > 1) {
document.write(days+1 + " days until " + description);
}
else if (days == 1) {
document.write("Only two days until " + description);
}
else if (days == 0) {
document.write("Tomorrow is " + description);
}
else {
document.write("It's" + description + "!");
}
document.write("</h3></center>");
*/
}
function DaysUntil2(NewDate){
//	alert("1rrrr " );
 //  var NewDate2 ="";
   var txt=""
   var now = new Date();
   var Newdate2 = "";
  //  var now2 = new Date();
	//alert("3rrrr " );
   var MonthFullName=["January", "February", "March", "April", "May", "June","July", 
	"August", "September", "October", "November", "December"];
  // alert("4rrrr " );
   var MonthShortName=["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", 
	"Aug", "Sep", "Oct", "Nov", "Dec"];
 //  alert("5rrrr " );
   var month_check = -1;
   var imonth=0;
 //  var date = new Date(NewDate2); 2009-02-04;
  //NewDate="January 1, 2009";
 //   alert("NewDate " + NewDate);
  if (IsNumeric(NewDate.substring(0,4)) ){ //assuming yyyy-mm-dd
      var temp = NewDate;
	  var imonth=NewDate.substring(5,7);
	  var idate = NewDate.substring(8,10);
	  NewDate=MonthFullName[imonth-1]+" " +idate+","+NewDate.substring(0,4);
//	  alert("NewDate " + NewDate);
 //alert("idate " + idate);
     // alert("imonth " + imonth);
  }
  var date = new Date(NewDate);
 // alert("NewDate " + NewDate);
  try
  {
    var newYear = date.getYear(); 
    if (date.getYear() < 100){
	    newYear=newYear+2000;
        date.setFullYear(newYear);
  	}
 // 	alert("NewDate2 " + newYear);
  	
    var diff = date.getTime() - now.getTime();
    var days = Math.floor(diff / (1000 * 60 * 60 * 24));
    if (isNaN(newYear) || isNaN(diff) || isNaN(days) ) {
        //"Invalid Date "  
        return 1;
    } 
    if(days<3)
	   return 2; //error < 3 days
    else 
       return 0; //OK
  }
  catch(err)
  {
  txt="There was an error on this page.\n\n";
  txt+="Error description: " + err.description + "\n\n";
  txt+="Click OK to continue.\n\n";
     alert(txt);
  }
    return 0;
//}
  }
 // Return a boolean value telling whether // the first argument is a string. 
function isString(argument) {
	if (typeof argument == 'string') return true;
	if (typeof argument == 'object') {  var criterion =   

    arguments[0].constructor.toString().match(/string/i); 
    return (criterion != null);  }return false;
 }
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
/* Date Format 1.2.2
 * (c) 2007-2008 Steven Levithan <stevenlevithan.com>
 * MIT license
 * Includes enhancements by Scott Trenda <scott.trenda.net> and Kris Kowal <cixar.com/~kris.kowal/>
 *
 * Accepts a date, a mask, or a date and a mask.
 * Returns a formatted version of the given date.
 * The date defaults to the current date/time.
 * The mask defaults to dateFormat.masks.default.
 */
var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;

		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && (typeof date == "string" || date instanceof String) && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date();
		if (isNaN(date)) throw new SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};
