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);


$(document).ready(function() {
  // color box launch
  $('#login .thickbox, #comments .thickbox').colorbox({iframe:true,width:400, height:250});
  $('#footer .thickbox').colorbox();
  $('#content .slideshow').colorbox({
  	slideshow:true,
  	photo:true,
  	preloading:true,
  	slideshowSpeed:5000,
  	slideshowAuto:false
  	});
  $('.rsvp .thickbox').colorbox({iframe:true,width:450, height:570});
  $('#options .thickbox,.section .thickbox').colorbox({iframe:true,width:500, height:570});  
  

  // Tabs script
  $('#tabs div').hide(); // Hide all divs
  $('#tabs div:first').show(); // Show the first div
  $('#tabs ul.nav li:first').addClass('active'); // Set the class of the first link to active
  $('#tabs ul.nav li a').click(function(){ //When any link is clicked
    $('#tabs ul.nav li').removeClass('active'); // Remove active class from all links
    $(this).parent().addClass('active'); //Set clicked link class to active
    var currentTab = $(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
    $('#tabs div').hide(); // Hide all divs
    $(currentTab).show(); // Show div with id equal to variable currentTab
    return false;
  });

  // Input Clear (search and newsletter signups)
  $('input.clearClick').removeClass('clearClick').addClass('clickClear');
  
  $('form#newsletter input[type=text]').each(function(){
    var helpText = $(this).prev('label').text();
    var helpText = helpText.replace(':','');
    $(this).prev('label').remove();
    $(this).addClass('clickClear').attr('value',helpText);
    //console.log(helpText);
  });
  
  $('input.clickClear').focus(function() {
      startText = $(this).val();
      $(this).val('').addClass('focus');
   });

   $('input.clickClear').blur(function() {
      blurText = $(this).val();
      if (blurText == '') {
         $(this).val(startText).removeClass('focus');
      };
   });



});

