/*
 * Ext JS Library 2.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

var win;
Ext.onReady(function(){
    
    //var button = Ext.get('show-btn');

//    button.on('click', function(){
//        // create the window on the first click and reuse on subsequent clicks
//        if(!win){
//            win = new Ext.Window({
//                applyTo     : 'hello-win',
//                layout      : 'fit',
//                width       : 500,
//                height      : 300,
//                closeAction :'hide',
//                plain       : true,
//                items       : new Ext.TabPanel({
//                    applyTo        : 'hello-tabs',
//                    autoTabs       : true,
//                    activeTab      : 0,
//                    deferredRender : false,
//                    border         : false
//                }),

//                buttons: [{
//                    text     : 'Submit',
//                    disabled : true
//                },{
//                    text     : 'Close',
//                    handler  : function(){
//                        win.hide();
//                    }
//                }]
//            });
//        }
//        var img = document.getElementById("img");
//        img.innerHTML = "<img src=\"http://chautuan/DundasChartSamplesVS2005/Demos/StockMarketDemo/charts/indices.aspx?s=INDEX1&w=360&h=240&f=0day\" />";
//        win.show(button);
//    });
});

function OpenGraph(symbol, exchange)
{
    ClearCurrentData();
    GetQuotesHistory(symbol);
    currentGraphSymbol = symbol;
    if(!win){
            win = new Ext.Window({
                applyTo     : 'hello-win',
                layout      : 'fit',
                width       : 500,
                height      : 500,
                closeAction :'hide',
                plain       : true,
                items:new Ext.Panel({applyTo        : 'hello-tabs',deferredRender : false,border         : false}),
//                items       : new Ext.TabPanel({
//                    applyTo        : 'hello-tabs',
//                    autoTabs       : true,
//                    activeTab      : 0,
//                    deferredRender : false,
//                    border         : false
//                }),

                buttons: [{
                    id     : 'showAllHistory',
                    text     : 'Show all',
                    handler  : function(){
                        ShowAllHistory();
                    }
                    },{
                    text     : 'Close',
                    handler  : function(){
                        win.hide();
                    }
                }]
            });
        }
        var showAllHistory = document.getElementById("showAllHistory");
    
        showAllHistory.disabled = true;
    
        var img = document.getElementById("img");
        img.innerHTML = "<img width='320' height='200' src=\"indices.aspx?s=" + symbol + "&w=320&h=200&f=0day&ex=" + exchange + "\" />";
        //var divScroll = document.getElementById("divScroll" + symbol);
        //win.top = 1000;
        //alert(document.body.scrollTop);
        //win.setPosition(300,document.body.scrollTop);
        //alert(1000);
        //var tr = document.getElementById("tr" + symbol);
        var currentY = GetPageTop();
        //var position = win.getPosition(false);
        win.setPosition(win.x, currentY + 100);
        win.show();
}

