/*
 * Richmond Pharmacology - Trials4us - Phase I recruitment
 *
 * Script: registration.js
 * Flash replacement for registration process page
 *
 * By Andy Smith, Preview Graphics
 * www.preview.co.uk
 */

function initPage(e)
{
    if (!(document.getElementById && document.createElement)) return;
    
    if (!flash_available) return;

    var procList = document.getElementById('process');
    if (!procList) return;
    
    var procContainer = ElementBuilder.build(
        ['div', ElementBuilder.Attr('id', 'process-container'),
            ['div', ElementBuilder.Attr('id', 'process-animation')],
            ['a', ElementBuilder.Attr('id', 'process-show-animation',
                                      'href', 'javascript:;'),
                  ElementBuilder.Event('click', showAnimationHandler(true)),
                'Show with animation'],
            ['a', ElementBuilder.Attr('id', 'process-hide-animation',
                                      'href', 'javascript:;'),
                  ElementBuilder.Event('click', showAnimationHandler(false)),
                'Show without animation']
          ]);
    
    procList.parentNode.insertBefore(procContainer, procList);
    procContainer.insertBefore(procList, procContainer.firstChild);

    setClass(procContainer, 'animation-visible', true);
    setClass(procContainer, 'animation-hidden', false);

    var animation = document.getElementById('process-animation');
    flashReplace(animation, 'process.swf', 591, 130, null);
}

/* Event handlers for links to show and hide the animation. The function
   below takes a boolean parameter indicating whether tha animation should
   be shown (true) or hidden (false), and returns an event handler to do
   this. */

function showAnimationHandler(show)
{
    return function (e) {
        var link = getEventLinkTarget(e);
        var container = link.parentNode;
        setClass(container, 'animation-visible', show);
        setClass(container, 'animation-hidden', !show);
    }
}

addEvent(window, "load", initPage);



