
    document.observe('dom:loaded', function(){
        
        var input = $$('#title-bar input[name="email"]')[0];
        if (input) {
            input.addClassName('empty');
            input.value = 'Sign up for the newsletter';
            input.observe('focus', function(){
                if (this.value == 'Sign up for the newsletter') {
                    input.removeClassName('empty');
                    input.value = '';
                }
            });
        }
        input.observe('blur', function(){
            if (this.value == '') {
                input.addClassName('empty');
                input.value = 'Sign up for the newsletter';
            }
        });
    
    });
    
    // Enquiries form
    document.observe('dom:loaded', function(){
        var form = $('enquiries_form');
        if (form) {
            $('nature_of_enquiry').observe('change', function(){
                var courses_div = this.up().next();
                
                if (this.value == 'Booking enquiry') {
                    courses_div.show();
                } else {
                    courses_div.hide();
                }
            });
        }
    });
    
    
/*--------------------------------------------------------------------------------
    Dynamic header
--------------------------------------------------------------------------------*/

    document.observe('dom:loaded', function(){
        var container = $$('div.dynamicheader')[0];
        if (container){
            
            container.left = 0;
            
            // Pause animation on mouseover, prevents a bug where the slider gets stuck halfway
            container.paused = false;
            container.observe('mouseover', function(){ container.paused = true; });
            container.observe('mouseout', function(){ container.paused = false; });
            
            // Assign each item with its contained link
        /*
            container.select('.item a').each(function(a){
                var href = a.getAttribute('href');
                a.up('.item').observe('click', function(){
                    window.location = href;
                });
            });
        */    
            container.select('ul li').each(function(li, key){
                
                li.observe('click', function(event){
                    event.stop();
                    if (container.locked) return false;
                    container.locked = true;
                    move_dynamic_header(container, li, key);
                }.bindAsEventListener());
            });
            
            setInterval(function(){
                if (container.paused) return false;
                
                container.select('li').each(function(li, key){
                    if (li.hasClassName('active')){
                        var next_li = li.next();
                        if (next_li){
                            move_dynamic_header(container, next_li, key+1); 
                        } else {
                            next_li = li.adjacent('li').first();
                            move_dynamic_header(container, next_li, 0); 
                        }
                        throw $break;
                    }
                });
            }, 10000);
        }
    });
    
    function move_dynamic_header(container, li, key)
    {
        var items = container.select('div.item');
        var item_width = items[0].getWidth();
        var inner = container.down('div.inner');
        
        var distance = key * item_width;
        var x = container.left - distance;
        
        // Store the current position
        container.left = (key * item_width);
        
        new Effect.Move(inner, {
            x: x,
            y: 0,
            mode: 'relative',
            duration: 0.5,
            afterFinish: function(){
                li.adjacent('li.active').invoke('removeClassName', 'active');
                li.addClassName('active');
                container.locked = false;
            }
        });
    }

