/* (c) 2009 - Jean Luc BIELLMANN */

var _Main = {
	topOfThePage : function () {
		$('content').scrollTop=0;
	},
	disableselect : function () {
		return false;
	},
	err : function (mess) {
		_Popup.on(_Lang.tr('Error'),mess);
		return false;
	},
	warn : function (mess) {
		_Popup.on(_Lang.tr('Warning'),mess);
	},
	info : function (mess) {
		_Popup.on(_Lang.tr('Info'),mess);
	},
	kwsInit : function (e) {
		$('kws').value = 'Rechercher';
		$('kws').style.color = 'rgb(120,120,100)';
	},
	kwsClick : function (e) {
		$('kws').value = '';
		$('kws').style.color = 'rgb(0,0,128)';
	},
	kwsBlur : function (e) {
		$('kws').style.color = 'rgb(120,120,100)';
		if ($('kws').value.length == 0)
			_Main.kwsInit();
	},
	startup : function () {
		var menus = $$('.menu a');
		var pages = menus.pluck('href').invoke('replace',/.*index.php\?p=([a-zA-Z0-9]+).*/,'$1');
		if (!document.location.href.match(/.*index.php\?p=([a-zA-Z0-9]+).*/)) {
			curPage = 'Accueil';
		} else {
			//var newLocation = document.location.href;
			var curPage = document.location.href.replace(/.*index.php\?p=([a-zA-Z0-9]+).*/,'$1');
console.debug(curPage);
			if (curPage.length==0)
				curPage = 'Accueil';
		}
console.debug(pages);
		pos = pages.indexOf(curPage);
console.debug(pos);
		if (pos!=-1) {
			$(menus[pos]).addClassName('curMenu');
			_Cookie.set('lastLocation',pos);
		}
			
		_Main.showFooter();
		Event.observe(window,'resize',_Main.showFooter);
	},
	showFooter : function (e) {
			$('contentFooter').show();
		if ($('content').scrollHeight>$('content').offsetHeight)
			$('contentFooter').show();
		else
			$('contentFooter').hide();
	},
	prn : function (pagename) {
		print();
		//location.href = 'index.php?p='+pagename+'&f=prnFrame';
		//window.open('index.php?p='+pagename+'&f=prnFrame','Impression','');
	}
};

