Kelda.Info.ISSTabbed = Ext.extend(Ext.TabPanel,{
	initComponent : function() {
		/*this.tabs = [
		             {xtype:'ISSP_Child',title:'A'},
		             {xtype:'ISSP_Child',title:'B'},
		             {xtype:'ISSP_Child',title:'C'}
		];*/
		this.add(new Kelda.Info.ISSGrid());
		
		this.on('render',function() {
			//console.log('render');
		})
	}
});
Ext.reg('ISSTabbed',Kelda.Info.ISSTabbed);


Kelda.Info.ISSGrid = Ext.extend(Ext.grid.GridPanel,{
	
	initComponent : function() {
		Ext.QuickTips.init();
		var pctChange = function(val){
	        if(val > 0){
	            return '<span style="color:green;">' + Kelda.Info.ValueRenderer(val,keldan_lang) + '&#37;</span>';
	        }else if(val < 0){
	            return '<span style="color:red;">&#45;' + Kelda.Info.ValueRenderer(Math.abs(val),keldan_lang) + '&#37;</span>';
	        }else if(isNaN(val))
	        	return '-';
	        else
	        	return Kelda.Info.ValueRenderer(val,'is')+"&#37;";
	    };
	    var change = function(val){
	        if(val > 0){
	            return '<span style="color:green;">' + Kelda.Info.ValueRenderer(val,keldan_lang)+'</span>';
	        }else if(val < 0){
	            return '<span style="color:red;">-' + Kelda.Info.ValueRenderer(Math.abs(val),keldan_lang) + '</span>';
	        }else if(isNaN(val))
	        	return '-';
	        else
	        	return val;
	    };
	    var defaultRenderer = function(val,p,rec) {
	    	if(isNaN(val)) {
	    		return '-';
	    	}
	    	else {
	    		return Kelda.Info.ValueRenderer(val,keldan_lang);
	    	}
	    };
    	this.rowActions = keldanNewRowaction(32);
    
		isscolumns=[{
			id: 'FullName',
			header: keldan_lang_text('name'),
			tooltip:keldan_lang_text('name'),
			dataIndex: 'fullName',
			width: 50,
			hidden:true,
			sortable:true
		},{
			id: 'Name',
			header: keldan_lang_text('identity'),
			tooltip:keldan_lang_text('identity'),
			dataIndex: 'name',
			width: (Ext.isIE||Ext.isChrome?65:55),
			sortable:true,
			renderer:function(val,p,rec) {
				p.attr = 'ext:qtip="'+rec.data.fullName+'"';
				if(val==='OMXI6ISK')
					return '<b>'+val+'</b>';
				else
					return val;
			}
		},{
            id: 'Last', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header:keldan_lang_text('price'),
            tooltip:keldan_lang_text('last price'),	
            dataIndex: 'last',
            width: 60,
            align:'right',
            renderer: function(val,p,rec) {
				if(val===0)
					return '';
				else if(rec.data.name=='OMXI6ISK') {
					return '<b>'+Kelda.Info.ValueRenderer(val,keldan_lang)+"</b>";
				}
				else 
					return Kelda.Info.ValueRenderer(val,keldan_lang);
			},
            sortable: true
        },{
        	id:'LastChangePct',
        	header:keldan_lang_text('change'),
        	tooltip:keldan_lang_text('change in percentage'),
        	dataIndex:'change_pct',
        	width:(Ext.isIE||Ext.isChrome?55:45),
        	align:'right',
        	renderer:function(val,p,rec) {
        		omxi6 = rec.data.name=="OMXI6ISK";
        		if(val > 0){
        			if(omxi6) {
        				return '<span style="color:green;"><b>' + Kelda.Info.ValueRenderer(val,keldan_lang) + '&#37;</b></span>';
        			}else {
        				return '<span style="color:green;">' + Kelda.Info.ValueRenderer(val,keldan_lang) + '&#37;</span>';
        			}
        		}else if(val < 0){
        			if(omxi6) {
        				return '<span style="color:red;"><b>&#45;' + Kelda.Info.ValueRenderer(Math.abs(val),keldan_lang) + '&#37;</b></span>';
        			}else {
        				return '<span style="color:red;">&#45;' + Kelda.Info.ValueRenderer(Math.abs(val),keldan_lang) + '&#37;</span>';
        			}
        		}else if(isNaN(val) || val===0) {
        			return '0&#37;';
        		}
        		else {
        			if(omxi6) {
        				return '<b>'+Kelda.Info.ValueRenderer(val,keldan_lang)+"&#37;"+'</b>';
        			}
        			return Kelda.Info.ValueRenderer(val,keldan_lang)+"&#37;";
        		}
        	},
        	sortable:true,
        	hidden:false
        },{
            id: 'Bid', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('bid'),
            dataIndex: 'bid',
            width: 45,
            align:'right',
            //renderer:Ext.util.Format.dateRenderer('d/m/Y'),
            renderer: function(val) {
        		if(isNaN(val) || val===0) {
        			return '-';
        		}
        		else {
        			return Kelda.Info.ValueRenderer(val,keldan_lang);
        		}
        	},
        	hidden:(keldan_screen=='s'?true:false),
            sortable: true
        },{
            id: 'Ask', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('ask'),
            tooltip:keldan_lang_text('ask'),
            dataIndex: 'ask',
            width: 45,
            align:'right',
            renderer: function(val) {
        		if(isNaN(val) || val===0) {
        			return '-';
        		}
        		else {
        			return Kelda.Info.ValueRenderer(val,keldan_lang);
        		}
        	},
        	hidden:(keldan_screen=='s'?true:false),
            sortable: true
        },{
        	id:'Last Change',
        	header:keldan_lang_text('change'),
        	tooltip:keldan_lang_text('change'),
        	dataIndex:'change',
        	width:60,
        	align:'right',
        	renderer:change,
        	hidden:true
        },{
        	id:'LastClose',
        	header:keldan_lang_text('closevalue'),
        	tooltip:keldan_lang_text('closevalue'),
        	dataIndex:'close',
        	width:55,
        	align:'right',
        	renderer:defaultRenderer,
        	hidden:true
        },{
        	id:'Volume',
        	header:keldan_lang_text('volume-shares'),
        	dataIndex:'volume',
        	width:65,
        	align:'right',
        	renderer:function(val){
        		return Kelda.Info.ValueRendererBig(val,keldan_lang);
        	},
        	hidden:true
        },{
        	id:'Turnover',
        	header:keldan_lang_text('volume'),
        	dataIndex:'turnover',
        	width:70,
        	align:'right',
        	renderer:function(val) {
        		return Kelda.Info.ValueRendererBig(val,keldan_lang);
        	},
        	hidden:false
        },/*{
            id: 'Updated', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: "Tími",
            dataIndex: 'updated',
            width: 150,
            hidden:true,
            renderer:Ext.util.Format.dateRenderer('d/m/Y H:i:s'),
            //renderer: this.renderTopic,
            sortable: true
        },*/{
            id: 'instrumentmarket', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
        	header: keldan_lang_text('market'),
        	dataIndex: 'instrumentMarket',
        	width: 45,
        	hidden:true
        },this.rowActions];
		
		var issstore = new Ext.data.JsonStore({
        	root: 'response',
        	autoDestroy:true,
        	id:'issJsonId',
            fields: [ {name:'instrumentMarket'},{name:'name'},
                {name:"fullName"/*,sortType:function(s){
            		if(s.indexOf("OMX") > -1 )
            			return 0;
            		else
            			return Ext.data.SortTypes.asText(s);
            	}*/},
            	{name:'bid',type:'float'},{name:'ask',type:'float'},
            	{name:'last',type:'float'},{name:'updated',mapping:'date',type:'string'},
            	{name:'change',mapping:'last_change',type:'float'},
            	{name:'change_pct',mapping:'last_change_pct',type:'float'},
            	{name:'open_change_pct',type:'float'},
            	{name:'close',mapping:'last_close',type:'float'},
            	{name:'turnover',type:'float'},{name:'volume',type:'float'},
            	{name:'description',mapping:'fullName',type:'string'},
            	{name:'marketOpen',type:'boolean'},
            	{name:'category',type:'string'},
            	{name:'ricCode',type:'string'}
            ],
            proxy: new Ext.data.HttpProxy({
                //url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"feedconnect/getFeed"
            	url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"connector/getMarketEquity"
            }),
            sortInfo:{field:'category',direction:'ASC'}
            //groupingField:'instrumentMarket',
		    //
            
        });
		//console.log(window.location.protocol+"//"+window.location.hostname+"/"+basePath);
		var cat = this.category;
		var issview = new Ext.grid.GridView( {
			forceFit : true,
			//autoFill:true,
            enableRowBody:true,
            scrollOffset:(cat=='ALL'?16:1),
            showPreview:false,
            getRowClass : function(record, rowIndex, p, store){
				if ((parseInt(rowIndex) % 2) == 0)
					return 'odd-row';	

			},
			columnsText:keldan_lang_text('columns'),
			sortAscText:keldan_lang_text('sort ascending'),
			sortDescText:keldan_lang_text('sort descending')
			/*getGroupField : function() {
				return 'instrumentMarket';
			}*/
		});
		issstore.on('load',function(store,records,options) {
			if(this.loadMask.disable)
    			this.loadMask.disable();
			var rec = records[0];
			if(!rec)return;
			var marketOpen = rec.data.marketOpen;
			this.bubble(function(){
				if(this.header) {
					if(marketOpen) {
						this.header.removeClass('redlight');
						this.header.addClass('greenlight');
					}else {
						this.header.removeClass('greenlight');
						this.header.addClass('redlight');
					}
				}
			});
			if(Ext.Msg.isVisible()) {
				keldan_store_count--;
				Ext.Msg.updateProgress((keldan_fixed_stcount-keldan_store_count)/keldan_fixed_stcount
						,keldan_fixed_stcount-keldan_store_count+(keldan_lang=='is' ? ' af ' : ' of ')+keldan_fixed_stcount);
				if(keldan_store_count==0) {
					Ext.Msg.hide();
					keldan_store_count=-1;
				}
			}
		},this);
		
		Ext.apply(this,{
			id:'marketgrid_'+Math.random()*1011,
			stateId:'issgrid_'+cat,
    		store : issstore,
    	    columns:isscolumns,
    	    plugins:[this.rowActions],
    	    view:issview
    	    //autoHeight:true
    	    
    	   
    	    
    	});
		
		this.isstask = {
	        	run:function() {
					//issstore.load({params:{feedName:'equityMarket',marketType:'ISS',type:cat}});
					issstore.load({params:{type:cat}});
				},
				interval: 60000,
				running:false
		};
		
		//setTimeout('Ext.TaskMgr.start(isstask)',60000);
		this.on('render',function(){

		},this);
		
    	this.on('destroy',function(){
    		Ext.TaskMgr.stop(this.isstask);
    	},this);
    	this.on('hide',function(){
    		Ext.TaskMgr.stop(this.isstask);
    	});
    	this.on('show',function(){
    		Ext.TaskMgr.start(this.isstask);
    	});
    	
    	Kelda.Info.ISSGrid.superclass.initComponent.apply(this,arguments);
	},
	stopPoll : function() {
		Ext.TaskMgr.stop(this.isstask);
	},
	startPoll : function() {
		Ext.TaskMgr.start(this.isstask);
	}
	/*
	getState : function() {
		console.log('get state stocks');
		return Kelda.Info.ISSGrid.superclass.getState.call(this);
	},
	applyState : function(state,config) {
		console.log('apply state stocks');
		Ext.apply(this,state);
	}
	*/
});
Ext.reg('ISSP_Child',Kelda.Info.ISSGrid);



Kelda.Info.ISSPortlet = Ext.extend(Ext.Panel,{
	
	initComponent: function() {
		this.on('render',function(){
			var w = 0;
			var vp = Ext.getCmp('main-viewport');
			if(vp)
				w = vp.getSize().width-50;
			Ext.apply(this,{
				preferredWinSize : {
					width:w!=0?w:500,
					height:380
				}
			});
			if(Ext.Msg.isVisible()) {
				keldan_store_count--;
				Ext.Msg.updateProgress((keldan_fixed_stcount-keldan_store_count)/keldan_fixed_stcount
						,keldan_fixed_stcount-keldan_store_count+(keldan_lang=='is' ? ' af ' : ' of ')+keldan_fixed_stcount);
				if(keldan_store_count==0) {
					Ext.Msg.hide();
					keldan_store_count=-1;
				}
			}
			
		},this);
		
		Kelda.Info.ISSPortlet.superclass.initComponent.apply(this,arguments);
	},
	layout:'fit',
	iconCls:'redlight',
	plugins: [Ext.ux.PortletPlugin],
    closeable: true,
    maximizable:false,
    resizeable:true,
    settings: false,
    collapsible:true,
    winWidth:480,
    winHeight:300,
    version:1.0001,
    width:400,
    //autoHeight:true
    height:(Ext.isIE?290:254)
});
Ext.reg('ISSP',Kelda.Info.ISSPortlet);



Kelda.Info.ISBGrid = Ext.extend(Ext.grid.GridPanel,{
	
	
	initComponent : function() {
		this.priceCache=[];
		this.yieldCache=[];
		this.bondsCollapsed=false;
		this.indexedCollapsed=false;
		this.rowActions = keldanNewRowaction(10);
		this.valueRenderer = function(value,metadata) {
			var val = value * 100;
			return Kelda.Info.ValueRenderer(val,keldan_lang);
		};
		var pctChange = function(val){
			val = val * 100;
	        if(val > 0){
	            return '<span style="color:green;">' + Kelda.Info.ValueRenderer(val,keldan_lang) + '&#37;</span>';
	        }else if(val < 0){
	            return '<span style="color:red;">&#45;' + Kelda.Info.ValueRenderer(Math.abs(val),keldan_lang) + '&#37;</span>';
	        }else if(isNaN(val))
	        	return '-';
	        else
	        	return Kelda.Info.ValueRenderer(val,keldan_lang)+"&#37;";
	    };
	    var nameW,bidYieldW,deltaW,deltaPctW,bidW,askW,lastW,volW;
	    if(Ext.isIE) {
	    	nameW = 32;
	    	bidYieldW = 22;
	    	deltaW = 11;
	    	deltaPctW = 19;
	    	bidW = 18;	
	    	askW = 18;
	    	lastW = 18;
	    	volW = 20;
	    }else if(Ext.isGecko) {
	    	nameW = 20;
	    	bidYieldW = 12;
	    	deltaW = 8;
	    	deltaPctW = 12;
	    	bidW = 11;
	    	askW = 11;
	    	lastW = 11;
		    volW = 12;
	    }else {
	    	nameW = 17;
	    	bidYieldW = 12;
	    	deltaW = 8;
	    	deltaPctW = 12;
	    	bidW = 10;
	    	askW = 10;
	    	lastW = 10;
		    volW = 12;
	    }
	    	
	    this.clearCellTask = new Ext.util.DelayedTask(function() {
    		var m = function(cssselect) {
    			var a = Ext.DomQuery.jsSelect(cssselect);
    			if(a.length < 1)
    				return;
    			for(i=0;i<a.length;i++) {
    				var el = Ext.get(a[i]);
    				el.removeClass('red-class');
    				el.removeClass('green-class');
    			}
    		};
    		m('.x-grid3-td-BidYield');
    		m('.x-grid3-td-LastPointChange');
    		m('.x-grid3-td-Bid');
    		m('.x-grid3-td-Ask');
    		m('.x-grid3-td-Volume');
    		m('.x-grid3-td-Last');
    	});
		this.isbcolumns=[{
			id: 'Name',
			header: keldan_lang_text('category'),
			dataIndex: 'name',
			width: nameW,
			align:'left',
			renderer : function(val) {
				if(val.substring(0,3)=='HFF') {
					val = val.substring(0,3)+" "+val.substring(7,9)+" "+val.substring(5,7)+""+val.substring(3,5);
				}
				return val;
			},
			sortable:false,
			groupable:false,
			hidden:false
		},{
            id: 'BidYield', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('bidyield'),
            tooltip:keldan_lang_text('bidyield'),
            dataIndex: 'bid_yield',
            width:bidYieldW,
            align:'right',
            groupable:false,
            renderer:function(val,p,record){
				var oldValue = record.get('old_bid_yield');
				if(val < oldValue) {
					p.css = 'red-class';
					p.attr = 'style="color:red"';
				}else if(val > oldValue) {
					p.css = 'green-class';
					p.attr = 'style="color:green"';
				}
			
			if(record.data.daycount <= 0 && record.data.name.indexOf('RIKV') >= 0)
				return '-';
			val = val *100;
			if(val===0)
				return '0&#37;';
			else
				return Kelda.Info.ValueRenderer(val,keldan_lang)+"&#37;";
			},
            hidden:false,
            sortable: true
        },{
            id: 'LastPointChange', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: "&#916;",
            tooltip:keldan_lang_text('basepointchange'),
            dataIndex: 'basePointChange',
            width: deltaW,
            groupable:false,
            align:'right',
            renderer: function(v,meta,rec) {
        		var oldValue = rec.get('oldBasePointChange');
        		if(v < oldValue) {
        			meta.css = 'red-class';
        			meta.attr = 'style="color:red"';
        		}else if(v > oldValue) {
        			meta.css = 'green-class';
        			meta.attr = 'style="color:green"';
        		}
        	
        		var val = 0;
        		if(v != -1)
        			val = v*10000;
        		if(val > 0){
        			return '<span style="color:green;">' + Kelda.Info.ValueRendererBig(val,keldan_lang) + '</span>';
        		}else if(val < 0){
        			return '<span style="color:red;">&#45;' + Kelda.Info.ValueRendererBig(Math.abs(val),keldan_lang) + '</span>';
        		}
        		return Kelda.Info.ValueRendererBig(val,keldan_lang);
        	},
            sortable: true,
            hidden:false
        },{
        	id: 'BidChange', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: "&#916;"+' &#37;',
            tooltip:keldan_lang_text('bidchange'),
            dataIndex: 'bidChange',
            width: deltaPctW,
            renderer:pctChange,
            align:'right',
            hidden:true,
            groupable:false,
            sortable: true
        },{
            id: 'Bid', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('bid'),	
            dataIndex: 'bid',
            groupable:false,
            width: bidW,
            renderer:function(val,meta,rec) {
        		var old = rec.get('oldBid');
        		if(val < old) {
        			meta.css = 'red-class';
        			meta.attr = 'style="color:red"';
        		}
        		else if(val > old) {
        			meta.css = 'green-class';
        			meta.attr = 'style="color:green"';
        		}
        		if(isNaN(val) || val===0)
        			return '-';
        		else
        			return Kelda.Info.ValueRenderer(val,keldan_lang);
        	},
            align:'right',
            hidden:(keldan_screen=='s'?true:false),
            sortable: true
        },{
            id: 'Ask', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header:keldan_lang_text('ask'),
            groupable:false,
            renderer:function(val,meta,rec) {
        		var old = rec.get('oldAsk');
    			if(val < old) {
    				meta.css = 'red-class';
    				meta.attr = 'style="color:red"';
    			}
    			else if(val > old) {
    				meta.css = 'green-class';
    				meta.attr = 'style="color:green"';
    			}
        		if(isNaN(val) || val===0)
        			return '-';
        		else
        			return Kelda.Info.ValueRenderer(val,keldan_lang);
        	},
            dataIndex: 'ask',
            width: askW,
            align:'right',
            hidden:(keldan_screen=='s'?true:false),
            sortable: true
        },{
            id: 'Last', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('price'),
            tooltip:keldan_lang_text('last price'),	
            dataIndex: 'last',
            groupable:false,
            width: lastW,
            renderer:function(val,meta,rec) {
        		var oldLast = rec.get('oldLast');
        		if(val < oldLast) {
        			meta.css = 'red-class';
        			meta.attr = 'style="color:red"';
        		}
        		else if(val > oldLast) {
        			meta.css = 'green-class';
        			meta.attr = 'style="color:green"';
        		}
        		if(isNaN(val) || val===0)
        			return '-';
        		else
        			return Kelda.Info.ValueRenderer(val,keldan_lang);
        	},
            align:'right',
            //renderer: this.valueRenderer,
            sortable: true
        },{
            id: 'Volume', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('volume'),
            tooltip:keldan_lang_text('volume-shares'),
            dataIndex: 'volume',
            width: volW,
            groupable:false,
            align:'right',
            renderer: function(val,meta,rec) {
        		var old = rec.get('oldVolume');
				if(val < old) {
					meta.css = 'red-class';
					meta.attr = 'style="color:red"';
				}
				else if(val > old) {
					meta.css = 'green-class';
					meta.attr = 'style="color:green"';
				}
        		var n = 0;
        		if(!isNaN(val))
        			n = Kelda.Info.ValueRendererBig(val/1000000,keldan_lang);
        		
        		return n+"m";
        		//return Kelda.Info.NumberFormat(val,'0.000/i');
        	
        	},
            sortable: true
        },{
            id: 'LastClose', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('closeprice'),	
            dataIndex: 'last_close',
            width: 70,
            align:'right',
            hidden:true,
            groupable:false,
            renderer: function(val) {
        		return Kelda.Info.ValueRenderer(val,keldan_lang);
        	},
            sortable: true
        },{
        	id:'LastYield',
        	header:keldan_lang_text('yield'),
        	align:'right',
        	dataIndex:'last_yield',
        	width:48,
        	groupable:false,
        	renderer:function(val,p,record){
        		var oldValue = record.get('old_last_yield');
        		if(val < oldValue) {
        			p.css = 'red-class';
        			p.attr = 'style="color:red"';
        		}else if(val > oldValue) {
        			p.css = 'green-class';
        			p.attr = 'style="color:green"';
        		}
		
        		if(record.data.daycount <= 0 && record.data.name.indexOf('RIKV') >= 0)
        			return '-';
        		val = val *100;
        		if(val===0)
        			return '0&#37;';
        		else
        			return Kelda.Info.ValueRenderer(val,keldan_lang)+"&#37;";
			},
        	sortable:true,
        	hidden:true
        },{
            id: 'AskYield', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('askyield'),
            dataIndex: 'ask_yield',
            width: 70,
            align:'right',
            groupable:false,
            renderer:function(val,p,record){
        		if(record.data.daycount <= 0 && record.data.name.indexOf('RIKV')>=0)
        			return '-';
			val = val *100;
			if(val===0)
				return '0&#37;';
			else
				return Kelda.Info.ValueRenderer(val,keldan_lang)+"&#37;";
			},
            hidden:true,
            sortable: true
        },{
            id: 'instrumentType', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
        	header: keldan_lang_text('type'),	
        	dataIndex: 'instrumentType',
        	width: 70,
        	hidden:true,
        	sortable: true,
        	renderer:function(val) {
        		
        		switch(val) {
        			case 'BONDSINDEXED' :
        				return keldan_lang_text('indexed');
        			case  'BONDS' :
        				return keldan_lang_text('nonindexed');
        			case 'BILLS' :
        				return keldan_lang_text('treasurybills');
        			default:
        				return val;
        		}
        		
        		return val;
        	}
        },this.rowActions];
		
		this.isbstore = new Ext.data.GroupingStore({
			autoDestroy:true,
			reader : new Ext.data.JsonReader({
				root: 'response',
				id : 'name',
				fields: [{name:'instrumentType'},{name:'name'},
				         {name:'bid',type:'float'},{name:'oldBid',type:'float'},
				         {name:'ask',type:'float'},{name:'oldAsk',type:'float'},
				         {name:'last',type:'float'},{name:'oldLast',type:'float'},{name:'description',type:'string'},
				         {name:'last_yield',type:'float'},{name:'ask_yield',type:'float'},
				         {name:'bid_yield',type:'float'},{name:'old_bid_yield',type:'float'},{name:'last_change_pct',type:'float'},
				         {name:'last_close',type:'float'},{name:'volume',type:'float'},
				         {name:'oldVolume',type:'float'},
				         {name:'basePointChange',type:'float'},{name:'oldBasePointChange',type:'float'},
				         {name:'marketOpen',type:'boolean'},
				         {name:'price',type:'float'},{name:'yield',type:'float'},{name:'bidChange',type:'float'},
				         {name:'daycount',type:'int'},
				         {name:'ricCode',type:'string'}
				         ]
			}),
			proxy : new Ext.data.HttpProxy({
				url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"connector/getBondsAndBills"
			}),
			//remoteGroup:false,
			//remoteSort:false,
		    groupField:'instrumentType',
		    sortingInfo:{field:'instrumentType',direction:'ASC'}
		});
		var grid = this;
		var view = new Ext.grid.GroupingView( {
			forceFit : true,
			
			autoFill:true,
            enableRowBody:true,
            markDirty:false,
            //groupMode:'display',
            scrollOffset:1,
            showPreview:false,
            getRowClass : function(record, rowIndex, p, store){
				if ((parseInt(rowIndex) % 2) == 0)
					return 'odd-row';

			},
			startCollapsed:true,
			//getGroupField : function() {
//				return 'instrumentType';
	//		},
			showGroupName:false,
			hideGroupedColumn:true,
			columnsText:keldan_lang_text('columns'),
			sortAscText:keldan_lang_text('sort ascending'),
			sortDescText:keldan_lang_text('sort descending'),
			enableGroupingMenu:false
		});
		
		
		
		Ext.apply(this,{
			id : 'isbgrid_'+Math.random()*110,
			stateId:'isbgrid',
    		store : this.isbstore,
    	    columns:this.isbcolumns,
    	    view:view,
    	    autoHeight:true,
    	    autoExpandColumn:'YieldCalc',
    	    plugins:[this.rowActions]
    	   
    	});
		/*
    	this.isbtask = {
        	run:function() {
    			//grid.isbstore.load({params:{feedName:'getBondNumbers'}});
    			grid.isbstore.load();
			},
			interval: 60000
    	};
    	*/
    	//setTimeout('Ext.TaskMgr.start(isbtask)',60000);
    	this.on('render',function(comp) {
			
		},this);
    	this.on('show',function(comp) {
    		Ext.TaskMgr.start(this.isbTask);
    	});
    	this.on('hide',function(comp) {
    		Ext.TaskMgr.stop(this.isbTask);
    	});
    	this.on('destroy',function(){
    		Ext.TaskMgr.stop(this.isbTask);
    	});
    	
    	this.isbstore.on('load',function(store,records,options) {
    		grid.getView().toggleRowIndex(1,true);
    		if(this.loadMask.disable)
    			this.loadMask.disable();
    		rec = records[0];
			if(!rec)return;
			var marketOpen = rec.data.marketOpen;
			this.bubble(function(){
				if(this.header) {
					if(marketOpen) {
						this.header.removeClass('redlight');
						this.header.addClass('greenlight');
					}else {
						this.header.removeClass('greenlight');
						this.header.addClass('redlight');
					}
				}
			});
			if(Ext.Msg.isVisible()) {
				keldan_store_count--;
				Ext.Msg.updateProgress((keldan_fixed_stcount-keldan_store_count)/keldan_fixed_stcount
						,keldan_fixed_stcount-keldan_store_count+(keldan_lang=='is' ? ' af ' : ' of ')+keldan_fixed_stcount);
				if(keldan_store_count==0) {
					Ext.Msg.hide();
					keldan_store_count=-1;
				}
			}
			
		});
    	this.isbTask = {
    			run : function() {
    				
    				if(grid.loadMask.disable)
    					grid.loadMask.disable();
    				Ext.Ajax.request({
    				 url:window.location.protocol+"//"+window.location.hostname+"/"+basePath+"connector/getBondsAndBills",
    				 success: function(response){
    					var obj = Ext.decode(response.responseText);
    					var data = obj.response;
    					var rec;
    					var marketOpen = false;
    					for(var i = 0; i < data.length; i++){
    						rec = this.isbstore.getById(data[i].name);
    						//console.log('instrument is '+data[i].instrumentType);
    						if(rec){
    							
    							rec.data.oldBid = rec.get('bid');
    							rec.set('bid',data[i].bid);
    							rec.data.oldAsk = rec.get('ask');
    							rec.set('ask',data[i].ask);
    							rec.data.oldLast = rec.get('last');
    							rec.set('last', data[i].last);
    							rec.data.oldVolume = rec.get('volume');
    							rec.set('volume',data[i].volume);
    							rec.data.old_bid_yield = rec.get('bid_yield');
    							rec.set('bid_yield',data[i].bid_yield);
    							rec.data.old_ask_yield = rec.get('ask_yield');
    							rec.set('ask_yield',data[i].ask_yield);
    							rec.data.old_last_yield =rec.get('last_yield');
    							rec.set('last_yield',data[i].last_yield);
    							rec.data.oldBasePointChange = rec.get('basePointChange');
    							rec.set('basePointChange',data[i].basePointChange);
    							rec.set('marketOpen',data[i].marketOpen);
    							rec.set('instrumentType',data[i].instrumentType);
    							
    						}else{
    							rec = new this.isbstore.recordType(data[i], data[i].name);
    							this.isbstore.add(rec);
    						}
    						marketOpen = rec.data.marketOpen;
    					}
    					
    					this.bubble(function(){
    						if(this.header) {
    							if(marketOpen!=='false') {
    								this.header.removeClass('redlight');
    								this.header.addClass('greenlight');
    							}else {
    								this.header.removeClass('greenlight');
    								this.header.addClass('redlight');
    							}
    						}
    					});
    					this.clearCellTask.delay(3000);
        				grid.getView().toggleRowIndex(1,true);
        				grid.getView().toggleRowIndex(10,true);
        				
    				 },
    				 scope:grid
    				});
    				keldanCloseStoreMask();
    			},
    			interval : 60000
    			
    		};
    	
    	Kelda.Info.ISBGrid.superclass.initComponent.apply(this,arguments);
	},
	stopPoll : function() {
		Ext.TaskMgr.stop(this.isbTask);
	},
	startPoll : function() {
		Ext.TaskMgr.start(this.isbTask);
	}
	
});
Ext.reg('ISBP_Child',Kelda.Info.ISBGrid);



Kelda.Info.BondsGrid = Ext.extend(Ext.grid.EditorGridPanel,{
	initComponent : function() {
	this.priceCache=[];
	this.yieldCache=[];
	this.bondsCollapsed=false;
	this.indexedCollapsed=false;
	this.valueRenderer = function(value,metadata) {
		var val = value * 100;
		return Kelda.Info.ValueRenderer(val,keldan_lang);
	};
	var pctChange = function(val){
		val = val * 100;
        if(val > 0){
            return '<span style="color:green;">' + Kelda.Info.ValueRenderer(val,keldan_lang) + '&#37;</span>';
        }else if(val < 0){
            return '<span style="color:red;">&#45;' + Kelda.Info.ValueRenderer(Math.abs(val),keldan_lang) + '&#37;</span>';
        }else if(isNaN(val))
        	return '-';
        else
        	return Kelda.Info.ValueRenderer(val,keldan_lang)+"&#37;";
    };


	this.isbcolumns=[{
		id: 'Name',
		header: keldan_lang_text('category'),
		dataIndex: 'name',
		width: 50,
		align:'left',
		/*
		renderer:function(val) {
				if(val.indexOf('LSS')==0) {
					return val.substring(0,3)+' '+val.substring(3,7)+"<b>"+val.substring(7,val.length)+'</b>';
				}
				var s = val.split(" ");
				if(s[0]==="HFF")
					return s[0]+" "+s[2].substring(2,4)+""+s[2].substring(0,2)+"<b>"+s[1]+"</b>";
				else if(s[0]==="RIKB" || s[0]==='RIKV' || s[0]==='RIKS')
					return s[0]+" "+"<b>"+s[1]+"</b>"+s[2].substring(0,2)+s[2].substring(2,4);
			
		},
		*/
		renderer : function(val) {
			if(val.substring(0,3)=='HFF') {
				val = val.substring(0,3)+" "+val.substring(7,9)+" "+val.substring(5,7)+""+val.substring(3,5);
			}
			return val;
		},
		sortable:true,
		hidden:false
	},{
        id: 'BidYield', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
        header: keldan_lang_text('bidyield'),
        dataIndex: 'bid_yield',
        width: 50,
        align:'right',
        renderer:function(val,p,record){
		if(record.data.daycount <= 1 && record.data.name.indexOf('RIKV')>=0)
			return '-';
		val = val *100;
		if(val===0)
			return '0&#37;';
		else
			return Kelda.Info.ValueRenderer(val,keldan_lang)+"&#37;";
		},
        hidden:false,
        sortable: true
    },{
        id: 'Bid', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
        header: keldan_lang_text('bid'),	
        dataIndex: 'bid',
        width: 50,
        renderer:function(val) {
    		if(isNaN(val) || val===0)
    			return '-';
    		else
    			return Kelda.Info.ValueRenderer(val,keldan_lang);
    	},
        align:'right',
        hidden:false,
        sortable: true
    },{
    	id:'LastYield',
    	header:keldan_lang_text('yield'),
    	align:'right',
    	dataIndex:'last_yield',
    	width:52,
    	renderer:function(val,p,record){
    		if(record.data.daycount <= 0)
    			return '-';
			val = val *100;
			if(isNaN(val) || val===0)
				return '0&#37;';
			else
				return Kelda.Info.ValueRenderer(val,keldan_lang)+"&#37;";
		},
    	sortable:true,
    	hidden:true
    },{
        id: 'Last', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
        header: keldan_lang_text('price'),
        tooltip:keldan_lang_text('last price'),	
        dataIndex: 'last',
        width: 52,
        renderer:function(val) {
    		if(isNaN(val) || val===0)
    			return '-';
    		else
    			return Kelda.Info.ValueRenderer(val,keldan_lang);
    	},
        align:'right',
        //renderer: this.valueRenderer,
        hidden:true,
        sortable: true
    },{
        id: 'Type', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
    	header: keldan_lang_text('type'),	
    	dataIndex: 'instrumentType',
    	width: 10,
    	hidden:true,
    	sortable: false,
    	renderer:function(val) {
        		
        		switch(val) {
        			case 'BONDSINDEXED' :
        				return keldan_lang_text('indexed');
        			case  'BONDS' :
        				return keldan_lang_text('nonindexed');
        			case 'BILLS' :
        				return keldan_lang_text('treasurybills');
        			default:
        				return val;
        		}
        		
        		return val;
        }
    },{
    	id:'YieldCalc',
    	header:keldan_lang_text('yieldcalc'),
    	tooltip:keldan_lang_text('yieldcalctooltip'),
    	dataIndex:'yield',
    	align:'right',
    	width:40,
    	hidden:false,
    	hideable:false,
    	renderer:function(val){
			return Kelda.Info.ValueRenderer(Number(val),'is');
		},
		editor:new Ext.form.NumberField({
			/*allowBlank: true,
			allowNegative: false,
			maxValue: 1000000000,
			decimalSeparator:(keldan_lang=='is'?',':'.'),
			decimalPrecision:3,
			cls:'bonds-yieldcalc',
			allowDomMove:false,
			onFocus:function(){this.setRawValue('');},
			enableKeyEvents:true*/
			allowBlank: true,
			allowNegative: false,
			maxValue: 1000000000,
			cls:'bonds-yieldcalc',
			decimalSeparator:(keldan_lang=='is'?',':'.'),
			decimalPrecision:3,
			selectOnFocus:true,
			onFocus:function(){this.setRawValue('');},
			enableKeyEvents:true
			
    	})
    },{
    	id:'PriceCalc',
    	header:keldan_lang_text('pricecalc'),
    	tooltip:keldan_lang_text('pricecalctooltip'),
    	dataIndex:'price',
    	align:'right',
    	width:40,
    	hidden:false,
    	hideable:false,
    	renderer: function(val){
    		
    		return Kelda.Info.ValueRenderer(Number(val),keldan_lang);
    	},
		editor:new Ext.form.NumberField({
    			allowBlank: true,
    			allowNegative: false,
    			maxValue: 1000000000,
    			cls:'bonds-pricecalc',
    			decimalSeparator:(keldan_lang=='is'?',':'.'),
    			decimalPrecision:3,
    			selectOnFocus:true,
    			onFocus:function(){this.setRawValue('');},
    			enableKeyEvents:true
         })}];
	/*
	
	*/
	this.store = new Ext.data.JsonStore({
		root: 'response',
		autoDestroy:true,
		id : 'isbJsonId',
	    fields: [{name:'instrumentType',convert:function(val,rec) {
	    	if(val=='BONDSINDEXED')
    			return keldan_lang_text('indexed');
    		else if(val=='BONDS')
    			return keldan_lang_text('nonindexed');
    		else 
    			return keldan_lang_text('treasurybills')
	    }},{name:'name'},
	    	{name:'bid',type:'float'},{name:'ask',type:'float'},
	    	{name:'last',type:'float'},{name:'description',type:'string'},
	    	{name:'last_yield',type:'float'},{name:'ask_yield',type:'float'},
	    	{name:'bid_yield',type:'float'},{name:'last_change_pct',type:'float'},
	    	{name:'last_close',type:'float'},{name:'volume',type:'float'},
	    	{name:'basePointChange',type:'float'},{name:'marketOpen',type:'boolean'},
	    	{name:'price',type:'float'},{name:'yield',type:'float'},{name:'daycount',type:'int'}
	    ],
	    proxy: new Ext.data.HttpProxy({
	        //url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"feedconnect/getFeed"
	    	url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"connector/getBondsAndBills"
	    }),
	    groupingField:'instrumentType',
	    sortingInfo:{field:'name',direction:'ASC'}
	});
	var grid = this;
	var view = new Ext.grid.GroupingView( {
		forceFit : true,
		autoFill:true,
        enableRowBody:true,
        scrollOffset:1,
        //showPreview:true,
        getRowClass : function(record, rowIndex, p, store){
			if ((parseInt(rowIndex) % 2) == 0)
				return 'odd-row';

		},
		getGroupField : function() {
			return 'instrumentType';
		},
		showGroupName:false,
		columnsText:keldan_lang_text('columns'),
		sortAscText:keldan_lang_text('sort ascending'),
		sortDescText:keldan_lang_text('sort descending'),
		enableGroupingMenu:false
	});
	this.store.on('load',function(){
		keldan_store_count--;
		if(keldan_store_count==0) {
			Ext.Msg.hide();
			keldan_store_count=-1;
		}
	});
	
	Ext.apply(this,{
		id : 'bondsgrid_'+Math.random()*110,
		stateId:'bondsgrid',
		store : this.store,
	    columns:this.isbcolumns,
	    view:view,
	    autoHeight:true,
	    autoExpandColumn:'YieldCalc'
	   
	});
	this.task = {
    	run:function() {
			/*if(grid)
				grid.store.load();
			*/
			if(grid.loadMask.disable)
				grid.loadMask.disable();
			Ext.Ajax.request({
				url:window.location.protocol+"//"+window.location.hostname+"/"+basePath+"connector/getBondsAndBills",
				success: function(response){
				var obj = Ext.decode(response.responseText);
				var data = obj.response;
				var rec;
				var marketOpen = false;
				for(var i = 0; i < data.length; i++){
					rec = this.store.getById(data[i].name);
					//console.log('instrument is '+data[i].instrumentType);
					if(rec){
					rec.data.oldBid = rec.get('bid');
					rec.set('bid',data[i].bid);
					
					rec.data.oldLast = rec.get('last');
					rec.set('last', data[i].last);
					
					rec.data.old_bid_yield = rec.get('bid_yield');
					rec.set('bid_yield',data[i].bid_yield);
					
					rec.data.old_last_yield =rec.get('last_yield');
					rec.set('last_yield',data[i].last_yield);
					
					rec.set('marketOpen',data[i].marketOpen);
					
					
				}else{
					rec = new this.store.recordType(data[i], data[i].name);
					this.store.add(rec);
				}
				marketOpen = rec.data.marketOpen;
			}
			
			this.bubble(function(){
				if(this.header) {
					if(marketOpen) {
						this.header.removeClass('redlight');
						this.header.addClass('greenlight');
					}else {
						this.header.removeClass('greenlight');
						this.header.addClass('redlight');
					}
				}
			});
			
		 },
		 scope:grid
		});
		keldanCloseStoreMask();
			
		},
		interval: 60000
	};
	//Ext.TaskMgr.start(this.task);
	
	//setTimeout('Ext.TaskMgr.start(isbtask)',60000);
	
	this.on('show',function(comp) {
		Ext.TaskMgr.start(this.task);
	});
	this.on('destroy',function(){
		Ext.TaskMgr.stop(this.task);
	});
	/*
	this.on('beforeedit',function(editObj){
		if(editObj.field=="price" && (isNaN(editObj.record.data.last) || editObj.record.data.last <= 0) )
			return false;
		else if(editObj.field=="yield" && (isNaN(editObj.record.data.last_yield) || editObj.record.data.last_yield <= 0) )
			return false;
	});
	*/
	this.on('afteredit',function(editObj) {
		//pageTracker._trackEvent('Bonds','CalculatorInput',editObj.record.data.name);
		_gaq.push(['_trackEvent', 'Bonds', 'CalculatorInput', editObj.record.data.name]);
		/*
		 * editObj = {
		 * 		grid:the grid
		 * 		record:record being edited
		 * 		field:field name being edited
		 * 		value: value after edit
		 * 		originalValue:value before edit
		 * 		row:grid row index
		 * 		column:grid column index
		 * }
		 */
		if(editObj.field=="price") {
			if(editObj.record.data.name.indexOf('RIKV')>=0) {
				var val =editObj.value;
				var dayc = editObj.record.data.daycount;
				if(val <= 0 || dayc <= 0) {
					editObj.record.set('yield',0);
				}else {
					var y = ((((100/val)-1)/dayc)*360)*100;
					editObj.record.set('yield',y);
					
				}
				editObj.grid.yieldCache[editObj.record.data.name]=y;
				editObj.grid.priceCache[editObj.record.data.name]=val;
				
			}else if(editObj.value!=0){
			  Ext.Ajax.request({
				url:window.location.protocol+"//"+window.location.hostname+"/"+basePath+"feedconnect/getFeed",
				params : {feedName:'getBondYield',
						  instrument:editObj.record.data.description,value:editObj.value},
				success: function(response,opt) {
					//var res = (eval('('+response.responseText+')').yield*100).toFixed(2);
					var res = eval('('+response.responseText+')');
					var y = 0;
					if(res.result == 0)
						y = (res.results.result1*100).toFixed(2);
					this.set('yield',y);
					editObj.grid.yieldCache[editObj.record.data.name]=res;
					editObj.grid.priceCache[editObj.record.data.name]=editObj.value;
					
				},
				failure: function(response,opt) {
					
				},
				scope:editObj.record
			  });
			}else {
				editObj.record.set('yield',0);
			}
		}else if(editObj.field=="yield") {
			if(editObj.record.data.name.indexOf('RIKV')>=0) {
				var val =editObj.value/100;
				var dayc = editObj.record.data.daycount;
				if(val <= 0 || dayc <= 0) {
					editObj.record.set('price',0);
				}else {
					var p = 100/(1+val*dayc/360);
					editObj.record.set('price',p);
					
				}
				editObj.grid.yieldCache[editObj.record.data.name]=val;
				editObj.grid.priceCache[editObj.record.data.name]=p;
			}else if(editObj.value!=0) {
			  Ext.Ajax.request({
				url:window.location.protocol+"//"+window.location.hostname+"/"+basePath+"feedconnect/getFeed",
				params : {feedName:'getBondPrice',
						  instrument:editObj.record.data.description,value:(editObj.value/100).toFixed(4)},
				success: function(response,opt) {
					//var res = eval('('+response.responseText+')').price.toFixed(2);
					var pr = 0;
					var res = eval('('+response.responseText+')');
					if(res.result==0)
						pr = (res.results.result1).toFixed(2);
					this.set('price',pr);
					editObj.grid.priceCache[editObj.record.data.name]=res;
					editObj.grid.yieldCache[editObj.record.data.name]=editObj.value;
			    },
				failure: function(response,opt) {
					
				},
				scope:editObj.record
			  });
			}else {
				editObj.record.set('price',0);
			}
		}
	},this);
	this.store.on('load',function(store,records,options) {
		if(this.loadMask.disable)
			this.loadMask.disable();
		for(i = 0; i < records.length;i++){
			rec = records[i];
			//console.log(this.priceCache[rec.data.name	]+"  "+this.yieldCache[rec.data.name]);
			rec.set('price',this.priceCache[rec.data.name]!=null?this.priceCache[rec.data.name]:0);
			rec.set('yield',this.yieldCache[rec.data.name]!=null?this.yieldCache[rec.data.name]:0);
			rec = records[0];
			if(!rec)return;
			var marketOpen = rec.data.marketOpen;
			this.bubble(function(){
				if(this.header) {
					if(marketOpen) {
						this.header.removeClass('redlight');
						this.header.addClass('greenlight');
					}else {
						this.header.removeClass('greenlight');
						this.header.addClass('redlight');
					}
				}
			})
		};
		if(Ext.Msg.isVisible()) {
			keldan_store_count--;
			Ext.Msg.updateProgress((keldan_fixed_stcount-keldan_store_count)/keldan_fixed_stcount
					,keldan_fixed_stcount-keldan_store_count+(keldan_lang=='is' ? ' af ' : ' of ')+keldan_fixed_stcount);
			if(keldan_store_count==0) {
				Ext.Msg.hide();
				keldan_store_count=-1;
			}
		}
	},this);
	
	
	this.on('cellclick',function(grid,rowIndex,columnIndex,event){
		//var editor = grid.getColumnModel().getCellEditor(columnIndex,rowIndex);
		//editor.startEdit();
		this.fireEvent('celldblclick',grid,rowIndex,columnIndex,event);
		//var rec = grid.getStore().getAt(rowIndex);
		//var n = rec.fields[columnIndex];
	});
	Kelda.Info.BondsGrid.superclass.initComponent.apply(this,arguments);
},
stopPoll : function() {
	Ext.TaskMgr.stop(this.task);
},
startPoll : function() {
	Ext.TaskMgr.start(this.task);
}

});
Ext.reg('Bonds_Child',Kelda.Info.BondsGrid);


Kelda.Info.MarketTabsPanel = Ext.extend(Ext.TabPanel,{
	
	initComponent : function() {
		Ext.apply(this,{
			activeTab:0,
			autoHeight:true
		});
		
		this.on('beforetabchange',function(tpanel,newtab,currentTab){
			/*
			if(newtab.isXType('Bonds_Child')) {
				this.ownerCt.setHeight(this.ownerCt.getSize().height+28);
				//this.ownerCt.ownerCt.setHeight(this.ownerCt.ownerCt.getSize().height-(Ext.isIE7?22:24));
			}else if(currentTab && currentTab.isXType('Bonds_Child')) {
				this.ownerCt.setHeight(this.ownerCt.getSize().height-(Ext.isIE7?26:28));
			}
			*/
			/*
			if(newtab.id=='fruss') {
				console.log('got panel in tabchange');
				
				newtab.cascade(function() {
					if(this.isXType('ISBGP_Child'))
						this.replot();
				});
			}
			*/
		},this);
		Kelda.Info.MarketTabsPanel.superclass.initComponent.apply(this,arguments);
	}
});
Ext.reg('ISBTabsPanel',Kelda.Info.MarketTabsPanel);
Kelda.Info.StocksTabsPanel = Ext.extend(Ext.TabPanel,{
	
	initComponent : function() {
		Ext.apply(this,{
			activeTab:0
		});
		

		Kelda.Info.StocksTabsPanel.superclass.initComponent.apply(this,arguments);
	}
});
Ext.reg('ISSTabsPanel',Kelda.Info.StocksTabsPanel);

Kelda.Info.ISBGraph = Ext.extend(Ext.ux.Flot,{
	initComponent : function() {
		
		this.mystoreIndexed = new Ext.data.JsonStore({
			root: 'response',
			fields: [ 
			          {name:'timestamp',dataIndex:'timestamp'},
			          {name:keldan_lang_text('indexed'),mapping:'indexed',dataIndex:keldan_lang_text('indexed'),type:'float',
			        	  convert:function(v,rec){
			        	  	return v*100;
			          }}
			],
			proxy: new Ext.data.HttpProxy({
				//url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"feedconnect/getFeed"
				url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"connector/getBondGraphData"
			}),
			baseParams : {type:'indexed'}
		});
		this.mystoreNonIndexed = new Ext.data.JsonStore({
			root: 'response',
			fields: [ 
			          {name:'timestamp',dataIndex:'timestamp'},
			          {name:keldan_lang_text('nonindexed'),mapping:'nonindexed',dataIndex:keldan_lang_text('nonindexed'),type:'float',
			        	  convert:function(v,rec){
			        	  	return v*100;
			          }}
			],
			proxy: new Ext.data.HttpProxy({
				//url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"feedconnect/getFeed"
				url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"connector/getBondGraphData"
			}),
			baseParams : {type:'nonindexed'}
		});
		
		Ext.apply(this,{
			stateId:'bondsgraph',
			xaxis: {
				mode:'time',
				ticks:8,
				minTickSize:[1,"month"],
				timeformat:'%y'
			},
			yaxis : {
				ticks:10,
				tickDecimals:2,
				min:0,
				max:10
			},
			series:[],
			colors:["#79bde8","#000000"],
			points: { show: true },
			lines : { show:true},
			hideMode:'offsets',
			selection:{
				mode:null
			}
			

		});
		
		this.mystoreIndexed.on('load',function(store,records,options){
			var seriesIndexed = this.createSeries(this.mystoreIndexed,'timestamp');
			Ext.apply(seriesIndexed[0],{
				clickable:false
			});
			Ext.apply(seriesIndexed[1],{
				clickable:false
			});
			var seriesNonIndexed = this.createSeries(this.mystoreNonIndexed,'timestamp');
			this.ser = [seriesIndexed[0],seriesNonIndexed[0]];
			this.plot(this.ser);
			this.baseRange = this.getRanges();
			this.contextMenu = null;
			if(Ext.Msg.isVisible()) {
				keldan_store_count--;
				Ext.Msg.updateProgress((keldan_fixed_stcount-keldan_store_count)/keldan_fixed_stcount
						,keldan_fixed_stcount-keldan_store_count+' af '+keldan_fixed_stcount);
				if(keldan_store_count==0) {
					Ext.Msg.hide();
					keldan_store_count=-1;
				}
			}
		},this);
		this.mystoreNonIndexed.on('load',function(store,records,options){
			var seriesIndexed = this.createSeries(this.mystoreIndexed,'timestamp');
			Ext.apply(seriesIndexed[0],{
				clickable:false
			});
			Ext.apply(seriesIndexed[1],{
				clickable:false
			});
			var seriesNonIndexed = this.createSeries(this.mystoreNonIndexed,'timestamp');
			this.ser = [seriesIndexed[0],seriesNonIndexed[0]];
			this.plot(this.ser);
			this.baseRange = this.getRanges();
			this.contextMenu = null;
		},this);
		
		this.on('render',function(){
			
			//this.mystoreNonIndexed.load({params:{feedName:'getBondGraphData',bondType:'nonindexed'}});
			//this.mystoreIndexed.load({params:{feedName:'getBondGraphData',bondType:'indexed'}});
			this.mystoreNonIndexed.load({params:{type:'nonindexed'}});
			this.mystoreIndexed.load({params:{type:'indexed'}});
		},this);
		
		
		
		Kelda.Info.ISBGraph.superclass.initComponent.apply(this,arguments);
	},
	getIndexedStore : function() {
		return this.mystoreIndexed;
	},
	getStaticSeries : function() {
		return this.ser;
	},
	replot : function() {
		this.mystoreIndexed.reload();
	}
	
});

Ext.reg("ISBGP_Child",Kelda.Info.ISBGraph);

Kelda.Info.ISBPortlet = Ext.extend(Ext.Panel,{
	initComponent: function() {
	
		this.on('render',function(){
			var vpW = Ext.getCmp('main-viewport').getSize().width; //505 550
			if(vpW > 505)
				vpW = 505;
			Ext.apply(this,{
				preferredWinSize : {
					width:vpW ,
					height:570
				}
			});
			if(Ext.Msg.isVisible()) {
				keldan_store_count--;
				Ext.Msg.updateProgress((keldan_fixed_stcount-keldan_store_count)/keldan_fixed_stcount
						,keldan_fixed_stcount-keldan_store_count+(keldan_lang=='is' ? ' af ' : ' of ')+keldan_fixed_stcount);
				if(keldan_store_count==0) {
					Ext.Msg.hide();
					keldan_store_count=-1;
				}
			}
		});
		
		Kelda.Info.ISBPortlet.superclass.initComponent.apply(this,arguments);
	},
	layout:'fit',
	iconCls:'redlight',
	style:'border-width:0',
	plugins: [Ext.ux.PortletPlugin],
    closeable: true,
    maximizable:false,
    collapsible:true,
    resizeable:false,
    settings: false,
    version:1.0001,
    //autoWidth:true,
    autoHeight:true
    //height:(Ext.isIE7?435:445)
    /*
    listeners : {
		'resize' : {
			fn:function(comp,adjW,adjH,rW,rH) {
				//console.log('resize');
				this.cascade(function(){
					if(this.xtype==="ISBGP_Child") {
						//console.log('in flot');
						if(this.rendered) {
							this.replot();
						}
					}
				});
			}
		},
		'expand' : {
			fn:function(pan) {
			  this.cascade(function(){
				if(this.xtype==="ISBGP_Child") {
					//console.log('in flot');
					if(this.rendered) {
						this.replot();
					}
				}
			});
			}
		}
	}
	*/
	
});
Ext.reg('ISBP',Kelda.Info.ISBPortlet);


Kelda.Info.ICEAbroadGrid = Ext.extend(Ext.grid.EditorGridPanel,{
	
	
	initComponent : function() {
		this.rowActions = keldanNewRowaction(10);
		this.columns=[{
			id: 'Name',
			header: '',
			dataIndex: 'fullName',
			renderer : function(val,p,rec) {
				if(rec.data.name.indexOf("OLD_BOND") >= 0) {
					return '<pre>  - '+keldan_lang_text(rec.data.name)+"</pre>";
				}else {
					return keldan_lang_text(rec.data.name);
				}
			},
			width: (Ext.isIE7?90:85),
			sortable:false,
			menuDisabled:true
			
		},{
            id: 'value', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('value'),	
            dataIndex: 'last',
            align:'right',
            renderer:function(val,p,rec) {
				if(rec.data.name=='EURISK_OFF')
					if(keldan_lang=='is')
						return Kelda.Info.NumberFormat(rec.data.bid,'0.000/i')+"/"+Kelda.Info.NumberFormat(rec.data.ask,'0.000/i')+" kr.";
					else
						return "ISK "+Kelda.Info.NumberFormat(rec.data.bid,'0.000/i')+"/"+Kelda.Info.NumberFormat(rec.data.ask,'0.000/i');
				else if(rec.data.name=='ISCDS')
					return Kelda.Info.ValueRendererNoPrec(val,keldan_lang)+(keldan_lang=='is'?" pt.":" bp.");	
				else
					return Kelda.Info.ValueRenderer(val,keldan_lang);
        	},
            width: 35,
            sortable: false
        },{
            id: 'updated', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('updated'),
            dataIndex: 'lastUpdated',
            align:'right',
            renderer:function(val,p,rec) {
        		if(rec.data.name=='ISCDS_DUMMY') {
        			return '';
        		}else {
        			return Kelda.Info.DateFormat(val,'is');
        			
        			
        		}
        	},
            width: 30,
            hidden:false,
            sortable: false
        },{
            id: 'cat', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('category'),
            dataIndex: 'instrumentMarket',
            /*
            renderer:function(val) {
        		if(val==="BANK_BONDS")
        			return "Verð skuldabréfa gömlu bankanna:";
        		return '';
        	},
        	*/
            width: 30,
            hidden:true,
            sortable: true
        },this.rowActions];
		
		this.store = new Ext.data.JsonStore({
        	root: 'response',
            //idProperty: 'feedId',
        	autoDestroy:true,
            fields: [ {name:'fullName'},{name:'name'},
            	{name:'last',type:'float'},
            	{name:'bid',type:'float'},
            	{name:'ask',type:'float'},
            	{name:'lastUpdated',type:'date',dateFormat:'timestamp'},
            	{name:'instrumentMarket'},{name:'category',type:'string'}
            ],
            //groupingField:'instrumentMarket',
            proxy: new Ext.data.HttpProxy({
                //url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"feedconnect/getFeed"
            	url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"connector/getIceAbroad"
            }),
            sortInfo : {field:'category',direction:'asc'}
        });
		this.store.on('load',function(){
			this.loadMask.disable();
			if(Ext.Msg.isVisible()) {
				keldan_store_count--;
				Ext.Msg.updateProgress((keldan_fixed_stcount-keldan_store_count)/keldan_fixed_stcount
						,keldan_fixed_stcount-keldan_store_count+(keldan_lang=='is' ? ' af ' : ' of ')+keldan_fixed_stcount);
				if(keldan_store_count==0) {
					Ext.Msg.hide();
					keldan_store_count=-1;
				}
			}
		},this);
		this.view = new Ext.grid.GridView( {
			forceFit : true,
			autoFill:true,
            enableRowBody:true,
            scrollOffset:1,
            showPreview:true,
            autoExpandColumn:'fullName',
            getRowClass : function(record, rowIndex, p, store){
				if ((parseInt(rowIndex) % 2) == 0)
					return 'odd-row';

			},
			/*getGroupField : function() {
				return 'instrumentMarket';
			},
			showGroupName:false,
			*/
			columnsText:keldan_lang_text('columns'),
			sortAscText:keldan_lang_text('sort ascending'),
			sortDescText:keldan_lang_text('sort descending'),
			enableGroupingMenu:false
		});
		
		Ext.apply(this,{
			stateId:'iceabrgrid',
    		store : this.store,
    	    columns:this.columns,
    	    view:this.view,
    	    autoHeight:true,
    	    loadMask:{msg:keldan_lang_text('loading'),removeMask:true},
    	    selModel:new Ext.grid.RowSelectionModel(),
    	    plugins:[this.rowActions]
    	});
		var s = this.store;
		this.task = {
	        	run:function() {
					//s.load({params:{feedName:'iceAbroad'}});
					s.load({params:{feedName:'iceAbroad'}});
				},
				interval: 600000
		};
		this.on('render',function(){
			var dislink = Ext.get('iceabr-disc-link');
			dislink.on('click',function(){
				
				if(Ext.Msg.isVisible())
					return;
				 Ext.Msg.show({
					   id:'iceabr-disc',
					   title:keldan_lang_text('legalnotice'),
					   msg: keldan_lang_text('iceabroad-disclaimer'),
					   buttons: Ext.Msg.OK,
					   animEl: this.ownerCt.getEl(),
					   icon: Ext.MessageBox.INFO,
					   closable:false,
					   modal:false
					});
			},this);
			/*
			var grid = this;
			var copy = new Ext.KeyMap(this.getEl(),{
				key:Ext.EventObject.C,
				ctrl:true,
				fn:function() {
					console.log('ctrl-c pressed on iceabroad');
					recs = this.getSelectionModel().getSelections();
					var n = recs.length;
					console.log('number of selected rows : '+n);
				},
				scope:this
			},'keyup');
			*/
			Ext.TaskMgr.start(this.task);
		},this);
		this.on('destroy',function(){
			Ext.TaskMgr.stop(this.task);
		},this);
		
		
    	Kelda.Info.ICEAbroadGrid.superclass.initComponent.apply(this,arguments);
	},
	stopPoll : function() {
		Ext.TaskMgr.stop(this.task);
	},
	startPoll : function() {
		Ext.TaskMgr.start(this.task);
	}
});
Ext.reg('ICEAbroadPortlet_Child',Kelda.Info.ICEAbroadGrid);
Kelda.Info.ICEAbroadPortlet = Ext.extend(Ext.Panel,{
	layout:'fit',
	plugins: [Ext.ux.PortletPlugin],
    closeable: true,
    resizeable:false,
    maximizable:false,
    settings: false,
    collapsible:true,
    nohelp:true,
    listeners : {
    	'render' : {
    		fn : function() {
    			if(Ext.Msg.isVisible()) {
    				keldan_store_count--;
    				Ext.Msg.updateProgress((keldan_fixed_stcount-keldan_store_count)/keldan_fixed_stcount
    						,keldan_fixed_stcount-keldan_store_count+(keldan_lang=='is' ? ' af ' : ' of ')+keldan_fixed_stcount);
    				if(keldan_store_count==0) {
    					Ext.Msg.hide();
    					keldan_store_count=-1;
    				}
    			}
    		}
    	}
    },
    footerCfg: {
		tag:'div',
		cls:'x-panel-footer',
		children:[{
			tag:'pre',
			cls:'footer-text-title iceabroad-footer',
			html:'<a id="iceabr-disc-link" href="#" >'+keldan_lang_text('legalnotice')+'</a>'
		}]
	},	
	version:1.0001,
    width:400,
    autoHeight:true
    //height:(Ext.isIE?200:194)
});
Ext.reg('ICEAbroadPortlet',Kelda.Info.ICEAbroadPortlet);


Kelda.Info.AuctionSecurities = Ext.extend(Ext.grid.GridPanel,{
	
	
	initComponent : function() {
		
		this.columns=[{
			id: 'pub',
			header: keldan_lang_text('publishershort'),
			tooltip: keldan_lang_text('publisher'),
			dataIndex: 'publisher',
			align:'left',
			renderer : function(val,p,rec) {
				return '<a href="'+rec.data.puburl+'" target="_blank"><img src="themes/keldanpremium/images/'+val+'.png"></a>';
			},
			width:Ext.isIE?14:10,
			sortable:false,
			menuDisabled:true
			
		},{
            id: 'type', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('type'),
            tooltip: keldan_lang_text('type'),
            dataIndex: 'type',
            renderer : function(val) {
            	return val.toUpperCase();
            },
            align:'left',
            width: 40,
            sortable: false
        },{
            id: 'name', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('name'),
            tooltip: keldan_lang_text('name'),
            dataIndex: 'name',
            align:'left',
            width: 35,
            hidden:false,
            sortable: false
        },{
            id: 'lastyield', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('lastyield'),
            tooltip: keldan_lang_text('lastyield'),
            dataIndex: 'lastYield',
            width: 30,
            align:'right',
            hidden:false,
            sortable: true
        },{
            id: 'closeDate', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: keldan_lang_text('closeDate'),
            tooltip: keldan_lang_text('closeDate'),
            dataIndex: 'closeDate',
            align:'right',
            renderer:function(val,p,rec) {
        		
        		return Kelda.Info.DateFormatLong(val,'is');
        		
        	},
            width: 40,
            hidden:false,
            sortable: false
        },{
        	id: 'info',
			header: keldan_lang_text('detail'),
			tooltip: keldan_lang_text('detail'),
			dataIndex: 'info',
			align : 'center',
			renderer : function(val,p,rec) {
				return '<a href="'+rec.data.infourl+'" target="_blank"><img src="themes/keldanpremium/images/info.png"></a>';
			},
			width:16,
			sortable:false,
			menuDisabled:true
        }];
		
		this.store = new Ext.data.JsonStore({
        	root: 'response',
            //idProperty: 'feedId',
        	autoDestroy:true,
            fields: [ {name:'publisher'},{name:'type'},
            	{name:'name'},
            	{name:'lastYield'},
            	{name:'puburl'},
            	{name:'infourl'},
            	{name:'closeDate',type:'date',dateFormat:'d.m.Y'}
            ],
            //groupingField:'instrumentMarket',
            proxy: new Ext.data.HttpProxy({
                //url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"feedconnect/getFeed"
            	url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"connector/getSecuritiesAuction"
            }),
            sortInfo : {field:'type',direction:'asc'}
        });
		this.store.on('load',function(){
			this.loadMask.disable();
			if(Ext.Msg.isVisible()) {
				keldan_store_count--;
				Ext.Msg.updateProgress((keldan_fixed_stcount-keldan_store_count)/keldan_fixed_stcount
						,keldan_fixed_stcount-keldan_store_count+(keldan_lang=='is' ? ' af ' : ' of ')+keldan_fixed_stcount);
				if(keldan_store_count==0) {
					Ext.Msg.hide();
					keldan_store_count=-1;
				}
			}
		},this);
		this.view = new Ext.grid.GridView( {
			forceFit : true,
			autoFill:true,
            enableRowBody:true,
            scrollOffset:1,
            showPreview:true,
            autoExpandColumn:'fullName',
            getRowClass : function(record, rowIndex, p, store){
				if ((parseInt(rowIndex) % 2) == 0)
					return 'odd-row';

			},
			/*getGroupField : function() {
				return 'instrumentMarket';
			},
			showGroupName:false,
			*/
			columnsText:keldan_lang_text('columns'),
			sortAscText:keldan_lang_text('sort ascending'),
			sortDescText:keldan_lang_text('sort descending'),
			enableGroupingMenu:false
		});
		
		Ext.apply(this,{
			stateId:'securitiesauctiongrid',
    		store : this.store,
    	    columns:this.columns,
    	    view:this.view,
    	    autoHeight:true,
    	    loadMask:{msg:keldan_lang_text('loading'),removeMask:true},
    	    selModel:new Ext.grid.RowSelectionModel()
    	    
    	});
		var s = this.store;
		this.task = {
	        	run:function() {
					//s.load({params:{feedName:'iceAbroad'}});
					s.load();
				},
				interval: 3600000
		};
		
		
		this.on('render',function(){
			Ext.TaskMgr.start(this.task);
		},this);

		this.on('destroy',function(){
			Ext.TaskMgr.stop(this.task);
		},this);
		
		
    	Kelda.Info.AuctionSecurities.superclass.initComponent.apply(this,arguments);
	},
	stopPoll : function() {
		Ext.TaskMgr.stop(this.task);
	},
	startPoll : function() {
		Ext.TaskMgr.start(this.task);
	}
});
Ext.reg('SecuritiesAuctionPortlet_Child',Kelda.Info.AuctionSecurities);
Kelda.Info.Kalendar = Ext.extend(Ext.grid.GridPanel,{
	
	
	initComponent : function() {
		
		this.columns=[{
			id: 'title',
			header: 'Hvað',
			tooltip: 'Hvað er að gerast.',
			dataIndex: 'title',
			align:'left',
			width:Ext.isIE?44:40,
			sortable:false,
			menuDisabled:true
			
		},{
            id: 'startDate', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: 'Hvenær',
            tooltip: 'Hvenær byrjar atburðurinn',
            dataIndex: 'startDate',
            renderer : function(val,p,rec) {
            	var full = Kelda.Info.DateFormatFullShortNoY(val,'is');
            	if(!rec.data.allDay) {
            		full += ' kl. '+Kelda.Info.DateFormatHour(val,'is');
            	}
            	return HtmlEncode(full);
            },
            align:'left',
            width: 40,
            sortable: false
        },{
            id: 'endDate', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: 'Lýkur',
            tooltip: 'Hvenær lýkur atburðinum',
            dataIndex: 'endDate',
            renderer : function(val,p,rec) {
            	var full = Kelda.Info.DateFormatFullShortNoY(val,'is');
            	if(!rec.data.allDay) {
            		full += ' kl. '+Kelda.Info.DateFormatHour(val,'is');
            	}
            	return HtmlEncode(full);
            },
            align:'left',
            width: 40,
            sortable: false,
            hidden:true
        },{
            id: 'loc', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: 'Hvar',
            tooltip: 'Hvar verður atburðurinn',
            dataIndex: 'loc',
            align:'left',
            width: 40,
            hidden:Ext.get('main-portal').getComputedWidth() < 1280 ? true:false,
            sortable: false
        },{
            id: 'allDay', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
            header: 'Allan dag',
            tooltip: 'Er viðburðurinn í allan dag.',
            dataIndex: 'allDay',
            renderer : function(va) {
            	if(va)
            		return 'já';
            	else
            		return 'nei';
            },
            width: 30,
            align:'right',
            hidden:true,
            sortable: true
        },{
        	id: 'info',
			header: keldan_lang_text('detail'),
			tooltip: keldan_lang_text('detail'),
			dataIndex: 'info',
			align : 'center',
			renderer : function(val,p,rec) {
				return '<a href="'+window.location.protocol+'//'+window.location.hostname+'/dagatal/'+rec.data.id+'" target="_blank"><img src="themes/keldanpremium/images/info.png"></a>';
			},
			width:16,
			sortable:false,
			menuDisabled:true
        }];
		
		this.store = new Ext.data.JsonStore({
        	root: 'data',
            //idProperty: 'feedId',
        	autoDestroy:true,
            fields: [
                {name:'id'},
                {name:'title'},
                {name:'startDate',type:"date",dateFormat:'Y-m-d H:i:s'},
                {name:'endDate',type:"date",dateFormat:'Y-m-d H:i:s'},
            	{name:'allDay',type:'bool'},
            	{name:'loc'},
            	{name:'notes'},
            	{name:'url'},
            	{name:'info'}
            ],
            //groupingField:'instrumentMarket',
            proxy: new Ext.data.HttpProxy({
                //url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"feedconnect/getFeed"
            	url: window.location.protocol+"//"+window.location.hostname+"/"+basePath+"kalendar/getEvents?start=0&limit=5"
            })
            
            
        });
		
		this.store.on('load',function(){
			this.loadMask.disable();
			if(Ext.Msg.isVisible()) {
				keldan_store_count--;
				Ext.Msg.updateProgress((keldan_fixed_stcount-keldan_store_count)/keldan_fixed_stcount
						,keldan_fixed_stcount-keldan_store_count+(keldan_lang=='is' ? ' af ' : ' of ')+keldan_fixed_stcount);
				if(keldan_store_count==0) {
					Ext.Msg.hide();
					keldan_store_count=-1;
				}
			}
			
		},this);
		this.view = new Ext.grid.GridView( {
			forceFit : true,
			autoFill:true,
            enableRowBody:true,
            scrollOffset:1,
            showPreview:true,
            autoExpandColumn:'fullName',
            getRowClass : function(record, rowIndex, p, store){
				if ((parseInt(rowIndex) % 2) == 0)
					return 'odd-row';

			},
			/*getGroupField : function() {
				return 'instrumentMarket';
			},
			showGroupName:false,
			*/
			columnsText:keldan_lang_text('columns'),
			sortAscText:keldan_lang_text('sort ascending'),
			sortDescText:keldan_lang_text('sort descending'),
			enableGroupingMenu:false
		});
		
		Ext.apply(this,{
			stateId:'kalendargrid',
    		store : this.store,
    	    columns:this.columns,
    	    view:this.view,
    	    autoHeight:true,
    	    loadMask:{msg:keldan_lang_text('loading'),removeMask:true},
    	    selModel:new Ext.grid.RowSelectionModel()
    	    
    	});
		
		this.on('mouseover',function(e,t){
			if( (row = this.getView().findRowIndex(t))!== false && (col=this.getView().findCellIndex(t))!==false) {
				var rec = this.getStore().getAt(row);
				var htmlel = this.getView().getCell(row,col);
				var header = this.getColumnModel().getColumnHeader(col);
				var dIdx = this.getColumnModel().getDataIndex(col);
				
				var html = '';
				if(header.indexOf('Hvað') == 0) {
					
					new Ext.ToolTip({
						target:htmlel,	
						html:'<b>'+rec.data.title+'<b>',
						//	cls:'fx-tooltip',
						//		ctCls:'ct-fx-tooltip',
						showDelay:0,
						hideDelay:0,
						trackMouse:true,
						frame:true,
						dismissDelay:0
					});
					
				}else if(header.indexOf('Hvenær') == 0) {
					
					new Ext.ToolTip({
						target:htmlel,	
						html:'<b>'+Kelda.Info.DateFormatFull(rec.data.startDate,'is')+(rec.data.allDay ? '' : ' kl. '+Kelda.Info.DateFormatHour(rec.data.startDate,'is') )+'<b>',
						//	cls:'fx-tooltip',
						//		ctCls:'ct-fx-tooltip',
						showDelay:0,
						hideDelay:0,
						trackMouse:true,
						frame:true,
						dismissDelay:0
					});
					
				}else if(header.indexOf('Hvar') == 0) {
					
					new Ext.ToolTip({
						target:htmlel,	
						html:'<b>'+rec.data.loc+'<b>',
						//	cls:'fx-tooltip',
						//		ctCls:'ct-fx-tooltip',
						showDelay:0,
						hideDelay:0,
						trackMouse:true,
						frame:true,
						dismissDelay:0
					});
					
				}
					
				
				
				
			}
		});
		
		
		var s = this.store;
		this.task = {
	        	run:function() {
					//s.load({params:{feedName:'iceAbroad'}});
					s.load();
				},
				interval: 600000
		};
		
		
		this.on('render',function(){
			Ext.TaskMgr.start(this.task);
		},this);

		this.on('destroy',function(){
			Ext.TaskMgr.stop(this.task);
		},this);
		
		
    	Kelda.Info.Kalendar.superclass.initComponent.apply(this,arguments);
	},
	stopPoll : function() {
		Ext.TaskMgr.stop(this.task);
	},
	startPoll : function() {
		Ext.TaskMgr.start(this.task);
	}
});
Ext.reg('KalendarPortlet_Child',Kelda.Info.Kalendar);
Kelda.Info.AuctionSecuritiesPortlet = Ext.extend(Ext.Panel,{
	layout:'fit',
	plugins: [Ext.ux.PortletPlugin],
    closeable: true,
    resizeable:false,
    maximizable:false,
    settings: false,
    collapsible:true,
    nohelp:true,
	version:1.0001,
    width:400,
    autoHeight:true
    //height:(Ext.isIE?200:194)
});
Ext.reg('SecuritiesAuctionPortlet',Kelda.Info.AuctionSecuritiesPortlet);





