var $whichPlaylist; var $whichPage; var $whichSpeaker; var $filledObj; $(document).ready(function(){ // SAME AS on window.load(), acts as an event listener /** ----------------------------------------- /** Correct hover appearance on "Connect" Menu /** -----------------------------------------*/ $("ul#connect-menu").hover( function () { if ($("#globalnav-connect").hasClass("active")==false){$("#globalnav-connect").addClass("hovering");} }, function () {$("#globalnav-connect").removeClass("hovering");}); /** ----------------------------------------- /** Popup bubble on event hover /** -----------------------------------------*/ $("#home-coming-events-list li").hover( function () { $(".comingUpBubble").hide().stop(); $(this).children(".comingUpBubble").show().animate({ opacity: 1.0, marginTop: -20 }, 250); }, function () { $(this).children(".comingUpBubble").animate({ marginTop: -12, opacity: 0 }, 250,"swing").fadeOut("fast"); } ); /** ----------------------------------------- /** I'm New Tab on the Home Page /** -----------------------------------------*/ // Check cookies to see last tab clicked if ($.cookie('visitcard')=='new'){activateImNew($("#im-new-tab"));} else if ($.cookie('visitcard')=='returning'){activateImReturning($("#im-returning-tab"));} else {activateImNew($("#im-new-tab"));} // Change tab and set cookies $("#im-new-tab").click(function () { if ($(this).hasClass("active")==false){ activateImNew($(this)); return false; } }); $("#im-returning-tab").click(function () { if ($(this).hasClass("active")==false){ activateImReturning($(this)); return false; } }); /** ----------------------------------------- /** Open sermon popup player on home page /** ----------------------------------------- $("#last-sunday-listen").click(function () { window.open ("/audio/popup-player", "SermonAudio","toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=540,height=55") }); */ /** ----------------------------------------- /** Functions for pull out drawers at top of every page /** -----------------------------------------*/ $("#contact-tab").click(function () { $("#drawer-contact").slideToggle("slow"); $("#drawer-sitemap").slideUp("slow"); }); $("#wrapper-head, #wrapper-billboard, #wrapper-content, #wrapper-footer").click(function () { $("#drawer-contact").slideUp("slow"); $("#drawer-sitemap").slideUp("slow"); }); $("#sitemap-tab").click(function () { $("#drawer-sitemap").slideToggle("slow"); $("#drawer-contact").slideUp("slow"); }); // CONTACT FORM FUNCTIONS // add contacts from list $(".contact-list li").click(function () { var $theContact = $(this).children("span.contact-name").html(); $("#contact-form-addressee").focus(); if ($("#contact-form-addressee").val()=="Select one or more names from the left."||$("#contact-form-addressee").val()=='') { $("#contact-form-addressee").val($theContact); $("#contact-form-addressee").removeClass("empty"); } else { $("#contact-form-addressee").val($("#contact-form-addressee").val()+', '+$theContact); } }); // on input change $("#contact-form-name,#contact-form-email,#contact-form-addressee,#contact-form-message").blur(function () { if ($(this).val()=='') {$(this).val($(this).attr("title")).addClass('empty');} }); // on input focus clear placeholder text $("#contact-form-name,#contact-form-email,#contact-form-addressee,#contact-form-message").focus(function () { if ($(this).val()=='Your Name') {$(this).val('').removeClass('empty');} else if ($(this).val()=='Your Email') {$(this).val('').removeClass('empty');} else if ($(this).val()=='Select one or more names from the left.') {$(this).val('').removeClass('empty');} else if ($(this).val()=='Message') {$(this).val('').removeClass('empty');} }); // Send main contact form over ajax $("form#contact-drawer-form").submit(function() { if ($('#contact-form-name').val() == 'Your Name' || $('#contact-form-email').val() == 'Your Email' || $('#contact-form-addressee').val() == 'Select one or more names from the left.' || $('#contact-form-message').val() == 'Message') { alert('All fields are required. Please complete the form before submitting.'); return false; } else { $.post("/includes/contact-submit", { addressee: $("#contact-form-addressee").val(), name: $("#contact-form-name").val(), email: $("#contact-form-email").val(), message: $("#contact-form-message").val() }, function(data) {$('#contact-form').html(data);}); return false; } }); /** ----------------------------------------- /** Audio Archive functions /** -----------------------------------------*/ // Change playlists $("#audio-playlists li a").click(function () { var $playlistID = $(this).attr("id"); $whichPage = 0; if ($playlistID == "all-audio"){ $whichPlaylist = "all"; } else if ($playlistID == "sunday-audio"){ $whichPlaylist = "sunday-morning-audio"; } else if ($playlistID == "high-life-audio"){ $whichPlaylist = "sr-high-life-audio"; } else if ($playlistID == "jr-high-life-audio"){ $whichPlaylist = "jr-high-life-audio"; } else if ($playlistID == "misc-class-audio"){ $whichPlaylist = "misc-class-audio"; } var $ajaxURL = "/audio/ajax-audio/P"+$whichPage+"/"+$whichPlaylist; $("#audio-table").fadeOut("fast").load($ajaxURL); $("#audio-playlists li").removeClass("active-playlist"); $(this).parent().addClass("active-playlist"); $("#audio-loading").fadeIn(200); $("#audio-table").ajaxComplete(function () { $(".page-controls a").unbind("click").bind("click", function(){newAjaxPagination($(this),$whichPage,$whichPlaylist,$whichSpeaker);}); $("#audio-loading").hide(); $("#audio-table").fadeIn(300); }); }); // Send small groups info request over ajax $("form#form-smallgroups").submit(function() { if ($('#name').val() == 'name' || $('#email').val() == 'email' || $('#name').val() == '') { alert('All fields are required. Please complete the form before submitting.'); return false; } else { $.post("/smallgroups/submit", { name: $("#name").val(), email: $("#email").val(), phone: $("#phone").val(), type: $("#type").val(), comments: $("#comments").val() }, function(data) {$('#form-smallgroups').html(data);}); return false; } }); }); //*********************************************************************************************************** //******************************** end document.ready *******************************************************/ /** ----------------------------------------- /** Ajax Pagination of Audio Archive /** -----------------------------------------*/ function ajaxPagination(ajaxURL,thePageNumber,theButton){ if ($(theButton).html().substring(0,2)=="Ne"){thePageNumber=thePageNumber+20;} else { thePageNumber=thePageNumber-20; if (thePageNumber<0) thePageNumber=0; } ajaxURL = ajaxURL + '/P' + thePageNumber; $whichPage = thePageNumber; $("#audio-table").fadeOut("fast").load(ajaxURL); $("#audio-loading").fadeIn(200); $("#audio-table").ajaxComplete(function () { $(".page-controls a").unbind("click").bind("click", function(){ajaxPagination("/audio/ajax-audio"+$whichPage+"/"+$whichPlaylist,$whichPage,$(this));}); $("#audio-loading").hide(); $("#audio-table").fadeIn(300); }); } /** ----------------------------------------- /** Ajax Pagination of Audio Archive /** -----------------------------------------*/ function newAjaxPagination(theButton,thePageNumber,thePlaylist,theSpeaker){ if ($(theButton).html().substring(0,2)=="Ne"){thePageNumber=thePageNumber+20;} else { thePageNumber=thePageNumber-20; if (thePageNumber<0) thePageNumber=0; } if (thePlaylist==''){ thePlaylist = 'all'; } if (theSpeaker==undefined){theSpeaker='';} var $ajaxURL = '/audio/ajax-audio/P' + thePageNumber + '/' + thePlaylist + '/' + theSpeaker; $whichPage = thePageNumber; $whichPlaylist = thePlaylist; $whichSpeaker = theSpeaker $("#audio-table").fadeOut("fast").load($ajaxURL); $("#audio-loading").fadeIn(200); $("#audio-table").ajaxComplete(function () { $(".page-controls a").unbind("click").bind("click", function(){newAjaxPagination($(this),$whichPage,$whichPlaylist,$whichSpeaker);}); $("#audio-loading").hide(); $("#audio-table").fadeIn(300); }); } /** ----------------------------------------- /** Home Page Announcement Slides /** -----------------------------------------*/ function slideSwitch() { var $active = $('#featured-image div.active'); if ( $active.length == 0 ) $active = $('#featured-image div:last'); var $next = $active.next().length ? $active.next() : $('#featured-image div:first'); $active.addClass('last-active'); $next.css({opacity: 0.0}) .addClass('active') .animate({opacity: 1.0}, 3000, function() { $active.removeClass('active last-active'); }); } // Delay for home page slideshow $(function() { setInterval( "slideSwitch()", 9000 ); }); /** ----------------------------------------- /** I'm New home page tabs /** -----------------------------------------*/ function activateImNew(theTab){ $(theTab).addClass("active"); $("#im-returning").children().fadeOut(); $("#im-returning").hide(); $("#im-new").children().hide(); $("#im-new").show(); $("#im-new").children().fadeIn(); $("#im-returning-tab").removeClass("active"); $.cookie('visitcard', 'new', { expires: 1000, path: '/', domain: 'southwood.org' }); } function activateImReturning(theTab){ $(theTab).addClass("active"); $("#im-new").children().fadeOut(); $("#im-new").hide(); $("#im-returning").children().hide(); $("#im-returning").show(); $("#im-returning").children().fadeIn(); $("#im-new-tab").removeClass("active"); $.cookie('visitcard', 'returning', { expires: 1000, path: '/', domain: 'southwood.org' }); } /** ----------------------------------------- /** Hide serving modal /** -----------------------------------------*/ function hideModals(){ $("#op-card").css("display","none"); $("#overlay").css("display","none"); } function serveIncrement(){ var filled = $filledObj.html(); filled = ++filled; if (filled==$filledObj.siblings(".op-avail").html() ){$filledObj.parents(".serving-op").addClass("filled");} $filledObj.html(filled); setTimeout("$filledObj.css('background','none')",2000); } /** ----------------------------------------- /** Open popup sermon player in audio archive /** -----------------------------------------*/ function openSermonPlayer(url){ window.open(url, "sermonplayer","location=0,status=0,scrollbars=0,width=340,height=115"); }