
Sermons.OpenFlashWindow = function(sFil, sTtl, sUrl, sSit)
 {
  sSit = sSit  ||  Sermons.domain;
  sUrl = sUrl  ||  Sermons.domain + "sermonVideo.htm";
  var url = sUrl + "?fil=" + encodeURIComponent(sFil) + "&sit=" + encodeURIComponent(sSit) + "&ttl=" + encodeURIComponent(sTtl);
//  FP_openNewWindow('660', '500', false, false, false, false, false, true, 'videoWindow', /*href*/url);
  window.open(url, "videoWindow", "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=640,height=480");
 }

function Sermons(argDate, title, preacher)
 {
  /// <summary>Constructor for the Sermons object.</summary>
  /// <param name="argDate" type="Date">The date (and optionally) time of the sermon; may be an array of Date objects.</param>
  /// <param name="title" type="string">The sermon title.</param>
  /// <param name="preacher" type="string">The name of the preacher.</param>
  /// <returns type="Object">Returns an object representing the defined sermon.</returns>
  
  this.oDates = [];

  if (typeof(argDate) == "string"  ||  argDate instanceof Date)
   {
    this.oDate = new Date(argDate);
    this.oDates[0] = this.oDate;
   }
  else  // Assume array of date strings or Date objects
   {
    for (var i = 0; i < argDate.length; i++)
     {
      this.oDates[i] = new Date(argDate[i]); 
     }
   this.oDate = this.oDates[0];
   }

  this.title = title;
  this.preacher = preacher;
  
  this.fileName = this.oDate.getFullYear() + ((this.oDate.getMonth() < 9) ? '0' : '') + (this.oDate.getMonth()+1) + ((this.oDate.getDate() < 10) ? '0' : '') + this.oDate.getDate();
  if (this.oDate.getHours() > 0)
    this.fileName += '_' + ((this.oDate.getHours() < 10) ? '0' : '') + this.oDate.getHours() + this.oDate.getMinutes();

  this.text = true;
  this.audio = true;
  this.video = true;
 }
Sermons.domain = "http://suncath.org/";
Sermons.months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
Sermons.audiogifURL = "http://www.sunshinecathedral.org/sermons/audio.gif";
Sermons.videogifURL = "http://www.sunshinecathedral.org/sermons/video.gif";

Sermons.prototype.out = function(id)
 {
  var sTime = "";
  if (this.oDate.getHours() > 0)
   {
    sTime = this.oDate.getHours() + ':' + this.oDate.getMinutes();
    for (var i = 1; i < this.oDates.length; i++)
     {
      sTime += ' and ' + this.oDates[i].getHours() + ':' + this.oDates[i].getMinutes();
     }
    sTime = ', ' + sTime  + ' <span style="font-variant: small-caps;">am</span>';
   }
  var outLine = '<strong>' + this.title + '</strong><br />Preached by the ' + this.preacher +
      '<br />' + Sermons.months[this.oDate.getMonth()] + ' ' + this.oDate.getDate() + ', ' + this.oDate.getFullYear() +
      sTime;

  if (this.text)
   {
    outLine = '<a title="' + this.title + '" href="' + Sermons.domain + 'sermons.aspx?dat='
      + (this.oDate.getMonth()+1) + '/' + this.oDate.getDate() + '/' + this.oDate.getFullYear() + '+' + this.oDate.getHours() + ':' + this.oDate.getMinutes() +
      '">' + outLine + '</a>';
   }
  if (this.audio)
   {
    outLine += '<br /><a title="' + this.title + '" href="' + Sermons.domain + 'sermons/' + this.fileName +
      '.mp3"><img border="0" src="' + Sermons.audiogifURL + '" width="18" height="13" alt="Audio" />Audio (.mp3)</a>';
   }
  if (this.video)
   {
    outLine += '<br /><a title="' + this.title + '" href="javascript:Sermons.OpenFlashWindow(\'' + this.fileName + '\',\'' + this.title + '\');">' +
      '<img border="0" src="' + Sermons.videogifURL + '" width="16" height="18" alt="Video" />Broadband video</a>';
   }

  if (!id) 
    return '<p>' + outLine + '</p>';
  else
   {
    if (typeof(id) == "string") id = document.getElementById(id);
    id.innerHTML = outLine;
    return true;
   }
 }

  function emailPage()
   {
    var sURL = document.URL;
    sURL = 'email_page.aspx?nam=' + sURL;
    window.location = sURL;
    return true;
   }

  function printName()
   {
    var sURL = document.URL;
    sURL = sURL.substr(0, sURL.length - 4) + 'p.htm';  // By convention, filename is same as this plus 'p'
    return sURL;
  }

  function PDFName()
   {
    var sURL = document.URL;
    sURL = sURL.substr(0, sURL.length - 3) + 'pdf';
    return sURL;
   }

  function MP3Name()
   {
    var sURL = document.URL;
    sURL = sURL.substr(0, sURL.length - 3) + 'mp3';
    return sURL;
   }

  function WMVName()
   {
    var sURL = document.URL;
    sURL = sURL.substr(0, sURL.length - 3) + 'wmv';
    return sURL;
   }
  function flashName()
   {
    var sURL = document.URL;
    sURL = sURL.substr(0, sURL.length - 4) + 'f.htm';  // By convention, filename is same as this plus 'f'
    return sURL;
   }
  function openWin(sExt)
   {
    var sURL = document.URL;
    sURL = sURL.substr(0, sURL.length - 3) + sExt;
    readingWin = window.open(sURL);
    readingWin.focus();
   }


function FP_openNewWindow(w,h,nav,loc,sts,menu,scroll,resize,name,url) {//v1.0
 var windowProperties=''; if(nav==false) windowProperties+='toolbar=no,'; else
  windowProperties+='toolbar=yes,'; if(loc==false) windowProperties+='location=no,'; 
 else windowProperties+='location=yes,'; if(sts==false) windowProperties+='status=no,';
 else windowProperties+='status=yes,'; if(menu==false) windowProperties+='menubar=no,';
 else windowProperties+='menubar=yes,'; if(scroll==false) windowProperties+='scrollbars=no,';
 else windowProperties+='scrollbars=yes,'; if(resize==false) windowProperties+='resizable=no,';
 else windowProperties+='resizable=yes,'; if(w!="") windowProperties+='width='+w+',';
 if(h!="") windowProperties+='height='+h; if(windowProperties!="") { 
  if( windowProperties.charAt(windowProperties.length-1)==',') 
   windowProperties=windowProperties.substring(0,windowProperties.length-1); } 
 window.open(url,name,windowProperties);
}

function FP_setStatusBarText(txt) {//v1.0
 window.status=txt;
 return true;
}
function TestBwsr()
{
  var bwsr = navigator.userAgent.toLowerCase();
  if (bwsr.indexOf("firefox") != -1)
    document.body.style.fontSize = "medium";
}
