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=0,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;
}

/**
 * Replace une chaine
 * 
 * @author Theodor Zoulias, http://simon.incutio.com/archive/2006/01/20/escape#comment14
 * @param string
 * @return string
 */
function str_replace(search, replace, subject)
{
	return subject.replace(RegExp(encodeRE(replace), 'g'), encodeRE(replace));
}

/**
 * Escape Regular Expression
 * 
 * @author Theodor Zoulias, http://simon.incutio.com/archive/2006/01/20/escape#comment14
 * @param string
 * @return string
 */
function encodeRE(string)
{ 
	return string.replace (/([.*+?^${}()|[\]\/\\])/g, '\\$1');
}
