
Sermons.domain = "http://suncath.org/";
Sermons.months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
Sermons.audiogifURL = "images/audio.gif";
Sermons.videogifURL = "images/video.gif";

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);
  window.open(url, "videoWindow", "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=640,height=480");
 }

function Sermons(argDate, service, title, preacher)
 {
  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.service = service;
  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() +
    "_" + this.service;

  this.text = true;
  this.audio = true;
  this.video = true;
  this.videoHD = false;
  this.videoHQ = false;
 }

 Sermons.prototype.out = function(id) {
   var sTime = "";
   var outLine = '<strong>' + this.title + '</strong><br />Preached by ' + 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() + '&svc=' + this.service +
      '">' + 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="sermon_video.htm?fil=' + encodeURIComponent(this.fileName) + '&ttl=' + encodeURIComponent(this.title) + '&sit=' + Sermons.domain + '&hq=' + (this.videoHQ ? 1 : 0) + '&hd=' + (this.videoHD ? 1 : 0) + '">' +
      '<img border="0" src="' + Sermons.videogifURL + '" width="16" height="18" alt="Video" /> Broadband video</a>';
//     outLine += '<br /><a title="' + this.title + '" href="' + Sermons.domain + 'sermon_video.htm?fil=' + encodeURIComponent(this.fileName) + '&ttl=' + encodeURIComponent(this.title) + '&sit=' + Sermons.domain + '&hq=' + (this.videoHQ ? 1 : 0) + '">' +
//      '<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";
}
