//<!--

/*
 * splash.js
 * 
 * initializes the site, if JS is enabled
 * 
 */


Event.observe(window, 'load', initialize);


/*
 * initialize()
 * 
 * page setup stuffs
 * 
 * 
 */

function initialize()
{
    Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 6;
    Prototype.Browser.IE7 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 7;
    Prototype.Browser.IE8 = Prototype.Browser.IE && !Prototype.Browser.IE6 && !Prototype.Browser.IE7;
    
    if (window.location.pathname.indexOf('categories.html') != -1) // user has landed on the categories page
    {
        showCategories();
    }
    else if (window.location.pathname.indexOf('/portfolio/') != -1) // user has landed a portfolio page
    {
        initScrollPane();
    }
    else // we're on the index
    {
        executeIndex();
    }
}



function executeIndex()
{
    
    $('navigation').hide();
    
    // IE + Png24 + opacity....no good
    if (Prototype.Browser.IE6 || Prototype.Browser.IE6 || Prototype.Browser.IE8)
    {
        return;
    }
    
    var logo            = $('logoHref');
    var content         = $('content');
    var bg              = logo.down('img', 0);
    var heidi_text      = logo.down('img', 1);
    var photo_text      = logo.down('img', 2);
    var in_duration     = .6;
    var out_duration    = .2;
    
    heidi_text.setStyle({ opacity: .6 });
    photo_text.setStyle({ opacity: .6 });
    
    // handle mouseover - extra span because of bubbling issues
    logo.down('span').observe
    (
        'mouseover', 
        function()
        {
            new Effect.Parallel(
                [
                    new Effect.Morph(bg, { style: 'opacity: .6;', sync: true }),
                    new Effect.Morph(heidi_text, { style: 'opacity: 1;', sync: true }),
                    new Effect.Morph(photo_text, { style: 'opacity: 1;', sync: true })
                ],
                {
                    duration: in_duration, 
                    queue: window.heidi.queue_logo_in
                }
            );
            
        }
    );
    
    // handle mouseout - extra span because of bubbling issues
    logo.down('span').observe
    (
        'mouseout', 
        function()
        {
            new Effect.Parallel(
                [
                    new Effect.Morph(bg, { style: 'opacity: 1;', sync: true }),
                    new Effect.Morph(heidi_text, { style: 'opacity: .6;', sync: true }),
                    new Effect.Morph(photo_text, { style: 'opacity: .6;', sync: true })
                ],
                {
                    duration: out_duration, 
                    queue: window.heidi.queue_logo_out
                }
            );
        }
    );
}



function hideLogo()
{
    new Effect.Fade
    (
        'logo', 
        { 
            duration: 5,
            queue: window.heidi.queue_general
        }
    );
}


/*
 * showCategories()
 * 
 * shows #content, then each of the category divs
 * initializes the subCategories divs (menus) wihin each category div
 * 
 */

function showCategories()
{
    $('content').setStyle({ background: 'transparent' });
    
    $('categories').childElements().invoke('hide');
    
    Effect.multiple
    (
        $('categories').childElements(),
        Effect.Appear, 
        { 
            duration: 1,
            afterFinish: function()
            {
                new Effect.Appear
                (
                    'navigation', 
                    { 
                        duration: .5 
                    }
                );
            }
        }
    );
}


function showContent(callback)
{
    new Effect.Appear
    (
        'content',
        {
            duration: .5,
            queue: window.heidi.queue_general,
            afterFinish: function()
            {
                if (callback != 'undefined')
                {
                    callback.apply();
                }
            }
        }
    );
}

function hideContent()
{
    new Effect.Fade
    (
        'content',
        {
            duration: .5,
            queue: window.heidi.queue_general
        }
    );
}


function initScrollPane()
{
    window.heidi.ScrollPane = new ScrollPane
    (
        'scrollPane', 
        { 
            duration: 0.4, 
            start_item_opacity: 0.3,
            scale_amount: 0.8,
            item_is_clickable: false,
            navigation:
            {
                next:                   'scrollPaneNext',
                previous:               'scrollPanePrevious',
                disabled_css_classname: 'scrollPaneDisabled'
            }
        }
    );   
}




// -->

