//=========================================================================================
// Function Names		Description
//=========================================================================================
// StartDateAndMarquee()	Start both the system date func and the scrolling marquee
// DisplaySystemDate()		Start the system date function
// StartMarqueeScroll()		Start the scrolling margquee
// BookMarkSite()               Provide link to bookmark the website
//=========================================================================================

function StartDateAndMarquee()
{
  try
  {
    idDate.innerHTML=CalcTodaysDate();
    startmarquee();
  }
 
  catch(exception){};
}

//=========================================================================================
// Used to display the system date in the "top_cb.html" file
// DisplaySystemDate()		Start the system date function
//=========================================================================================
function DisplaySystemDate()
{
  try
  {
    idDate.innerHTML=CalcTodaysDate();
  }
 
  catch(exception){};
}


function StartMarqueeScroll()
{
  try
  {
    startmarquee();
  }
 
  catch(exception){};
}

//=========================================================================================
// Support Functions		Description
//=========================================================================================
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.getYear();
      return (strDate);
   }
   
   catch(exception){};
}

// ========================================================================================
function GetDayText(nDay)
{
   var aDaysText = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

   return aDaysText[nDay];
}

// ========================================================================================
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];
}

// ========================================================================================
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;												
}

// ========================================================================================
function startTimer()
{
   stopTimer();
   timerID = setTimeout("hidemenus()", 100);
}

// ========================================================================================
function stopTimer()
{
   clearTimeout(timerID);
}

// ========================================================================================
function MM_callJS(jsStr)
{
   //v2.0
   return eval(jsStr);
}

// ========================================================================================
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);
     }
   }
}

// ========================================================================================
function startmarquee() 
{
  isntimer=window.setTimeout("isnscroll(100)",500);
}

// ========================================================================================
function BookMarkSite(title, url)
{
  if (document.all)
    window.external.AddFavorite(url, title);
  else if (window.sidebar)
    window.sidebar.addPanel(title, url, "");
}
