<!--

//
// Script    :   fes_fantasygalaxy_functions.js
// Author    :   C.E. Berry
// Version   :   5.00.012
// Notes     :   Javascript function library for addional functions for Fantasy Galaxy websites.
//
//               All material contained within is the intellectual property of SysExcel Ltd.
//               and as such may not be reproduced in any way shape or form without the prior
//               consent of SysExcel Ltd.
//
// Amendment Log
//
//      Version     Date           Author              Notes
//      -------     ----           ------              -----
//
//      5.00.012    15/12/2012     C.E. Berry          Added ticker_panel parameter to
//                                                     fncFesFgMainSitesAlignPopups function
//
//                  03/07/2011     C.E. Berry          Added slideshow functions
//
//                  10/12/2010     C.E. Berry          Creation
//
//=================================================================================================

function fncFesFgMainSitesAlignPopups (prm_ticker_panel)
//
// Function to position main sites' popup menus in correct place on page
//
// Arguments
//
//  prm_ticker_panel            Boolean to indicate whetgher ticker panel displayed or not, valid
//                              values are 'true' - panel displayed, 'false' - panel not displayed
//
{

    document.getElementById('popupoursites').style.left = fncFesGetAbsolutePosition(document.getElementById('toptable')).left + 203 + 'px';

    if (prm_ticker_panel)
    {
        document.getElementById('popupoursites').style.top =  '-247px';

    }

    else
    {
        document.getElementById('popupoursites').style.top =  '-296px';

    }

    document.getElementById('popupoursites').style.clip = 'rect(0px, 0px, 0px, 0px)';
    document.getElementById('popupoursites').style.visibility = 'visible';

    if (document.getElementById('popupmore'))
    {
        document.getElementById('popupmore').style.left = fncFesGetAbsolutePosition(document.getElementById('toptable')).left + 322 + 'px';

        if (prm_ticker_panel)
        {
            document.getElementById('popupmore').style.top =  '-147px';

        }

        else
        {
            document.getElementById('popupmore').style.top =  '-196px';

        }

        document.getElementById('popupmore').style.clip = 'rect(0px, 0px, 0px, 0px)';
        document.getElementById('popupmore').style.visibility = 'visible';

    }

}

//=================================================================================================
//
// Splash page slideshow functions
//
//=================================================================================================

function fncFesFgMainSitesInitSlideshow(prm_slideshow)
//
// Function to initialise splash page slideshow
//
// Arguments
//
//  prm_slideshow           Name of slideshow
//
{

    pub_slideshow = document.getElementById(prm_slideshow);

    pub_slideshow.fes_main_images = new Array();
    pub_slideshow.fes_blur_images = new Array();
    pub_slideshow.fes_overlays = new Array();

// Build arrays of images and overlays

    var loc_counter1 = 0;
    var loc_counter2 = 0;
    var loc_counter3 = 0;
    var loc_div_counter = 0;

    for (var loc_item = pub_slideshow.firstChild; loc_item; loc_item = loc_item.nextSibling)
    {
        if (loc_item.nodeName === "DIV")
        {
            if (loc_div_counter%3 == 0)
            {
                loc_item.style.zIndex = 10;
                pub_slideshow.fes_blur_images[loc_counter1++] = loc_item;

            }

            else if (loc_div_counter%3 == 1)
            {
                loc_item.style.zIndex = 11;
                pub_slideshow.fes_main_images[loc_counter2++] = loc_item;

            }

            else
            {
                loc_item.style.zIndex = 12;
                pub_slideshow.fes_overlays[loc_counter3++] = loc_item;

            }

            loc_div_counter++;

        }

    }

// Initialise variables

    pub_slideshow.fes_opacity_images = 0;
    pub_slideshow.fes_previous_images_index = pub_slideshow.fes_main_images.length - 1;
    pub_slideshow.fes_current_images_index = 0;
    pub_slideshow.fes_opacity_overlays = 0;
    pub_slideshow.fes_previous_overlays_index = pub_slideshow.fes_overlays.length - 2;
    pub_slideshow.fes_current_overlays_index = pub_slideshow.fes_overlays.length - 1;

// Call function to reveal first overlay

    pub_fade_timer2  = setTimeout('fncFesFgMainSitesShowSlideshowOverlay(1)',1500);

    return;
}

//=================================================================================================

function fncFesFgMainSitesShowSlideshowOverlay(prm_change_slide)
//
// Function to initialise splash page slideshow
//
// Arguments
//
//  prm_change_slide        Glag to indicate whteher to change slide or not
//
{

// If change slide parameter set the find next slide

    if (prm_change_slide)
    {
        var loc_next_index = pub_slideshow.fes_current_overlays_index + 1;

        if (loc_next_index >= pub_slideshow.fes_overlays.length) loc_next_index = 0;

        pub_slideshow.fes_overlays[pub_slideshow.fes_previous_overlays_index].style.display = 'none';
        pub_slideshow.fes_overlays[pub_slideshow.fes_previous_overlays_index].style.zIndex = 10;

        pub_slideshow.fes_overlays[pub_slideshow.fes_current_overlays_index].style.display = 'none';
        pub_slideshow.fes_overlays[pub_slideshow.fes_current_overlays_index].style.zIndex = 20;

        pub_slideshow.fes_overlays[loc_next_index].style.opacity = 0;
        pub_slideshow.fes_overlays[loc_next_index].style.zIndex = 30;
        pub_slideshow.fes_overlays[loc_next_index].style.display = 'block';

        pub_slideshow.fes_previous_overlays_index = pub_slideshow.fes_current_overlays_index;
        pub_slideshow.fes_current_overlays_index = loc_next_index;

        pub_slideshow.fes_opacity_overlays = 0;

    }

// Set opacity

    if (pub_slideshow.fes_overlays[pub_slideshow.fes_current_overlays_index].filters)
    {
        pub_slideshow.fes_overlays[pub_slideshow.fes_current_overlays_index].style.filter = 'alpha(opacity=' + pub_slideshow.fes_opacity_overlays + ')';

    }

    pub_slideshow.fes_overlays[pub_slideshow.fes_current_overlays_index].style.opacity = pub_slideshow.fes_opacity_overlays/100;

// If target opacity not reached set timer to recall function to carry on incrementing opacity

    if (pub_slideshow.fes_opacity_overlays < 80)
    {
        pub_slideshow.fes_opacity_overlays += 2
        clearTimeout(pub_fade_timer2);
        pub_fade_timer2  = setTimeout('fncFesFgMainSitesShowSlideshowOverlay()',3);

    }

// If target opacity reached set timer to call image swap function

    else
    {
        clearTimeout(pub_fade_timer2);
        pub_fade_timer  = setTimeout('fncFesFgMainSitesShowSlideshowImage(1)',1500);

    }

}

//=================================================================================================

function fncFesFgMainSitesShowSlideshowImage(prm_change_slide)
//
// Function to initialise splash page slideshow
//
// Arguments
//
//  prm_change_slide        Glag to indicate whteher to change slide or not
//
{

// If change slide parameter set the find next slide

    if (prm_change_slide)
    {
        var loc_next_index = pub_slideshow.fes_current_images_index + 1;

        if (loc_next_index >= pub_slideshow.fes_main_images.length) loc_next_index = 0;
        if (loc_next_index < 0) loc_next_index = pub_slideshow.fes_main_images.length - 1;

        pub_slideshow.fes_main_images[pub_slideshow.fes_previous_images_index].style.display = 'none';
        pub_slideshow.fes_main_images[pub_slideshow.fes_previous_images_index].style.zIndex = 10;

        pub_slideshow.fes_main_images[pub_slideshow.fes_current_images_index].style.zIndex = 20;

        pub_slideshow.fes_blur_images[pub_slideshow.fes_previous_images_index].style.display = 'none';
        pub_slideshow.fes_blur_images[pub_slideshow.fes_previous_images_index].style.zIndex = 10;

        pub_slideshow.fes_blur_images[pub_slideshow.fes_current_images_index].style.zIndex = 20;

// Make sure overlay is behind next slide

        pub_slideshow.fes_overlays[pub_slideshow.fes_current_overlays_index].style.zIndex = 20;

        pub_slideshow.fes_main_images[loc_next_index].style.opacity = 0;
        pub_slideshow.fes_main_images[loc_next_index].style.zIndex = 30;
        pub_slideshow.fes_main_images[loc_next_index].style.display = 'block';

        pub_slideshow.fes_blur_images[loc_next_index].style.opacity = 0;
        pub_slideshow.fes_blur_images[loc_next_index].style.zIndex = 30;
        pub_slideshow.fes_blur_images[loc_next_index].style.display = 'block';

        pub_slideshow.fes_previous_images_index = pub_slideshow.fes_current_images_index;
        pub_slideshow.fes_current_images_index = loc_next_index;

        pub_slideshow.fes_opacity_images = 0;
    }

// Set opacity

    if (pub_slideshow.fes_main_images[pub_slideshow.fes_current_images_index].filters)
    {
        pub_slideshow.fes_main_images[pub_slideshow.fes_current_images_index].style.filter = 'alpha(opacity=' + pub_slideshow.fes_opacity_images + ')';
        pub_slideshow.fes_blur_images[pub_slideshow.fes_current_images_index].style.filter = 'alpha(opacity=' + pub_slideshow.fes_opacity_images + ')';

    }

    pub_slideshow.fes_main_images[pub_slideshow.fes_current_images_index].style.opacity = pub_slideshow.fes_opacity_images/100;
    pub_slideshow.fes_blur_images[pub_slideshow.fes_current_images_index].style.opacity = pub_slideshow.fes_opacity_images/100;

// If target opacity not reached set timer to recall function to carry on incrementing opacity

    if (pub_slideshow.fes_opacity_images < 100)
    {
        pub_slideshow.fes_opacity_images += 2
        clearTimeout(pub_fade_timer);
        pub_fade_timer  = setTimeout('fncFesFgMainSitesShowSlideshowImage()',3);

    }

// If target opacity reached set timer to call overlay swap function

    else
    {
        clearTimeout(pub_fade_timer);
        pub_fade_timer2  = setTimeout('fncFesFgMainSitesShowSlideshowOverlay(1)',1500);

    }

}

//-->
