﻿
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
};

String.prototype.ltrim = function() {
    return this.replace(/^\s+/,"");
};

String.prototype.rtrim = function() {
    return this.replace(/\s+$/,"");
};
            
var toBoolean = function(value) {

    switch(value) {
        case "1":
        case "true":
        case "yes": 
            return true;
        case "0":
        case "false":
        case "no":
            return false;
        default:
            return Boolean(value); }

};

var logMessage = function(message) {

    if (toBoolean(socioscope.debug)) {
    
        if (window.console) {
            window.console.log(message);
        }
    
    }

};

socioscope = function() {

    var handleFontSizeSwitching = function(size) {
            alert(size);
            //Ext.util.CSS.updateRule('body', 'font-size', size);
            //Ext.util.CSS.refreshCache();
            Ext.util.CSS.swapStyleSheet('font_size', 'css/' + size + '.css');
    };

    return {
    
        debug: false,
        appName: null,
        appSubName: null,
        
        defaultBlankText: '',
        incorrectEmailMessage: '',
        
        left: function(str, n) {

	        if (n <= 0) {
	            return '';
	        } else if (n > String(str).length) {
	            return str;
	        } else {
	            return String(str).substring(0,n);
	        }
	
        },
        
        right: function(str, n) {

            if (n <= 0) {
               return '';
            } else if (n > String(str).length) {
               return str;
            } else {
               var iLen = String(str).length;
               return String(str).substring(iLen, iLen - n);
            }
    
        },
        
        dataOf: function(txt) {
        
            var data = txt;

            // Use ECMA-262 Edition 3 String and RegExp features
            data = data.replace(/[\n\r ]+/g, '');
            data = data.replace(/[\t ]+/g, ' ');

            if (data.charAt(0) == ' ') {
                data = data.substring(1, data.length - 1);
            }
            
            if (data.charAt(data.length - 1) == ' ') {
                data = data.substring(0, data.length - 1);
            }
            
            return data;
            
        },
        
        print: function() {
    
            logMessage('Printing from Socioscope...');    
            window.print();
    
        },
        
        init: function() {

            logMessage('Socioscope started...');
            
        }
    
    };

}();

$(document).ready(function () {

    $('#print_btn').click(function() {
        window.print();
        return false;
    });     
        
    socioscope.init();
    
});



