Ext.onReady(function(){
            
	Ext.BLANK_IMAGE_URL = '/ext/resources/images/default/s.gif';
	Ext.QuickTips.init();
	
	// example of custom renderer function
    function greenred(val){
        if(val > 0){
            return '<span style="color:green;">' + val + '</span>';
        }else if(val < 0){
            return '<span style="color:red;">' + val + '</span>';
        }
        return val;
    }

	function renderIndicator(value, p, record){
        // return String.format('<a href="#" onClick="win=window.open(\'/Pages/Help.aspx?id={1}\', \'popup\', \'width=680, height=420, scrollbars=yes, resizable=yes\');win.focus();">{0}</a>', value, record.data.intid);
        return String.format('<a hre="/Pages/Calculators.aspx?id={1}" onClick="document.opener.location(this.href);return false;">{0}</a>', value, record.data.intrecordid);
    }
    
    var proxy1 = new Ext.data.ScriptTagProxy({
	    url: 'http://data.investinginbondseurope.org/iibeu-site/actGetConsoleAsJSON.cfm',
	    method: 'GET'
    });
    
    var countryArray = new Ext.form.ComboBox({
	    store: new Ext.data.SimpleStore({
            fields: ['display', 'value'],
            data : [["", ""],
                ["Austria", "AT"],
                ["Belgium", "BE"],
                ["Bulgaria", "BG"],
                ["Cyprus", "CY"],
                ["Czech Republic", "CZ"],
                ["Denmark", "DK"],
                ["Estonia", "EE"],
                ["Finland", "FI"],
                ["France", "FR"],
                ["Germany", "DE"],
                ["Greece", "GR"],
                ["Hungary", "HU"],
                ["Ireland", "IE"],
                ["Italy", "IT"],
                ["Latvia", "LV"],
                ["Lithuania", "LT"],
                ["Luxembourg", "LU"],
                ["Malta", "MT"],
                ["Netherlands", "NL"],
                ["Poland", "PL"],
                ["Portugal", "PT"],
                ["Romania", "RO"],
                ["Slovakia", "SK"],
                ["Slovenia", "SI"],
                ["Spain", "ES"],
                ["Sweden", "SP"],
                ["United Kingdom", "GB"]]
            }),
        forceSelection: false,
	    triggerAction: 'all',
	    emptyText: Ext.csllbl.lbl_SelectCounty,
	    selectOnFocus:true,
	    id: 'strCountry',
	    hiddenName: 'strCountry_hidden',
	    width:120,
	    valueField: 'value',
	    displayField:'display',
	    mode: 'local',
	    value: qsParm["strCountry"]
	});
	

    // reader1 and homecolumns1
    switch (qsParm["strView"]) {
        case "markit-corporate":
        default:
            
            var reader1 = new Ext.data.JsonReader({
                root: 'data',
                totalProperty: 'recordcount',
                idProperty: 'intrecordid',
                fields: ['aggregateaswapsprd', 'aggregateprice', 'aggregateyield', 'ccy', 'coupon', 'datedatagenerated', 'impliedrating', 'instrument', 'intrecordid', 'isin', 'issuedate', 'issuername', 'maturity', 'type', 'thisdatetime', 'snprating', 'moodysrating']
            });
        	
	        var homecolumns1 = new Ext.grid.ColumnModel([{
		        header: Ext.csllbl.lbl_issuername,
		        dataIndex: 'issuername',
		        width: 240,
		        tooltip: Ext.csllbl.txt_issuername
	        },{
		        header: Ext.csllbl.lbl_instrument,
		        dataIndex: 'instrument',
		        width: 300,
		        tooltip: Ext.csllbl.txt_instrument
	        },{
		        header: Ext.csllbl.lbl_isin,
		        dataIndex: 'isin',
		        width: 100,
		        tooltip: Ext.csllbl.txt_isin
	        },{
		        header: Ext.csllbl.lbl_ccy,
		        dataIndex: 'ccy',
		        width: 60,
		        tooltip: Ext.csllbl.txt_ccy
	        },{
		        header: Ext.csllbl.lbl_coupon,
		        dataIndex: 'coupon',
		        width: 60,
		        tooltip: Ext.csllbl.txt_coupon
	        },{
		        header: Ext.csllbl.lbl_issuedate,
		        dataIndex: 'issuedate',
		        width: 75,
		        tooltip: Ext.csllbl.txt_issuedate
	        },{
		        header: Ext.csllbl.lbl_maturity,
		        dataIndex: 'maturity',
		        width: 75,
		        tooltip: Ext.csllbl.txt_maturity
			},{
		        header: Ext.csllbl.lbl_impliedrating,
		        dataIndex: 'impliedrating',
		        width: 75,
		        tooltop: Ext.csllbl.txt_impliedrating
	        },{
		        header: Ext.csllbl.lbl_snprating,
		        dataIndex: 'snprating',
		        width: 160,
				sortable: false,
		        tooltip: Ext.csllbl.txt_snprating
	        },{
		        header: Ext.csllbl.lbl_moodysrating,
		        dataIndex: 'moodysrating',
		        width: 160,
				sortable: false,
		        tooltip: Ext.csllbl.txt_moodysrating
	        },{
		        header: Ext.csllbl.lbl_aggregateprice,
		        dataIndex: 'aggregateprice',
		        width: 150,
		        tooltip: Ext.csllbl.txt_aggregateprice
	        },{
		        header: Ext.csllbl.lbl_aggregateaswapsprd,
		        dataIndex: 'aggregateaswapsprd',
		        renderer: greenred,
		        width: 150,
		        tooltip: Ext.csllbl.txt_aggregateaswapsprd
	        },{
		        header: Ext.csllbl.lbl_aggregateyield,
		        dataIndex: 'aggregateyield',
		        width: 150,
		        tooltip: Ext.csllbl.txt_aggregateyield
	        }]);
        
            var this_Time = '9:00 AM CET';
            
        break;
        
        case "tradeweb-dsup":

            var reader1 = new Ext.data.JsonReader({
                root: 'data',
                totalProperty: 'recordcount',
                id: 'intrecordid',
                fields: ['intrecordid', 'datedatagenerated', 'cusip', 'isin', 'sedol', 'coupon', 'description', 'securitytype', 'ontherun', 'spreadCUSIP', 'spreaddescription', 'bidprice', 'bidyield', 'bidspread', 'askprice', 'askyield', 'askspread', 'maturitydate', 'datedated', 'dateissued', 'auctiondate', 'firstcoupondate', 'issuedas', 'currency', 'thisdatetime', 'snprating', 'moodysrating']
            });
    	
	        var homecolumns1 = new Ext.grid.ColumnModel([{
		        header: Ext.csllbl.lbl_description,
		        dataIndex: 'description',
		        width: 200,
		        tooltip: Ext.csllbl.txt_description
	        },{
		        header: Ext.csllbl.lbl_cusip,
		        dataIndex: 'cusip',
		        width: 100,
		        tooltip: Ext.csllbl.txt_cusip
	        },{
		        header: Ext.csllbl.lbl_coupon,
		        dataIndex: 'coupon',
		        width: 60,
		        tooltip: Ext.csllbl.txt_coupon
	        },{
		        header: Ext.csllbl.lbl_maturity,
		        dataIndex: 'maturitydate',
		        width: 75,
		        tooltip: Ext.csllbl.txt_maturity
	        },{
		        header: Ext.csllbl.lbl_snprating,
		        dataIndex: 'snprating',
		        width: 160,
				sortable: false,
		        tooltip: Ext.csllbl.txt_snprating
	        },{
		        header: Ext.csllbl.lbl_moodysrating,
		        dataIndex: 'moodysrating',
		        width: 160,
				sortable: false,
		        tooltip: Ext.csllbl.txt_moodysrating
	        },{
		        header: Ext.csllbl.lbl_ccy,
		        dataIndex: 'currency',
		        width: 60,
		        tooltip: Ext.csllbl.txt_ccy
	        },{
		        header: Ext.csllbl.lbl_issuedate,
		        dataIndex: 'dateissued',
		        width: 75,
		        tooltip: Ext.csllbl.txt_issuedate
	        },{
		        header: Ext.csllbl.lbl_bidprice,
		        dataIndex: 'bidprice',
		        width: 100,
		        tooltip: Ext.csllbl.txt_bidprice
	        },{
		        header: Ext.csllbl.lbl_bidyield,
		        dataIndex: 'bidyield',
		        width: 75,
		        tooltip: Ext.csllbl.txt_bidyield
	        },{
		        header: Ext.csllbl.lbl_bidspread,
		        dataIndex: 'bidspread',
		        width: 75,
		        tooltip: Ext.csllbl.txt_bidspread
	        },{
		        header: Ext.csllbl.lbl_askprice,
		        dataIndex: 'askprice',
		        width: 100,
		        tooltip: Ext.csllbl.txt_askprice
	        },{
		        header: Ext.csllbl.lbl_askyield,
		        dataIndex: 'askyield',
		        width: 75,
		        tooltip: Ext.csllbl.txt_askyield
	        },{
		        header: Ext.csllbl.lbl_askspread,
		        dataIndex: 'askspread',
		        width: 75,
		        tooltip: Ext.csllbl.txt_askspread
	        }]);
	        
	        var this_Time = '10:45 PM CET';
	        
        break;
        
        case "tradeweb-trsy":
            
            var reader1 = new Ext.data.JsonReader({
                    root: 'data',
                    totalProperty: 'recordcount',
                    id: 'intrecordid',
                    fields: ['intrecordid', 'datedatagenerated', 'cusip', 'isin', 'sedol', 'description', 'securitytype', 'ontherun', 'bidprice', 'bidyield', 'bidspread', 'bidrate', 'askprice', 'askyield', 'askspread', 'askrate', 'maturitydate', 'datedated', 'dateissued', 'auctiondate', 'issuedas', 'coupon', 'firstcoupondate', 'whenissued', 'calldate', 'currency', 'thisdatetime', 'snprating', 'moodysrating']
                });
        	
	        var homecolumns1 = new Ext.grid.ColumnModel([{
		        header: Ext.csllbl.lbl_description,
		        dataIndex: 'description',
		        width: 200,
		        tooltip: Ext.csllbl.lbl_descriptiontrsy
	        },{
		        header: Ext.csllbl.lbl_cusip,
		        dataIndex: 'cusip',
		        width: 100,
		        tooltip: Ext.csllbl.txt_cusip
	        },{
		        header: Ext.csllbl.lbl_coupon,
		        dataIndex: 'coupon',
		        width: 60,
		        tooltip: Ext.csllbl.txt_coupon
	        },{
		        header: Ext.csllbl.lbl_maturity,
		        dataIndex: 'maturitydate',
		        width: 75,
		        tooltip: Ext.csllbl.txt_maturity
	        },{
		        header: Ext.csllbl.lbl_snprating,
		        dataIndex: 'snprating',
		        width: 160,
				sortable: false,
		        tooltip: Ext.csllbl.txt_snprating
	        },{
		        header: Ext.csllbl.lbl_moodysrating,
		        dataIndex: 'moodysrating',
		        width: 160,
				sortable: false,
		        tooltip: Ext.csllbl.txt_moodysrating
	        },{
		        header: Ext.csllbl.lbl_ccy,
		        dataIndex: 'currency',
		        width: 60,
		        tooltip: Ext.csllbl.txt_ccy
	        },{
		        header: Ext.csllbl.lbl_issuedate,
		        dataIndex: 'dateissued',
		        width: 75,
		        tooltip: Ext.csllbl.txt_issuedate
	        },{
		        header: Ext.csllbl.lbl_bidprice,
		        dataIndex: 'bidprice',
		        width: 100,
		        tooltip: Ext.csllbl.txt_bidprice
	        },{
		        header: Ext.csllbl.lbl_bidyield,
		        dataIndex: 'bidyield',
		        width: 75,
		        tooltip: Ext.csllbl.txt_bidyield
	        },{
		        header: Ext.csllbl.lbl_bidspread,
		        dataIndex: 'bidspread',
		        width: 75,
		        tooltip: Ext.csllbl.txt_bidspread
	        },{
		        header: Ext.csllbl.lbl_askprice,
		        dataIndex: 'askprice',
		        width: 100,
		        tooltip: Ext.csllbl.txt_askprice
	        },{
		        header: Ext.csllbl.lbl_askyield,
		        dataIndex: 'askyield',
		        width: 75,
		        tooltip: Ext.csllbl.txt_askyield
	        },{
		        header: Ext.csllbl.lbl_askspread,
		        dataIndex: 'askspread',
		        width: 75,
		        tooltip: Ext.csllbl.txt_askspread
	        }]);
	        
	        var this_Time = '10:45 PM CET';
	
        break;
        
        case "tradeweb-eugv":
        case "tradeweb-pfan":
        case "tradeweb-supr":
        
            var reader1 = new Ext.data.JsonReader({
                root: 'data',
                totalProperty: 'recordcount',
                idProperty: 'intrecordid',
                fields: ['intrecordid', 'datedatagenerated', 'cusip', 'isin', 'sedol', 'coupon', 'description', 'securitytype', 'ontherun', 'bidprice', 'bidyield', 'bidspread', 'askprice', 'askyield', 'askspread', 'maturitydate', 'datedated', 'dateissued', 'auctiondate', 'firstcoupondate', 'issuedas', 'assetswapspread', 'spread', 'ISIN', 'spreaddescription', 'currency', 'thisdatetime', 'snprating', 'moodysrating']
            });
            
            var homecolumns1 = new Ext.grid.ColumnModel([{
		        header: Ext.csllbl.lbl_description,
		        dataIndex: 'description',
		        width: 200,
		        tooltip: Ext.csllbl.txt_description
	        },{
		        header: Ext.csllbl.lbl_isin,
		        dataIndex: 'isin',
		        width: 100,
		        tooltip: Ext.csllbl.txt_isin
	        },{
		        header: Ext.csllbl.lbl_coupon,
		        dataIndex: 'coupon',
		        width: 60,
		        tooltip: Ext.csllbl.txt_coupon
	        },{
		        header: Ext.csllbl.lbl_issuedate,
		        dataIndex: 'dateissued',
		        width: 75,
		        tooltip: Ext.csllbl.txt_issuedate
	        },{
		        header: Ext.csllbl.lbl_snprating,
		        dataIndex: 'snprating',
		        width: 160,
				sortable: false,
		        tooltip: Ext.csllbl.txt_snprating
	        },{
		        header: Ext.csllbl.lbl_moodysrating,
		        dataIndex: 'moodysrating',
		        width: 160,
				sortable: false,
		        tooltip: Ext.csllbl.txt_moodysrating
	        },{
		        header: Ext.csllbl.lbl_ccy,
		        dataIndex: 'currency',
		        width: 60,
		        tooltip: Ext.csllbl.txt_ccy
	        },{
		        header: Ext.csllbl.lbl_bidprice,
		        dataIndex: 'bidprice',
		        width: 75,
		        tooltip: Ext.csllbl.txt_bidprice
	        },{
		        header: Ext.csllbl.lbl_bidyield,
		        dataIndex: 'bidyield',
		        width: 75,
		        tooltip: Ext.csllbl.txt_bidyield
	        },{
		        header: Ext.csllbl.lbl_bidspread,
		        dataIndex: 'bidspread',
		        width: 75,
		        tooltip: Ext.csllbl.txt_bidspread
	        },{
		        header: Ext.csllbl.lbl_askprice,
		        dataIndex: 'askprice',
		        width: 75,
		        tooltip: Ext.csllbl.txt_askprice
	        },{
		        header: Ext.csllbl.lbl_askyield,
		        dataIndex: 'askyield',
		        width: 75,
		        tooltip: Ext.csllbl.txt_askyield
	        },{
		        header: Ext.csllbl.lbl_askspread,
		        dataIndex: 'askspread',
		        width: 75,
		        tooltip: Ext.csllbl.txt_askspread
	        }]);
	        
	        var this_Time = '5:45 PM CET';
	        
        break;
        
    }
    
    // proxy1.on and searchTbar
    var thisPageSize = 20;
	
	switch (qsParm["strView"]) {
        case "markit-corporate":
        case "tradeweb-pfan":
        default:
        
            proxy1.on('beforeload', function(p, params) {

                params.strView = qsParm["strView"];
                
                var this_strMaturityDate = qsParm["strMaturityDate"];
                if (this_strMaturityDate != document.getElementById('strMaturityDate').value){
                    this_strMaturityDate = document.getElementById('strMaturityDate').value;
                }
                
                var this_strISIN = qsParm["strISIN"];
                if (this_strISIN != document.getElementById('strISIN').value){
                    this_strISIN = document.getElementById('strISIN').value;
                }

                params.strMaturityDate = this_strMaturityDate;
                params.strISIN = this_strISIN;
	        });
	        
            var searchTbar = [
                '<b>Search Parameters:</b>',
                '&nbsp;&nbsp;Maturity Date',
                {xtype: 'textfield',
                    id: 'strMaturityDate',
                    width:120,
                    value: qsParm["strMaturityDate"]},
                '&nbsp;&nbsp;ISIN',
                {xtype: 'textfield',
                    id: 'strISIN',
                    width:120,
                    value: qsParm["strISIN"]},
                '&nbsp;&nbsp;',
                {xtype: 'button',
                    text: '<b>Search</b>',
                    handler: function() {
                        store1.load({params:{start:0, limit:thisPageSize}});
                    }
                },
                Ext.csllbl.txt_scrollbar
            ];
            
        break;
        
        case "tradeweb-dsup":
        case "tradeweb-trsy":
        
            proxy1.on('beforeload', function(p, params) {

                params.strView = qsParm["strView"];
                
                var this_strMaturityDate = qsParm["strMaturityDate"];
                if (this_strMaturityDate != document.getElementById('strMaturityDate').value){
                    this_strMaturityDate = document.getElementById('strMaturityDate').value;
                }
                
                var this_strCUSIP = qsParm["strCUSIP"];
                if (this_strCUSIP != document.getElementById('strCUSIP').value){
                    this_strCUSIP = document.getElementById('strCUSIP').value;
                }

                params.strMaturityDate = this_strMaturityDate;
                params.strCUSIP = this_strCUSIP;
	        });

            var searchTbar = [
                Ext.csllbl.txt_searchparam,
                Ext.csllbl.txt_searchmaturity,
                {xtype: 'textfield',
                    id: 'strMaturityDate',
                    width:120,
                    value: qsParm["strMaturityDate"]},
                '&nbsp;&nbsp;CUSIP',
                {xtype: 'textfield',
                    id: 'strCUSIP',
                    width:120,
                    value: qsParm["strCUSIP"]},
                '&nbsp;&nbsp;',
                {xtype: 'button',
                    text: Ext.csllbl.txt_searchbutton,
                    handler: function() {
                        store1.load({params:{start:0, limit:thisPageSize}});
                    }
                }
            ];
        
        break;
        
        case "tradeweb-eugv":
        case "tradeweb-supr":
        
            proxy1.on('beforeload', function(p, params) {

                params.strView = qsParm["strView"];
                
                var this_strCountry = qsParm["strCountry"];
                if (this_strCountry != document.getElementById('strCountry_hidden').value){
                    this_strCountry = document.getElementById('strCountry_hidden').value;
                }
                
                var this_strISIN = qsParm["strISIN"];
                if (this_strISIN != document.getElementById('strISIN').value){
                    this_strISIN = document.getElementById('strISIN').value;
                }
                
                var this_strMaturityDate = qsParm["strMaturityDate"];
                if (this_strMaturityDate != document.getElementById('strMaturityDate').value){
                    this_strMaturityDate = document.getElementById('strMaturityDate').value;
                }
                
                params.strCountry = this_strCountry;
                params.strMaturityDate = this_strMaturityDate;
                params.strISIN = this_strISIN;
	        });
	        
            var searchTbar = [
                Ext.csllbl.txt_searchparam,
                Ext.csllbl.txt_issuingcountry,
                countryArray,
                Ext.csllbl.txt_searchmaturity,
                {xtype: 'textfield',
                    id: 'strMaturityDate',
                    width:120,
                    value: qsParm["strMaturityDate"]},
                '&nbsp;&nbsp;ISIN',
                {xtype: 'textfield',
                    id: 'strISIN',
                    width:120,
                    value: qsParm["strISIN"]},
                '&nbsp;&nbsp;',
                {xtype: 'button',
                    cls: 'x-btn-text-icon details',
                    text: Ext.csllbl.txt_searchbutton,
                    handler: function() {
                        store1.load({params:{start:0, limit:thisPageSize}});
                    }
                }
            ];
	        
        break;
    }

	homecolumns1.defaultSortable = true;
	
	var viewconfig1 = {forceFit:false, enableRowBody:true, showPreview: false};

    var store1 = new Ext.data.Store({
        proxy: proxy1,
		reader: reader1,
        remoteSort: true
    });	
    
    var dt = "No Date"; //To make sure the date doesn't get added after every reload
    
    store1.on('load', function(){
        var count = store1.getTotalCount();
        if (count == 0) {
            Ext.Msg.alert('', Ext.csllbl.txt_noresults);
        }             
        
        if (dt == 'No Date'){
            dt = new Date(store1.getAt(0).data.thisdatetime);
	        var lu = Ext.csllbl.txt_lastupdated + ' ' + dt.format('d/m/Y') + ' ' + this_Time;
            pagingBar.addButton({text: lu});
           }
    
    });
        
    var pagingBar = new Ext.PagingToolbar({
        pageSize: thisPageSize,
        store: store1,
	    displayInfo: true,
        displayMsg: Ext.csllbl.lbl_noresults + ' {0} - {1} of {2}',
        emptyMsg: Ext.csllbl.lbl_noresults,
        items: ['-']
    });
        
    var grid1 = new Ext.grid.GridPanel({
        renderTo: 'price_console',
	    height: 605,
        store: store1,
        cm: homecolumns1,
        loadMask: true,
        viewConfig: viewconfig1,
        tbar: searchTbar,
        bbar: pagingBar
    });
    
    // render it
    grid1.render(); 
    
    // trigger the data store load
    store1.load({params:{start:0, limit:thisPageSize}});

	//END home_iib_ei
	
	// when the page is resized, refresh the grid
    var refreshGrid = function() {
        grid1.getView().refresh();
    }
    Ext.EventManager.onWindowResize(refreshGrid);
    
});
