var regExpBeginning = /^\s+/;
var regExpEnd       = /\s+$/;

// Supprime les espaces inutiles en début et fin de la chaîne passée en paramètre.
function trim(aString) {
    return aString.replace(regExpBeginning, "").replace(regExpEnd, "");
}

// Supprime les espaces inutiles en début de la chaîne passée en paramètre.
function ltrim(aString) {
    return aString.replace(regExpBeginning, "");
}

// Supprime les espaces inutiles en fin de la chaîne passée en paramètre.
function rtrim(aString) {
    return aString.replace(regExpEnd, "");
}

//
function validEmail( email )
{
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return filter.test( trim( email ) );
}

//
function addslashes( str )
{
    // Escapes single quote, double quotes and backslash characters in a string with backslashes
    // version: 810.114
    // discuss at: http://phpjs.org/functions/addslashes
    // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // + improved by: Ates Goral (http://magnetiq.com)
    // + improved by: marrtins
    // + improved by: Nate
    // + improved by: Onno Marsman
    // * example 1: addslashes("kevin's birthday");
    // * returns 1: 'kevin\'s birthday'
    return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
}

// IE hack
if(!Array.indexOf){
    Array.prototype.indexOf = function(obj){
        for(var i=0; i<this.length; i++){
            if(this[i]==obj){
                return i;
            }
        }
        return -1;
    }
}

function counter( elemId, oldPts, newPts )
{
	counterTimeout = setInterval(function()
    {
        if (oldPts >= newPts)
            clearInterval(counterTimeout);
        else
            oldPts++;
        JQ("#"+elemId).html(oldPts);
	},100);
}
