var cookieEnabled=(navigator.cookieEnabled)? true : false
//if not IE4+ nor NS6+
if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){ 
	document.cookie="testcookie"
	cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)? true : false
}
if (!cookieEnabled) { //if cookies are enabled on client's browser
	alert ("Votre navigateur ne supporte pas les COOKIES. Vous ne pouvez pas accéder à toutes les fonctionnalités sans les activer");
}

function goto_page (formId, params) {
	var eForm = document.getElementById(formId);
	if (eForm) {
		var url = '';
		if (typeof(params) != 'undefined' && params != null && params.length) {
			url += '?'+params; 
			eForm.action = url;
		}
//		alert(url);
		eForm.submit();
	}
}

function local_submit (src) {
	var sForm = src.form;
	if (sForm) {
		var ok = true;
		if (sForm.hasAttribute('before-submit')) ok = ok && window.confirm(sForm.getAttribute('before-submit'));
		if (ok) {
			sForm.action = window.location.href;
			sForm.submit();
		}
	}
}

function logout (msg, reload) {
	var parent = window;
	var i=0;
	while (parent.parent && (++i) < 10) parent = parent.parent;
	if (parent.opener) {
		var pOpener = parent.opener;
		do {
			pOpener = pOpener.parent;
		} while (pOpener.name.length)
		pOpener.focus();
		if (reload) pOpener.location.href = pOpener.location.href;
		if (msg) pOpener.alert(msg);
	} else {
		parent.location.href = parent.location.href;
	}
	parent.close();
}

function parent_reload(href) {
	window.location.href = href;
}

function child_close(msg) {
	logout(msg);
}

function tree_change (src) {
	var parent = src;
	while (parent.parentNode && parent.parentNode.tagName != 'TABLE') parent=parent.parentNode;
	if (parent.parentNode && parent.parentNode.tagName == 'TABLE' && parent.parentNode.id) {
		parent = parent.parentNode;
		var target = document.getElementById(parent.id+'n');
		if (target) {
			switch (target.className) {
			case 'tree_show':
				target.className = 'tree_hide';
				src.setAttribute('src', 'img/switch-maj.png');
				break;
			default:
				target.className = 'tree_show';
				src.setAttribute('src', 'img/switch-min.png');
			}
		}
	}
}

function list_row (src, id, class1, class2) {
	var check = document.getElementById(id);
	if (src.className == class1) {
		if (check) check.checked = true;
		src.className = class2;
	} else {
		if (check) check.checked = false;
		src.className = class1;
	}
}
