document.observe('dom:loaded', function(){
        if($('loi_form')){
            var antiBot = new Element('input', {type:'hidden', name:'amibotornot', value:'nope'});
            $('loi_form').insert(antiBot);
            observe_character_counts();
        }
        if($("global-nav")){
            fix_clickability();
            observe_clickability();
        }
        if($('carousel-wrapper')){
            var firstElement = $$('#carousel-content .slide')[0];
            var htmlCopy = firstElement.cloneNode(true);
            Element.insert('carousel-content', htmlCopy);
            new Carousel('carousel-wrapper', $$('#carousel-content .slide'), '', {auto: true, circular: true, frequency: 6});
        }
        });

function observe_character_counts(){
    $('loi_form').select('.size-limit').each(function(el){
        var charSize;
        Element.classNames(el).each(function(cName){
            if(cName.match(/characters/)){
               charSize = cName.split('-')[1];
            }
        });
        var elToObserve = el.id.replace('_indicator','');
        $(elToObserve).observe('keyup',function(){
            var fieldCount = $F(elToObserve).length;
            var charLeft = charSize - fieldCount;
            el.select('span').each(function(countSpan){
                if(fieldCount <= charSize){
                    countSpan.removeClassName('error');
                    countSpan.update(' :: ' + charLeft + ' remaining');
                } else {
                    countSpan.addClassName('error');
                    countSpan.update(' :: ' + Math.abs(charLeft) + ' over!');
                }
            });
        });

    });
}

function fix_clickability(){
   $('global-nav').select('a[href="/our-partners/"]').each(function(el){
           el.addClassName('no_click');
           });
}

function observe_clickability(){
    $('global-nav').select("a.no_click").each(
            function (el){el.observe('click', function(e){Event.stop(e);})}
    );
}

