/*
Prototype : mixed StringExist(string needle, array haystack, bool stric)
Description : Cette fonction cherche une valeur dans un tableau
Paramètres :
- string Valeur : Valeur cherchée
- array Tableau : Tableau
- bool Strict : De meme type ou non

Valeur de retour :
- mixed : Emplacement ou false
*/
function ArraySearch(Valeur, Tableau, Strict)
{
    var Strict = !!Strict;
 
    for(var key in Tableau)
	{
        if( (Strict && Tableau[key] === Valeur) || (!Strict && Tableau[key] == Valeur) )
		{
            return key;
        }
    }
 
    return false;
}


/*
Prototype : mixed Explode(string Separation, string Chaine)
Description : Cette fonction cherche une valeur dans un tableau
Paramètres :
- string Separation : Séparation de la chaine
- string Chaine : Chaine

Valeur de retour :
- mixed : Tableau ou null ou false
*/
function Explode(Separation, Chaine)
{
    var emptyArray = { 0: '' };
 
    if ( arguments.length != 2
        || typeof arguments[0] == 'undefined'
        || typeof arguments[1] == 'undefined' )
    {
        return null;
    }
 
    if ( Separation === ''
        || Separation === false
        || Separation === null )
    {
        return false;
    }
 
    if ( typeof Separation == 'function'
        || typeof Separation == 'object'
        || typeof Chaine == 'function'
        || typeof Chaine == 'object' )
    {
        return emptyArray;
    }
 
    if ( Separation === true )
	{
        Separation = '1';
    }
 
    return Chaine.toString().split ( Separation.toString() );
}


/*
Prototype : string Implode(string Separation, array Tableau)
Description : Cette fonction assemble les éléments d'un tableau pour former une chaine
Paramètres :
- string Separation : Séparation de la future chaine
- string Tableau : Tableau

Valeur de retour :
- string : Chaine
*/
function Implode(Separation, Tableau)
{
    return ( ( Tableau instanceof Array ) ? Tableau.join ( Separation ) : Tableau );
}

//Supprime un élément dans un tableau
function SupprElementTableau(tableau,element_suppr,index_debut)
{
	//On cherche l'id du tableau qui contient l'element a supprimer
	var pos_a_suppr = -1;
	for(var i = index_debut; i < tableau.length; i++)
	{
		if(tableau[i] == element_suppr)
		{
			pos_a_suppr = i;
			break;
		}
	}
						
	//On supprime l'id si il est dans le tableau
	if(pos_a_suppr == -1)
	{
		//id pas dans le tableau
	}
	else
	{
		//id dans le tableau, on supprime
		for(var i = pos_a_suppr; i < tableau.length; i++)
		{
			tableau[i] = tableau[i+1];
		}
		tableau.pop();
	}
}