//=========================================================================================
// Function Names		Description
//=========================================================================================
// DisplaySystemDate()		    Start the system date function
// BookMarkSite()             Provide link to bookmark the website
// CalcTodaysDate()           Calculates Today's date
// GetDayText(nDay)           Returns the spelled out weekday for the value passed
// GetMonthText(nMonth)       Returns the spelled out month for the value passed
// FormatDate(strFromDate)    Formats the date from mm/dd/yyyy to yyyy/mm/dd
// startTimer()               Starts a timer
// stopTimer()                Stops a timer
// MM_callJS(jsStr)           Calls a Javascript with parameter
// isnscroll(hype)            Sets the text for the scrolling marquee

// startmarquee()             sub-function for starting the marquee display
// StartMarqueeScroll()       Starts the marquee display at bottom of the browser
// StartDateAndMarquee()      Calculates the Date and starts the marquee display at bottom of the browser
//=========================================================================================

// ==================
// Updated 11/30/2011
// ==================

//=========================================================================================
// Used to display the system date in the "top_cb.html" file
// DisplaySystemDate()		Start the system date function
//=========================================================================================
function DisplaySystemDate()
{
  try
  {
    document.getElementById("idDate").innerHTML=CalcTodaysDate();
  }
 
  catch(exception){};
};

//=========================================================================================
// Used to "bookmark" the webite URL
// Called in the "left_cb.html"
//=========================================================================================
function BookMarkSite(title, url)
{
  if (document.all)
    window.external.AddFavorite(url, title);
  else if (window.sidebar)
    window.sidebar.addPanel(title, url, "");
};

//=========================================================================================
// Calculates "Today's" date
//=========================================================================================
function CalcTodaysDate()
{
   try
   {
      var strDate;
      var Today = new Date();	
      var suffix = "th";
      switch (Today.getDate())
      {
	       case 1:
	       case 21:
	       case 31: 
	         suffix = "st"; 
	         break;
	       case 2:
	       case 22:
	         suffix = "nd"; 		
	         break;
	       case 3:
	       case 23:
	         suffix = "rd"; 
	         break;
      };

      // strDate = GetDayText(Today.getDay()) + ", " + GetMonthText(Today.getMonth()) + "  ";
      strDate = GetMonthText(Today.getMonth()) + " ";
      strDate += Today.getDate() + suffix + ", " + Today.getFullYear();
      return (strDate);
   }
   
   catch(exception){};
};

//=========================================================================================
// Returns the spelled out weekday for the value passed
//=========================================================================================
function GetDayText(nDay)
{
   var aDaysText = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

   return aDaysText[nDay];
};

//=========================================================================================
// Returns the spelled out month for the value passed
//=========================================================================================
function GetMonthText(nMonth)
{
  var aMonthsText = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
  //var aMonthsText = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
 
  return aMonthsText[nMonth]; 	 
};

//=========================================================================================
// Formats the date from mm/dd/yyyy to yyyy/mm/dd
//=========================================================================================
function FormatDate(strFromDate)
{
   var newDate;

   // format date from mm/dd/yyyy to yyyymmdd (yr month day)

   newDate = strFromDate.substring(6,10) + strFromDate.substring(0,2) + strFromDate.substring(3,5);
		
   return newDate;												
};	

//=========================================================================================
// Starts a timer
//=========================================================================================
function startTimer()
{
   stopTimer();
   timerID = setTimeout("hidemenus()", 100);
};

//=========================================================================================
// Stops a timer
//=========================================================================================
function stopTimer()
{
   clearTimeout(timerID);
};

//=========================================================================================
// Calls a Javascript with parameter
//=========================================================================================
function MM_callJS(jsStr)
{
   //v2.0
   return eval(jsStr);
};

//=========================================================================================
// Sets the text for the scrolling marquee
//=========================================================================================
function isnscroll(hype)
{
   var shameless = 100;
   var prtspc = " ";
   var col = 1;

   // You could use array here, but this is easy way to load messages
   // Unlike HTML documents, multiple adjoining spaces are preserved 
   var promotional="Thank you for visiting our web site!!!                         " + "Don't be left in the dark about your new home, call Illumination Home Inspection today!                           ";

   if (hype>shameless)
   {
     hype--;
     var cmd="isnscroll(" + hype + ")";
     isntimer=window.setTimeout(cmd,shameless);
   }
   else if (hype<=shameless && hype>0)
   {
     for (col=0;col<hype;col++)
     {
        prtspc+=" ";
     }
     prtspc+=promotional;
     hype--;
     var cmd="isnscroll(" + hype + ")";
     window.status=prtspc;
     isntimer=window.setTimeout(cmd,shameless);
   }
   else if (hype<=0)
   {
     if (-hype<promotional.length)
     {
       prtspc+=promotional.substring(-hype,promotional.length);
       hype--;
       var cmd="isnscroll(" + hype + ")";
       window.status=prtspc;
       isntimer=window.setTimeout(cmd,100);
     }
     else
     {
       window.status=" ";
       isntimer=window.setTimeout("isnscroll(100)",75);
     }
   }
};

//=========================================================================================
// sub-function for starting the marquee display
//=========================================================================================
function startmarquee() 
{
  isntimer=window.setTimeout("isnscroll(100)",500);
};

//=========================================================================================
// Starts the marquee display at bottom of the browser
//=========================================================================================
function StartMarqueeScroll()
{
  try
  {
    startmarquee();
  }
 
  catch(exception){};
};

//=========================================================================================
// Calculates the Date and starts the marquee display at bottom of the browser
//=========================================================================================
function StartDateAndMarquee()
{
  try
  {
    document.getElementById("idDate").innerHTML=CalcTodaysDate();
    // idDate.innerHTML=CalcTodaysDate();
    startmarquee();
  }
 
  catch(exception){};
};


