
// Submenu
//
//

var blindsubnav = false;

if (blindsubnav) {
    Event.observe(window, 'load', function() {
        charthovertimer = window.setTimeout(function() {
            Effect.toggle('subnavbar', 'blind', { duration: 1.0 });
        }, 1000);
    });
}

//

//**********************************************************************************************************************************************
// Stock hover chart popup code
//

//addOnLoad(function() { setupSymbolLinkEvents(); });
var charthovertimer = 0;
var callstatus = 0;
var mouseout = false;

Event.observe(window, 'load', function() {
    //add onmouseover event to all of the symbol links in the page
    var linkcount = 0;
    var sp = $$('.symbollink').each(function(e) {
        var symbol = $(e).readAttribute('ticker');
        $(e).writeAttribute('id', 'symbollink_' + linkcount);
        //var url = $(e).readAttribute('href');
        //var symbol = url.match(/=[^&;]+[&;]?/i);
        if (symbol != '' && symbol != null) {
            e.onmouseover = function() { showChartHover(e, symbol); };
        }
        linkcount++;
    });
});


function showChartHover(e, symbol) {

    //position the new div under the link
    $('hoverchartcontainer').update("<img src='/images/elements/ajax_flower.gif' alt='working...'>");   
    $('hoverchartcontainer').addClassName('hoveron');            
    $('hoverchartcontainer').show();
    var location = $('hoverchartcontainer').clonePosition(e, {setLeft: true, setTop: true, setWidth: false, setHeight: false, offsetLeft: -20, offsetTop: -20}); 
    //the date will help with caching of the chart data
    var currentTime = new Date()
    new Ajax.Updater('hoverchartcontainer', '/ajax/charthover.aspx?symbol=' + symbol + '&date=' + currentTime, {method: 'get', onFailure: processFailure});


    if (mouseout) {
        //if the mouse stays within the parent DIV don't start the timer to hide the hover chart
        $("hoverchartcontainer").observe("mouseout", function(e) {
            window.status = Event.pointerX(e) + " " + Event.pointerY(e);
            if (Position.within($("hoverchartcontainer"), Event.pointerX(e) - 20, Event.pointerY(e) + 20)) {
                charthovertimer = window.clearTimeout(charthovertimer);
                return;
            }
            else {
                hideChartHover(2000);
            }
        });
    }
   // Event.observe('divcloser', 'click', function(e) { alert('clicked me!') });

}

function processFailure(transport) {
    $('hoverchartcontainer').update("<img src='/images/elements/ajax_flower.gif' alt='working...'>");
    $('hoverchartcontainer').hide(); 
}

function hideChartHover(delay) {

    charthovertimer = window.setTimeout(function() {

    $('hoverchartcontainer').update("<img src='/images/elements/ajax_flower.gif' alt='working...'>");  
    $('hoverchartcontainer').hide();       
    }, delay);                
}

// Stock hover chart popup code
//
//**********************************************************************************************************************************************
