$(document).ready(function() {
   $('ul#sidelinks li li.current, body#info ul#sidelinks li li li').parents('li.current').addClass('parent');
   $('body.info #sidenav #sidelinks li#sidelinks_info.current ul li:first').addClass('first');
   $('input.clearClick').val('Search Apostles');
   $('input.clearClick').focus(function() {
      $(this).val('');
   });
   $('a#search_go').click(function() {
      $('#searchForm').submit();
   });
});


sfHover = function() {
   var sfEls = document.getElementById("nav").getElementsByTagName("LI");
   for (var i=0; i<sfEls.length; i++) {
      sfEls[i].onmouseover=function() {
         this.className+=" sfhover";
         if (document.getElementById("sermonLists")) {
            document.getElementById("sermonLists").style.visibility="hidden";
         }
      }
      sfEls[i].onmouseout=function() {
         this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
         if (document.getElementById("sermonLists")) {
            document.getElementById("sermonLists").style.visibility="visible";
         }
      }
   }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function gotoSermon() {
  var x=document.getElementById("sermonLists")
  if(x.selectedIndex==0) y=1;
  if(x.selectedIndex==1) window.location="/sermons-by-series/";
  if(x.selectedIndex==2) window.location="/sermons-by-category/";
  if(x.selectedIndex==3) window.location="/sermons-by-month/";
  if(x.selectedIndex==4) window.location="/sermons-by-speaker/";
}

function getWindowHeight() {
            var windowHeight=0;
            if (typeof(window.innerHeight)=='number') {
            windowHeight=window.innerHeight;
            }
            else {
            if (document.documentElement&&
            document.documentElement.clientHeight) {
            windowHeight=
            document.documentElement.clientHeight;
            }
            else {
            if (document.body&&document.body.clientHeight) {
            windowHeight=document.body.clientHeight;
            }
            }
            }
            return windowHeight;
            }


      
         function setFooter() {
            if (document.getElementById) {
            var windowHeight = getWindowHeight();
            if (windowHeight>0) {
            var contentHeight=document.getElementById('container').offsetHeight;
            var footerElement= document.getElementById('footer');
            var footerHeight=footerElement.offsetHeight;
            if (windowHeight-(contentHeight+footerHeight)>=0) {
            footerElement.style.position='relative';
            footerElement.style.top=(windowHeight-
            (contentHeight+footerHeight))+'px';
            }
            else {
            footerElement.style.position='static';
            }
            }
            }
            }
            
            window.onload = function() {
              setFooter();
            }
            window.onresize = function() {
              setFooter();
            }