/*
 * Ext JS Library 2.0.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.onReady(function(){

    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

    var myData = [
        ['<a href="http://spreadsheets.google.com/ccc?key=t_3ZsuA_jFgThjkWa4h9AgQ&output=html&gid=6" target="_blank" style="color:#15428b;">Quinn, A.</a>',6,13,6,5,1,1.50,1.83],
        ['<a href="http://spreadsheets.google.com/ccc?key=t_3ZsuA_jFgThjkWa4h9AgQ&output=html&gid=9" target="_blank" style="color:#15428b;">Kumpf, J.</a>',3,3,0,1,0,0.00,.333],
		['<a href="http://spreadsheets.google.com/ccc?key=t_3ZsuA_jFgThjkWa4h9AgQ&output=html&gid=11" target="_blank" style="color:#15428b;">Whitmer, D.</a>',3,1,2,2,0,.000,1.33],
		['<a href="http://spreadsheets.google.com/ccc?key=t_3ZsuA_jFgThjkWa4h9AgQ&output=html&gid=1" target="_blank" style="color:#15428b;">Garner, C.</a>',6,4,12,23,24,36.000,5.83],
		['<a href="http://spreadsheets.google.com/ccc?key=t_3ZsuA_jFgThjkWa4h9AgQ&output=html&gid=2" target="_blank" style="color:#15428b;">Bozack, T.</a>',1,2,6,4,7,63.000,10.00],
		['<a href="http://spreadsheets.google.com/ccc?key=t_3ZsuA_jFgThjkWa4h9AgQ&output=html&gid=4" target="_blank" style="color:#15428b;">Golden, K.</a>',7,10,33,22,44,56.57,7.86],
		['<a href="http://spreadsheets.google.com/ccc?key=t_3ZsuA_jFgThjkWa4h9AgQ&output=html&gid=3" target="_blank" style="color:#15428b;">Swolfs, J.</a>',4,7,7,4,6,13.500,2.75],
		['<a href="http://spreadsheets.google.com/ccc?key=t_3ZsuA_jFgThjkWa4h9AgQ&output=html&gid=10" target="_blank" style="color:#15428b;">Lenci, D.</a>',2,1,4,2,2,9.00,3.00],
		['<a href="http://spreadsheets.google.com/ccc?key=t_3ZsuA_jFgThjkWa4h9AgQ&output=html&gid=8" target="_blank" style="color:#15428b;">Kertesz, D.</a>',3,2,13,12,17,51.000,8.33],
		['<a href="http://spreadsheets.google.com/ccc?key=t_3ZsuA_jFgThjkWa4h9AgQ&output=html&gid=5" target="_blank" style="color:#15428b;">Tomson, D.</a>',2,3,2,6,6,27.000,4.00],
		['<a href="http://spreadsheets.google.com/ccc?key=t_3ZsuA_jFgThjkWa4h9AgQ&output=html&gid=0" target="_blank" style="color:#15428b;">Clancy, J.</a>',3,2,4,7,11,33.000,3.67]
    ];

    // example of custom renderer function
    function change(val){
        if(val > 0){
            return '<span style="color:black;">' + val + '</span>';
        }else if(val < 0){
            return '<span style="color:black;">' + val + '</span>';
        }
        return val;
    }

    // example of custom renderer function
    function pctChange(val){
        if(val > 0){
            return '<span style="color:black;">' + val + '%</span>';
        }else if(val < 0){
            return '<span style="color:black;">' + val + '%</span>';
        }
        return val;
    }

    // create the data store
    var store = new Ext.data.SimpleStore({
        fields: [
           {name: 'player'},
           {name: 'inn', type: 'float'},
           {name: 'k', type: 'float'},
           {name: 'bbi', type: 'float'},
           {name: 'ha', type: 'float'},
		   {name: 'r', type: 'float'},
		   {name: 'era', type: 'float'},
		   {name: 'whip', type: 'float'}
        ]
    });
    store.loadData(myData);

    // create the Grid
    var grid = new Ext.grid.GridPanel({
        store: store,
        columns: [
            {id:'player',header: "Player", width: 80, sortable: true, dataIndex: 'player'},
            {header: "INN", width: 40, sortable: true, dataIndex: 'inn'},
            {header: "K", width: 40, sortable: true, dataIndex: 'k'},
            {header: "BBI", width: 40, sortable: true, dataIndex: 'bbi'},
            {header: "HA", width: 40, sortable: true, dataIndex: 'ha'},
			{header: "R", width: 40, sortable: true, dataIndex: 'r'},
            {header: "ERA", width: 40, sortable: true, dataIndex: 'era'},
			{header: "WHIP", width: 40, sortable: true, dataIndex: 'whip'}
        ],
        stripeRows: true,
        //autoExpandColumn: 'player',
        height:315,
        width:370,
        title:'2008 Pitchers'
    });

    grid.render('pitchers');

    grid.getSelectionModel().selectFirstRow();
});
