function centerPositioning(x, y) {
	var theTop = (screen.height/2)-(y/2) - 40;
	var theLeft = (screen.width/2)-(x/2);
	if (navigator.appName == "Netscape") {
		theLocation = "screenY=" + theTop + ",screenX=" + theLeft;
	} else {		
		theLocation = "top=" + theTop + ",left=" + theLeft;
	}
	return theLocation;
}

function integersonly() {
	if (event.keyCode<48||event.keyCode>57)
		return false;
}

function charactersOnly() {
	if (!((event.keyCode > 47 && event.keyCode < 58) || 
		(event.keyCode > 64 && event.keyCode < 90) ||
		(event.keyCode > 96 && event.keyCode < 123)))
		return false;
}

function floatsonly() {
	if (!((event.keyCode>47 && event.keyCode<58) || event.keyCode==46))
		return false;
}

var ahref;
var aname;
var axSize;
var aySize;
var atoolsVisibility;

function thefocus() {
	self.focus();
}

function windowOpen(href, name, xSize, ySize, toolsVisibility) {
	
	if (toolsVisibility == 0) {
		var theWindow = window.open(href, name,
						"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=" + xSize + ",height=" + ySize + "," + centerPositioning(xSize, ySize));
		theWindow.focus();
	} else {
		var theWindow = window.open(href, name,
						"toolbar=no,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=" + xSize + ",height=" + ySize + "," + centerPositioning(xSize, ySize));
		theWindow.focus();
	}
}

function openHelp(helpPage, helpMenu, helpSubMenu) {
	windowOpen("help/main.php?href=" + helpPage + "&menu=" + helpMenu + "&subMenu=" + helpSubMenu, 
					"windowHelpAccrochages",700, 600, 0);
}


function comeBack() {
	window.history.back();
}


function vole(pigeon, voyageur) {
	windowOpen('coucou.php?pigeon='+pigeon+'&voyageur='+voyageur, 'pigeonvoyageur', 500, 300, 0);
}


chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789äëÿüïöâêûîôàèùìòéç~-_@;.:![]";
function symbol(cx,cy)
{
	var t=0;
	t=chars.substring(chars.length-cy,chars.length)+chars.substring(0,chars.length-cy);
	t=t.charAt(cx);
	return t;
}
function crypt(yo, yo2)
{
	var lin=""; var n=0; var c1=0;var c2=0; var t=true;
	

	var text=yo; 
	var cle=yo2;
	if (text=="" || cle=="")
	{
		alert("Merci d'entrer la phrase et la clé.");
		return false;
	}
	cle=passlin(cle,text);
	
	for (n=0;n<text.length;n++)
	{
		c1=chars.indexOf(cle.charAt(n)); 
		c2=chars.indexOf(text.charAt(n));
		if (c2==-1)
		{
			alert("ERREUR:\nImpossible de continuer: La phrase contient des carctères inacceptés!");
			return false;
		}
		else if (c1==-1)
		{
			alert("ERREUR:\nImpossible de continuer: La clé contient des carctères inacceptés!");
			return false;
		}
		else
		{
			lin+=symbol(c1,c2);
		}
	}

	var ou1= 'm';
	var ou2= 'a';
	var ou3= 'i';
	var ou4= 'l';
	var ou5= 't';
	var ou6= 'o';
	document.location.href= ou1+ou2+ou3+ou4+ou5+ou6+':'+ lin;
	
}
function passlin(cle,text)
{
	var lin="";
	for (n=0;n<Math.floor(text.length/cle.length);n++)
	{
		lin+=cle;
	}
	lin+=cle.substring(0,text.length-n*cle.length);
	return lin;
}