// http://paulirish.com/2009/markup-based-unobtrusive-comprehensive-dom-ready-execution/

SCS = {
    common : {
        init : function() {
            $("a[href*='http://']:not([href*='" + location.hostname.replace("www", "") + "'])").each(function() {
                $(this).attr('target', '_blank');
            });
        }
    },
    home : {
        init : function() {
            $('#large-slideshow').cycle({ timeout: 6000, speed: 2000 });
            $('#small-slideshow .items').cycle({
                fx: 'scrollHorz',
                next: '.controls .next',
                prev: '.controls .prev',
                pager: '#pager',
                pagerAnchorBuilder: function(index, slide) {
                    return '#pager li:eq(' + index + ') a';
                }
            });
        }
    },
    fundinganddevelopment : {
        ourfundraisers : function() {
            $('h3').nextUntil('h3').each(function() {
                if ($(this).is('p')) {
                    $(this).hide();
                }
            });
            $('h3').click(function() {
                $(this).nextUntil('h3').slideToggle();
            });
            $('h3:eq(0)').nextUntil('h3').show();
        }
    }
}

UTIL = {
    fire : function(func, funcname, args){
       var namespace = SCS;  // indicate your obj literal namespace here
       funcname = (funcname === undefined) ? 'init' : funcname;
       if (func !== '' && namespace[func] && typeof namespace[func][funcname] == 'function'){
           namespace[func][funcname](args);
       } 
    }, 
    loadEvents : function() {
         var bodyId = document.body.id.replace(/-/g, '');
         // hit up common first.
         UTIL.fire('common');
         // do all the classes too.
         $.each(document.body.className.split(/\s+/),function(i,classnm){
             classnm = classnm.replace(/-/g, '');
             UTIL.fire(classnm);
             UTIL.fire(classnm,bodyId);
         });
         UTIL.fire('common','finalize');
     } 
}; 


UTIL.loadEvents();

