function isEmail(elem)
{
	elem.value = trim(elem.value);
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		return false;
	}
}

function trim(str) 
{
	var resultStr = "";
	
	if (str != null)
	{
		resultStr = trimLeft(str);
		resultStr = trimRight(resultStr);
	}
	
	return resultStr;
} // end Trim

function trimLeft(str) 
{
	var resultStr = "";
	var i = len = 0;
	
	// Return immediately if an invalid value was passed in
	if (str + "" == "undefined" || str == null)	
		return "";

	// Make sure the argument is a string
	str += "";

	if (str.length == 0) 
		resultStr = "";
	else 
	{	
  		// Loop through string starting at the beginning as long as there
  		// are spaces.
		//	  	len = str.length - 1;
		len = str.length;
					
  		while ((i <= len) && (str.charAt(i) == " "))
			i++;
	
   	// When the loop is done, we're sitting at the first non-space char,
 		// so return that char plus the remaining chars of the string.
  		resultStr = str.substring(i, len);
  	}
			
  	return resultStr;
} // end TrimLeft
			
function trimRight(str) 
{
	var resultStr = "";
	var i = 0;
	
	// Return immediately if an invalid value was passed in
	if (str + "" == "undefined" || str == null)	
		return "";

	// Make sure the argument is a string
	str += "";
		
	if (str.length == 0) 
		resultStr = "";
	else 
	{
  		// Loop through string starting at the end as long as there
 		// are spaces.
  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;
			 			
 			// When the loop is done, we're sitting at the last non-space char,
	 		// so return that char plus all previous chars of the string.
	  		resultStr = str.substring(0, i + 1);
	  	}
	  	
	  	return resultStr;
} // end TrimRight


function showHideElement(pIdElem, pStato)
{
	document.getElementById(pIdElem).style.visibility = pStato;}


function xtTraiter(nompage) {
	var toReplace = 'éêèëîïíàâáùüûçñôöó -';
	var goodValues = 'eeeeiiiaaauuucnooo__';

  nompage = trim(nompage);
	nompage = nompage.toLowerCase();
	for (i = 0; i < toReplace.length; i++) {
		while (nompage.indexOf(toReplace.charAt(i)) >= 0) {
			nompage = nompage.replace(toReplace.charAt(i), goodValues.charAt(i)); 
		}
	}
	return nompage;
}
function random(n)
{
	var x;
	x=Math.round(Math.random()*100);
	x%=n;
	return x;
}
