  var switchMonth = false;
  var onloadRan = false;
  
  function showError(obj, hide, message)
{
  if(hide)
  {
    // remove the "required" class from the object
    classSwapping("remove", obj, "required");

    if(document.getElementById(obj.id + "ErrorImage"))
    {
      // hide the error icon
      classSwapping("add", document.getElementById(obj.id + "ErrorImage"), "hidden");
    }
    if(document.getElementById(obj.id + "ErrorMessage"))
    {
      //hide the error message
      classSwapping("add", document.getElementById(obj.id + "ErrorMessage"), "hidden");
    }
    if(!classSwapping("check", document.getElementById('errorMessagesDiv', "hidden")))
    {
      checkForErrorMessages('errorMessagesDiv');
    }
  }
  else
  {
      // add the "required" to the input field
      classSwapping("add", obj, "required");

      if(document.getElementById(obj.id + "ErrorImage") && obj.getAttribute('label'))
      {
        // set the alt attribute of the error icon image to the error message
        document.getElementById(obj.id + "ErrorImage").alt = obj.getAttribute('label') + " " + message;

        //set the title of the error icon image to the alt attribute
        document.getElementById(obj.id + "ErrorImage").title = document.getElementById(obj.id + "ErrorImage").alt;
        // display the error icon image by removing the "hidden" class
        classSwapping("remove",document.getElementById(obj.id + "ErrorImage"), "hidden");
      }
      if(!document.getElementById(obj.id + "ErrorMessage"))
      {
        var messageList = document.getElementById('errorMessageList');
        if(messageList)
        {
          var newErrorMessage = document.createElement('li');
          newErrorMessage.setAttribute('id', obj.id + "ErrorMessage");
          classSwapping('add', newErrorMessage, 'hidden');
          messageList.appendChild(newErrorMessage);
        }
      }
      if(document.getElementById(obj.id + "ErrorMessage") && obj.getAttribute('label'))
      {
        //set the inner html of the error list item to the error message
        document.getElementById(obj.id + "ErrorMessage").innerHTML =
            "<strong>" + obj.getAttribute('label') + "</strong> " + message;

        //display the error message by removing the "hidden" class from the list item
        classSwapping("remove", document.getElementById(obj.id + "ErrorMessage"), "hidden");
      }
  }
}

function checkForErrorMessages(divName)
{
    // local variable that indicates whether or not there are any error messages to display; initializes to false;
    var errorMessagesExist = false;

    //check to see if the div that contains the error messages has been defined
    if(document.getElementById(divName))
    {
        // local variable that contains all of the list elements that hold the error messages
        var errorMessages = document.getElementById(divName).getElementsByTagName("li");

        // local variable that will be used to either hide or reveal the error message
        var a = "";

        // foreach list items check to see if it contains a visible error
        for(var i = 0; i < errorMessages.length; i++)
        {
            // if the list item doesn't contain the hidden class that means it has an error message to display
            if(!classSwapping("check", errorMessages[i], "hidden"))
            {
                // set the flag to true
                errorMessagesExist = true;
            }
        }
        //if messages exist then set the action to remove the hidden class, otherwise we want to add it
        a = errorMessagesExist? "remove": "add";

        //set the FormSubmitter variable  = to the local variable
        self.errorMessagesVisible = errorMessagesExist;

        //add or remove the hidden class to either display or hide the error message
        classSwapping(a, document.getElementById(divName), "hidden");
    }

}
  function setButtonBehavior(obj, button_type)
  {
    switch(button_type)
    {
      case 'write':
        obj.onmouseover = function()
        {
          this.src = bttn_write_over;
        }
        obj.onmouseout = function()
        {
          this.src = bttn_write_norm
        }
        obj.onmousedown = function()
        {
          this.src = bttn_write_down
        }
        obj.onmouseup = function()
        {
          this.src = bttn_write_norm
        }
      break;
      case 'close':
        obj.onmouseover = function()
        {
          this.src = bttn_close_over;
        }
        obj.onmouseout = function()
        {
          this.src = bttn_close_norm;
        }
        obj.onmousedown = function()
        {
          this.src = bttn_close_down;
        }
        obj.onmouseup = function()
        {
          this.src = bttn_close_norm;
        }
      break;
      case 'up':
        obj.onmouseover = function()
        {
          this.src = bttn_up_over;
        }
        obj.onmouseout = function()
        {
          this.src = bttn_up_norm;
        }
        obj.onmousedown = function()
        {
          this.src = bttn_up_down;
        }
        obj.onmouseup = function()
        {
          this.src = bttn_up_norm;
        }
      break;
    }
  }
  

    function classSwapping(a,o,c1,c2)
    {
      switch (a){
        case 'swap':
          o.className =! classSwapping('check',o,c1)?o.className.replace(c2,c1):
          o.className.replace(c1,c2);
        break;
        case 'add':
          if(!classSwapping('check',o,c1)){o.className+=o.className?' '+c1:c1;}
        break;
        case 'remove':
          var rep=o.className.match(' '+c1)?' '+c1:c1;
          o.className=o.className.replace(rep,'');
        break;
        case 'check':
          return new RegExp('\\b'+c1+'\\b').test(o.className)
        break;
      }
    }

  function getHTTPRequest()
  {
    var xmlHttp;
    try
    {
      // Firefox, Opera 8.0+, Safari
      xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
      // Internet Explorer
      try
      {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      {
        try
        {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
        {
          alert("Your browser does not support AJAX, which is required to use this website.");
          xmlHttp = false;
        }
      }
    }
    return xmlHttp;
  }
function addEventCalendar(parentObj, theYear, theMonth, theDate)
{
  detailLink = 'calendar_day.php';
  EventCalendar = new PhyneasJavascriptEventCalendar("sms", theYear, theMonth, theDate);
  EventCalendar.setShowOtherMonths(false);
  EventCalendar.buildHTMLElement();
  parentObj.appendChild(EventCalendar.getHTMLElement());
}

String.prototype.checkFor2Char = function()
{
  if(this.length < 2)
  {
    return "0" + this;
  }
  else
  {
    return this;
  }
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();


/*
function cleanUpPops()
{
  var contentDiv = document.getElementById('content');
  if(contentDiv)
  {
    contentDiv.onmouseover = function()
    {
      if(detailsPopUp)
      {
        if(appended)
        {
          detailsPopUp.parentNode.removeChild(detailsPopUp);
          appended = false;
        }
      }
    }
  }
}
*/

