var Msg = {
	_msgSource:[
		['session.timeout','Session Timeout! Please re-sign in.'],
		['validation.failed', 'There are errors occurred. Please correct errors before proceeding.'],
		
		['document.del.confirm','Are you sure you want to remove this document?'],
		['window.close.confirm','Do you want to close this session without saving your data?'],
		['report.copy.confirm','Are you sure you want to copy this report?'],
		['report.del.confirm','Are you sure you want to remove this report?'],
		['report.cancel.confirm','Are you sure you want to cancel this report from Landmark Register?'],
		['report.select','Please select a report before proceeding.'],
		
		['insurance.title','Insurance Policies'],
		['insurance.del.confirm','Are you sure you want to remove this policy?']
	],
	
	_msg:{},
	
	_format:function(str,args) {
		args = args || [];
		var result = str
		for (var i = 0; i < args.length; i++){
			//result = result.replace(/%s/, args[i]);
			result = result.replace(new RegExp("\\{" + i + "\\}", "g"), args[i]);
		}
		return result;
	},
	get:function(key, args){
		return this._format(this._msg[key], args);
	}
}

$(function(){
	for (var i=0; i<Msg._msgSource.length; i++){
		Msg._msg[Msg._msgSource[i][0]] = Msg._msgSource[i][1];
	}
});

//alert(Msg._format("current login user:{0}, login time:{1}", ['zhanghuihua','10:01']));
//alert(Msg.get('validation.failed'));
