function changeVisibility(id, visible, page) {
	var ajax = new Ajax();
	ajax.doGet('ajaxvisibility.php?id=' + id + '&visible=' + visible + '&page=' + page,writeVisibility,'text');
}

var writeVisibility = function(str){
	var respArr = str.split(',');
    var id = respArr[0];
    var visible = respArr[1];
	var page = respArr[2];
	if (visible == 0) {
		window.document.getElementById('visibility' + id).innerHTML= "<a href='#' onclick='changeVisibility(" + id + ",1, " + page + ");'><img src='images/button_hidden.png' alt='Show?' /></a>";
	} else {
		window.document.getElementById('visibility' + id).innerHTML= "<a href='#' onclick='changeVisibility(" + id + ",0, " + page + ");'><img src='images/button_showed.png' alt='Hide?' /></a>";
	}
}

function showForm(number) {
	document.getElementById('modiform' + number).style.display = "block";
}

function hideForm(number) {
	document.getElementById('modiform' + number).style.display = "none";
}

function popUp(URL, x, y) {
	var top=(screen.height-y)/2;
	var left=(screen.width-x)/2;
	var parameter="toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,width=" + x + ",height=" + y + ",top=" + top + ",left=" + left + ",resizable=no";
	window.open(URL, 'popup', parameter);
}

function confirmLink(theLink,msg)
{
	// Confirmation is not required in the configuration file
	// or browser is Opera (crappy js implementation)
	if (typeof(window.opera) != 'undefined') {
		return true;
	}

	var is_confirmed = confirm(msg);
	if (is_confirmed) {
		window.location = theLink;
	}
}

// verif chaine contenant a->z ou A->Z et 0->9 + "-"
function letternumber(e)
{
	var key;
	var keychar;
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	
	// control keys
	if ((key==null) || (key==0) || (key==8) ||
		(key==9) || (key==13) || (key==27) )
	   return true;
	
	// alphas and numbers
	else if ((("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_").indexOf(keychar) > -1))
	   return true;
	else
	   return false;
}