<!--
//
// Script    :   fes_rsl_functions.js
// Author    :   C.E. Berry
// Version   :   5.00.010
// Notes     :   Javascript function library for additional functions for Refreshment Systems
//               website
//
//               All material contained within is the intellectual property of SysExcel Ltd.
//               and as such may not be reproduced or modified in any way shape or form without
//               the prior consent of SysExcel Ltd.
//
// Amendment Log
//
//      Version      Date           Author              Notes
//      -------      ----           ------              -----
//
//      5.00.010     04/09/2010     C.E. Berry          Creation
//
//=================================================================================================

var pub_mouseout_timer;

function fncRslToggleMenu(prm_name,prm_action)
{
    if (pub_selected_section !== prm_name) fncFesMoChangeState(prm_action, 'rsl_button_' + prm_name, 1);

    return;

    loc_button = document.getElementById('rslbutton' + prm_name);
    loc_menu   = document.getElementById('rslsubmenu' + prm_name);
    loc_pane   = document.getElementById('rslmainpane');

    clearTimeout(pub_fade_timer);

    if (prm_action)
    {
//        for (var loc_item = document.body.firstChild; loc_item; loc_item = loc_item.nextSibling)
        for (var loc_item = document.getElementById('rslsubmenus').firstChild; loc_item; loc_item = loc_item.nextSibling)
        {
            if (loc_item.nodeName === "DIV" &&
                loc_item.id !== 'rslsubmenu' + prm_name)
            {
                loc_item.fes_opacity = 0;
                loc_item.style.opacity = 0;
                loc_item.style.visibility = "hidden";
                loc_item.style.display = "none";
            }
        }

        if (loc_menu)
        {
            loc_menu.style.top  = fncFesGetAbsolutePosition(loc_button).top - 0 + "px" ;

            loc_menu.style.visibility = "visible";
            loc_menu.style.display = "block";
            pub_fade_timer = setTimeout('fncRslFadeMenu("' + prm_name + '",1)',1);
        }
    }
    else if (loc_menu)
    {
        pub_fade_timer = setTimeout('fncRslFadeMenu("' + prm_name + '",0)',1000);
    }

    return;

    loc_menu.style.top = Math.max(Math.min(fncFesGetWindowHeight() + fncFesGetVerticalScroll() - loc_menu.clientHeight,
                                          fncFesGetAbsolutePosition(prm_element).top - (loc_menu.clientHeight / 3)),
                                 fncFesGetVerticalScroll()) + "px";

    if (fncFesGetAbsolutePosition(prm_element).left > (fncFesGetWindowWidth() / 2)) // postion on the side with most room
    {
        loc_menu.style.left = fncFesGetAbsolutePosition(prm_element).left - loc_menu.clientWidth - 5 + "px" ;
    }
    else
    {
        loc_menu.style.left = fncFesGetAbsolutePosition(prm_element).left + prm_element.clientWidth + 5 + "px" ;
    }

}

function fncRslToggleChoice(prm_name)
{
    loc_cross = document.getElementById('vxp_' + prm_name + '_cross');
    loc_cgi   = document.getElementById('fes_vxp_' + prm_name);

debugDump(loc_cross);
debugDump(loc_cgi);

    if (loc_cgi.value)
    {
        loc_cgi.value = '';
        loc_cross.style.visibility = 'hidden';
    }
    else
    {
        loc_cgi.value = '1';
        loc_cross.style.visibility = 'visible';
    }

}

var pub_fade_timer;

function fncRslFadeMenu(prm_name,prm_action)
{
    loc_menu = document.getElementById('rslsubmenu' + prm_name);

//debugDump(loc_menu.fes_opacity,"OPAC");

    if (prm_action)
    {
        if (loc_menu.fes_opacity < 100)
        {
            loc_menu.fes_opacity += 10;
            loc_menu.style.opacity = Math.min(loc_menu.fes_opacity,100)/100;
            clearTimeout(pub_fade_timer);
            pub_fade_timer = setTimeout('fncRslFadeMenu("' + prm_name + '",' + prm_action + ')',20);
        }
    }
    else
    {
        if (loc_menu.fes_opacity > 0)
        {
            loc_menu.fes_opacity -= 10;
            loc_menu.style.opacity = Math.min(loc_menu.fes_opacity,100)/100;
            clearTimeout(pub_fade_timer);
            pub_fade_timer = setTimeout('fncRslFadeMenu("' + prm_name + '",' + prm_action + ')',20);
        }
        else
        {
            loc_menu.fes_opacity = 0;
            loc_menu.style.opacity = 0;
            loc_menu.style.visibility = "hidden";
            loc_menu.style.display = "none";
        }

    }
}

var pub_scroll_timer;
var pub_position = 0;

function fncPageScrollDown()
{
    pub_position -= 10;
    loc_text_object = document.getElementById("contenttext");
    loc_area_object = document.getElementById("contentarea");

    if (pub_position < 0 - loc_text_object.offsetHeight + loc_area_object.clientHeight)
    {
        clearInterval(pub_scroll_timer); // stop moving

        pub_position = 0 - loc_text_object.offsetHeight + loc_area_object.clientHeight;

    }

    loc_text_object.style.top = pub_position + "px";

}

function fncPageScrollUp()
{

    pub_position += 10;
    loc_text_object = document.getElementById("contenttext");

    if (pub_position > 0)
    {
        clearInterval(pub_scroll_timer); // stop moving

        pub_position = 0;

    }

    loc_text_object.style.top = pub_position + "px";

}

function fncPageScrollDownContainer()
{
    pub_scroll_timer = setInterval("fncPageScrollDown()", 5);

}

function fncPageScrollUpContainer()
{
    pub_scroll_timer = setInterval("fncPageScrollUp()", 5);

}

function fncFesRslScroller()
{
    loc_text_object = document.getElementById("contenttext");
    loc_area_object = document.getElementById("contentarea");

    if (loc_text_object && loc_text_object.clientHeight > loc_area_object.clientHeight)
    {
        document.getElementById("scrollup").style.visibility = "visible";
        document.getElementById("scrolldown").style.visibility = "visible";
    }

}

//-->
