ja.i18n = (function() {
	var readied = []
	return {
		locales: {},
		localeprocessors: [],
		getLocale: function(code) {
			if (!code) code = 'c'
			if (!Object.isString(code)) return code
			code = code.split(/-|_/).join('_')
			if (readied.include(code)) return this.locales[code]
			var locale = Object.clone(this.locales.system)
			var parts = code.split('_')
			code.split('_').each(function(c){
				if (this.locales[c]) locale = Object.extend(locale,this.locales[c])
			},this)
			locale.code = code
			this.localeprocessors.invoke('process',locale)
			this.locales[code] = locale
			readied.push(code)
			return locale
		},
		getSystemLocale: function()  { return this.getLocale() },
		setSystemLocale: function(l) { this.locales.system = this.getLocale(l) }
	}
})()

ja.i18n.localeprocessors.push({
	process: function(locale) {
		if (!locale.holidays) locale.holidays = []
		for (var i = 0; i < locale.holidays.length; i++) {
			locale.holidays[i] = Object.extend({
				condition:function(date){
					return (!this.d || this.d == date.getDate()) && (!this.m || this.m == date.getMonth()+1)
				}
			},locale.holidays[i])
		}
	}
})

ja.i18n.locales.system = {
	weekstartday: 0,
	days:    ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'],
	days3:   ['sun','mon','tue','wed','thu','fri','sat'],
	days1:   ['su','m','tu','w','th','f','sa'],
	months:  ['january','february','march','april','may','june','july','august','september','october','november','december'],
	montsh3: ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],
	ampm:    ['am','pm'],
	holidays: [],
	formats: {
		date: 'yyyy-mm-dd',
		parseDate : 'y-m-d'
	}
}

