/* (c) Jean Luc Biellmann - Groupe Ressources - 2010  */

var _FormStatsPages = {
	formId: 'formStatsPages',
	ls : function () {
		_JSON.send('m=stats&c=StatsPages&f=jsonLs',{
			url: 'index.php?json=true&',
			formId: _FormStatsPages.formId,
			onSuccess : function (json) {
				if (json.jsonLs) {
					$('stats').update(json.html);
					var i=1;
					$('stats').select('tbody tr').each(function (tr) {
						tr.addClassName(i++%2 ? 'hl' : 'nothl');
					});
				}
			}
		});

	},
	init : function (e) {
		if ($(_FormStatsPages.formId))
		_JSON.send('m=stats&c=StatsPages&f=jsonInit',{
			url: 'index.php?json=true&',
			formId: '',
			onSuccess : function (json) {
				if (json.jsonInit) {
					if (json.row) {
						//console.debug(json.row);
						if (json.row.y)
							$('y').select('option[value='+json.row.y+']')[0].selected = true;
						if (json.row.m)
							$('m').select('option[value='+json.row.m+']')[0].selected = true;
						if (json.row.d)
							$('d').select('option[value='+json.row.d+']')[0].selected = true;
						if (json.row.s)
							$('s').select('option[value='+json.row.s+']')[0].selected = true;
						if (json.row.l)
							$('l').select('option[value='+json.row.l+']')[0].selected = true;
						_FormStatsPages.ls();
					}
				}
			}
		});
	}
};

Event.observe(window,'load',_FormStatsPages.init);

