Jelo.load('all', function() {
    function onfocus() {
        if (this.value == this.defaultText) {
            this.value = '';
            Jelo.CSS.removeClass(this, 'default');
        }
    }
    function onblur() {
        if (!this.value.length || this.value == this.defaultText) {
            Jelo.CSS.addClass(this, 'default');
            this.value = this.defaultText;
        }
    }
    function defaultText(input, text) {
        if (input && text) {
            Jelo.CSS.addClass(input, 'default');
            Jelo.on(input, 'focus', onfocus);
            Jelo.on(input, 'blur', onblur);
            input.value = input.defaultText = text;
        }
    }
    Jelo.Anim.setDefaultDuration(0.33);
    Jelo.on($('#login .submit'), 'click', function() {
        Jelo.Dom.ancestor('form', this).submit();
    });
    Jelo.on($$('.targeted a'), 'click', function(e) {
        var id = this.href.replace(/.*#/, '#'), target = $(id);
        if (target) {
            e.preventDefault();
            Jelo.CSS.addClass($$('#content > div:not(#splash)'), 'hidden');
            Jelo.CSS.removeClass(target, 'hidden');
        }
    });
    Jelo.each($$('.partner-logos'), function(group) {
        var logos = $$('li', group), index = 0;
        Jelo.css(logos.slice(3), ['height', 'opacity'], ['0px', '0']);
        setTimeout(function() {
            if (Jelo.css(Jelo.Dom.ancestor('div', group), 'display') == 'none') {
                setTimeout(arguments.callee, 5000);
                return;
            }
            Jelo.each(logos.slice(index, index + 3), function(item, index) {
                setTimeout(function() {
                    Jelo.Anim.ate({
                        me: item,
                        css: 'top: -30px; height: 0px; opacity: 0',
                        duration: 1,
                        easing: 'strongout'
                    });
                }, index * 100);
            });
            index = index + 3;
            if (index >= logos.length) {
                index = 0;
            }
            Jelo.each(logos.slice(index, index + 3), function(item, index) {
                setTimeout(function() {
                    Jelo.Anim.ate({
                        me: item,
                        css: 'top: 0px; height: 130px; opacity: 1',
                        duration: 1,
                        easing: 'strongboth'
                    });
                }, index * 100);
            });
            setTimeout(arguments.callee, 5000);
        }, 5000);
    });
    Jelo.on($$('.player img'), 'click', function() {
        Jelo.css(this, 'display', 'none');
        Jelo.css($('object', this.parentNode), 'display', 'block');
    });
    if ($('.dse')) {
    	var dseLink = $$('.dse a')[1];
    	dseLink.origColor = Jelo.css(dseLink, 'color');
    	Jelo.on(dseLink, 'mouseover', function() {
    		Jelo.css(this, 'color', '#fff');
    	});
    	Jelo.on(dseLink, 'mouseout', function() {
    		Jelo.css(this, 'color', dseLink.origColor);
    	});
    }
    if ($('#newsletter')) {
        defaultText($('#newsletter [name=fname]'), 'First Name');
        defaultText($('#newsletter [name=lname]'), 'Last Name');
        defaultText($('#newsletter [name=email]'), 'Email Address');
    }
});
function onVideoComplete() {
    setTimeout(function() {
    	var players = $$('.player object');
        if (Jelo.css(players[0], 'display') == 'block') {
            Jelo.css(players[0], 'display', 'none');
            Jelo.css(players[1], 'display', 'block');
        } else {
            Jelo.css(players[1], 'display', 'none');
            Jelo.css($('.player img'), 'display', 'block');
        }
    }, 250);
}

