/**
 * VinaCIS Shop vinacis.core.js Package: Javascript Author: Lieou Kien Suy
 */

Ext.onReady(function() {
	Ext.BLANK_IMAGE_URL = '../ext3/resources/images/default/s.gif';
	Ext.QuickTips.init();
});

Ext.namespace('Ext.VinaCIS');
Ext.namespace('Ext.CP');
Ext.namespace('Ext.CP.Utils');

try {
	console.info('Welcome to CCP');
}
catch (e) {
	// Override console if Doesnot exits
	if (typeof(console) == 'undefined') {
		console = {};
		console.log = function() {
		};
		console.error = function() {
		};
		console.info = function() {
		};
	}
}

Ext.parseMoney = function(val) {
	if (!$CFG.money) {
		$CFG.money = {
			sign: 'Đ',
			decimal: ',',
			thousands: '.',
			number: 2
		};
	}
	return Ext.CP.Utils.formatMoney(val, $CFG.money.number || 0, $CFG.money.decimal || '.', $CFG.money.thousands || ',');
}

Ext.moneyValue = function(str) {
	if (!$CFG.money) {
		$CFG.money = {
			sign: 'Đ',
			decimal: ',',
			thousands: '.',
			number: 2
		};
	}
	str = str.split($CFG.money.decimal || '.').join("").split($CFG.money.thousands || ',').join('.');
	return Number(str);
}

Ext.VinaCIS.preInit = function() {
	Ext.loading = function() {
		var loadingpanel = Ext.get('loading');
		return {
			show: function(text) {
				text = text || 'Loading...';
				loadingpanel.child('#loading-text').update(text);
				loadingpanel.setBottom('0px');
				loadingpanel.setTop('auto');
				loadingpanel.show(true);
			},
			hide: function() {
				loadingpanel.hide(true);
			},
			setText: function(text, color) {
				loadingpanel.child('#loading-text').update(text);
				loadingpanel.child('#loading-text').applyStyles('color: ' + color);
			}
		}
	}
}

Ext.VinaCIS.Init = function() {

}

Ext.override(Ext.dd.DDProxy, {
	startDrag: function(x, y) {
		var dragEl = Ext.get(this.getDragEl());
		var el = Ext.get(this.getEl());

		dragEl.applyStyles({
			border: '',
			'z-index': 2000
		});
		//dragEl.update(el.dom.innerHTML);
		dragEl.addClass(el.dom.className + ' dd-proxy');
	}
});

