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(){
     $("#nav li:last").parent().parent().addClass('last');
                     $("#nav li:last").addClass('last');
         $("#searchbar fieldset a#search_go").text("Search");
         $("#searchbar fieldset").prepend($("#searchbar fieldset a#search_go"));
         $('#tellwindow, #response').hide();
         var subn = $('ul#subnavigation li.current').find("ul");
         
         if(subn.length == 0){ $('#subnav ul li.current').css({'margin-bottom': '10px'})};
         var page = location.href;
                      $('.tell').toggle(function() {
                            $('#tellwindow').fadeIn("slow"); 
                             
                               $('#header #message').append(page);
                            /*$('#tellwindow').load("/_inc/tellform.htm",
                               // function(){
                                  //  var page = location.href;
                                   // $('#message').append(page);
                                   // $("#response").hide();
                                   //  $('#tellwindow p.close').click(function(){ 
                                     //   $('#tellwindow').fadeOut(); 
                                   // });
                                //});*/                
                      },function(){
                          $('#tellwindow, #response').fadeOut();
                          $('#response').html("");
      
                          $('#tellafriend #toname, #tellafriend #toemail').val("");
                        });
                        
                        $('#tellwindow p.close').click(function(){ 
                                       $('#tellwindow').fadeOut(); 
                             });
                        
                        $('#tellafriend').submit(function() {
                                var inputs = [];
                                $('#tellafriend input').each(function(){
                                   inputs.push(this.name + '=' + escape(this.value));
                                });
                                 $('#tellafriend textarea').each(function(){
                                   inputs.push(this.name + '=' + escape(this.value));
                                });
                                jQuery.ajax({
                                    data: inputs.join('&'),
                                    url: this.action,
                                    timeout: 3000,
                                    error: function(){
                                      $('#respone').fadeIn().html("Err: search failed");   
                                    },
                                    success: function(r){
                                        $("#response").fadeIn().html(r);
                                    }
                                });

                        return false;
                  });
                  
                  $('select option').each(function(){
                    		  optval = $(this).val();
                    		  if (optval == "site-admins") {
                    			 $(this).remove();
                    		  }
                    	   });
                  
                  $(document).ajaxStop(function(){
                    	   $('select option').each(function(){
                    		  optval = $(this).val();
                    		  if (optval == "site-admins") {
                    			 $(this).remove();
                    		  }
                    	   });
                    	});
                    	
                    	$("#nav #nonnav li#nonnav_guests-and-newcomers ul,#nav #nonnav li#nonnav_leaders--pastors ul").hide();
                    	 $('.powered a').attr({target:"_blank"});
                    
     });
