var var_diverror = "";
var var_texterror = "";
var var_id_bio = "";

function show_error(message, posx, posy)
{
	var_diverror = document.getElementById("diverror");
	var_texterror = document.getElementById("texterror");

	var_texterror.innerHTML = message;
	var_diverror.style.left = posx+'px';
	var_diverror.style.top = posy+'px';
	var_diverror.style.display = "block";

	return false;
}

function hide_error()
{
	var_diverror.style.display = "none";

	return false;
}

function resize_me(width, height)
{
	if (document.all)
	{
		if (width == 'auto')
			height = document.body.firstChild.offsetHeight + 45;
		if (width == 'auto')
			width = document.body.firstChild.offsetWidth + 8;
	}
	else
	{
		if (width == 'auto')
			height = document.body.childNodes[1].offsetHeight + 45;
		if (width == 'auto')
			width = document.body.childNodes[1].offsetWidth + 8;
	}

	window.resizeTo(width, height);
}

function show_popup(url, width, height)
{
	var ref = window.open(url, 'popup', 'toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,menuBar=0,width='+width+',height='+height);
	ref.focus();
	return false;
}

function show_popup(url, width, height, scroll)
{
	var ref = window.open(url, 'popup', 'toolbar=0,location=0,directories=0,status=0,scrollbars='+scroll+',resizable=1,menuBar=0,width='+width+',height='+height);
	ref.focus();
	return false;
}

// Les codes d'erreur sont à modifier s'il on désire les utiliser
function is_email(emailStr)
{
	if (emailStr == '')
	{
		return 1;
	}

	var checkTLD = 1;

	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	var emailPat=/^(.+)@(.+)$/;

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	var validChars="\[^\\s" + specialChars + "\]";

	var quotedUser="(\"[^\"]*\")";

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	var atom=validChars + '+';

	var word="(" + atom + "|" + quotedUser + ")";

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null)
	{
		//alert ("Email address seems incorrect (check @ and .'s)");
		return 2;
	}

	var user=matchArray[1];
	var domain=matchArray[2];

	for (i=0; i<user.length; i++)
	{
		if (user.charCodeAt(i)>127)
		{
			//alert("The username contains invalid characters.");
			return 2;
		}
	}
	for (i=0; i<domain.length; i++)
	{
		if (domain.charCodeAt(i)>127)
		{
			//alert("The domain name contains invalid characters.");
			return 2;
		}
	}

	if (user.match(userPat)==null)
	{
		//alert("The username doesn't seem to be valid.");
		return 2;
	}

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
	{
		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255)
			{
				//alert("Destination IP address is invalid!");
				return 2;
			}
		}
		return true;
	}

	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++)
	{
		if (domArr[i].search(atomPat)==-1)
		{
			//alert("The domain name does not seem to be valid.");
			return 2;
		}
	}

	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
	{
		//alert("The address must end in a well-known domain or two letter " + "country.");
		return 2;
	}

	if (len<2)
	{
		//alert("This address is missing a hostname!");
		return 2;
	}

	return true;
}

function redirect(url)
{
	document.location.href = url;
}
