if (!Ext.grid.GridView.prototype.templates) {
   Ext.grid.GridView.prototype.templates = {};
}
Ext.grid.GridView.prototype.templates.cell = new Ext.Template(
   '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} x-selectable {css}" style="{style}" tabIndex="0" {cellAttr}>',
   '<div class="x-grid3-cell-inner x-grid3-col-{id}" {attr}>{value}</div>',
   '</td>'
);


Ext.grid.CheckColumn = function(config){

    Ext.apply(this, config);

    if(!this.id){

        this.id = Ext.id();

    }

    this.renderer = this.renderer.createDelegate(this);

};

Ext.grid.CheckColumn.prototype ={
    init : function(grid){
        this.grid = grid;
        this.grid.on('render', function(){
            var view = this.grid.getView();
            view.mainBody.on('mousedown', this.onMouseDown, this);
        }, this);
    },
    onMouseDown : function(e, t){
        if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){
            e.stopEvent();
	        var index = this.grid.getView().findRowIndex(t);
			var record = this.grid.store.getAt(index);
			record.set(this.dataIndex, !record.data[this.dataIndex]);
		}
},
    renderer : function(v, p, record){
        p.css += ' x-grid3-check-col-td'; 
        return '<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'"> </div>';
    }
}; 
$(document).ready(function(){
String.prototype.truncate = function(limit)//match smarty string default truncation
	{
		if (this.length > limit){
			limit = limit -3 ;
			return this.substring(0,limit)+'...';
		}
		else{
			return this;
		}
	};
$("#rolloutContainer .name a, a.loggedInHelp").tooltip({
		showURL: false
});
$("#rolloutContainer #Domains .name a").attr('title','The number of domains shown below and the % of total domains we found linking to this site.');
$("#rolloutContainer #Urls .name a").attr('title','The number of URLs shown below and the % of total URLs we found linking to this site.');
$("#rolloutContainer #Links .name a").attr('title','The number of Links accounted for below and the % of total links to this site.');
$("#rolloutContainer #Photos .name a").attr('title','The total number of image links shown below and the % of total image links to this site.');
$("#rolloutContainer #Dofollow .name a").attr('title','The total number of do_follow links shown below and the % of total links that are do follow links.');
$("#rolloutContainer #Anchor_Texts .name a").attr('title','The total number of unique anchor texts shown below.');
$("#rolloutContainer #Anchor_URLs .name a").attr('title','The total number of unique pages being linked to on this site.');
$("#rolloutContainer #Tlds .name a").attr('title','The total number of unique TLDs (.com, .net, etc.) linking to this site.');
$("#rolloutContainer #Ips .name a").attr('title','The total number of unique IPs associated with external sites linking to this site.');
$("#rolloutContainer #Countries .name a").attr('title','The total number of unique countries associated with external sites linking to this site.');
});
