﻿var Helpers = {};

Helpers.DisableAppletPrinting = function() {
	var html = '<PARAM NAME="printbuttons" VALUE="false"> ' +
	    '<PARAM NAME="printkeys" VALUE="false"> ' +
	    '<PARAM NAME="printmenus" VALUE="false"> ' +
	    '<PARAM NAME="printdocumentallowed" VALUE="false"> ' +
	    '<PARAM NAME="printrangeallowed" VALUE="false"> ' +
	    '<PARAM NAME="printvisibleallowed" VALUE="false"> ' +
	    '<PARAM NAME="printstickymenus" VALUE="false"> ' +
	    '<PARAM NAME="printselectedallowed" VALUE="false"> ' +
	    '<PARAM NAME="printwithusersettings" VALUE="false"> ' +
	    '<PARAM NAME="printoriginalsizeallowed" value="false"> ' +
	    '<PARAM NAME="printheader" VALUE="false">';
	    
	return html;
};

Helpers.LinkToOpenDocumentWithoutDaeja = function(document_id) {
    return 'document_view.aspx?document_id=' + document_id;
};

// This code patches CheckboxSelectionModel so clicking a row doesn't deselect all
Ext.override(Ext.grid.CheckboxSelectionModel, {
    onMouseDown: function(e, t) {
        if (this.checkOnly && !(e.button === 0 && t.className == 'x-grid3-row-checker')) {
            return;
        }
        
        e.stopEvent();        
        
        var row = e.getTarget('.x-grid3-row');
        
        if (row) {
            var index = row.rowIndex;
            
            if (this.isSelected(index)) {
                this.deselectRow(index);
            } else {
                this.selectRow(index, true);
            }
        }
    }
});
