/**
 * Cette fonction sert � cr�er un "shortcut" � document.getElementById.
 * @param objectId String
 * @return String
 */
function htmlObj( objectId ){
	return eval("document.getElementById('"+objectId+"')");
}

//Categories
jQuery.fn.loadCategories = function() {
    for ( i = 0; i < categories.length; i++){
        this.addOption( categories[i].CATEGORIE_ID, categories[i].CATEGORIE );
    }
}

//Sous-Categories
jQuery.fn.loadSubCategories = function( catId ) {
    this.removeOption(/./);
    this.addOption( "null", "« Sous-Categorie »" );

    if ( catId != "null" ){
        //Trouver la position du CategorieId dans le Array.
        for ( i = 0; i < categories.length; i++){
            if ( categories[i].CATEGORIE_ID == catId ){
                position = i;
                break;
            }
        }

        this.addOption( "null", "« Votre choix »" );
        for ( i = 0; i < categories[position].SOUS_CATEGORIE.length; i++){
            this.addOption( categories[position].SOUS_CATEGORIE[i].SOUS_CATEGORIE_ID, 
                            categories[position].SOUS_CATEGORIE[i].SOUS_CATEGORIE
            );
        }
        $("#sousCategories").selectOptions( "null", true );
    }
};

//Ajouter une Sous-Categories
jQuery.fn.selectionSubCategories = function( subCatId ) {
    totalofItems =  document.getElementById("sousCategoriesSelection").options.length;
    if ( subCatId != "null" && totalofItems < 6 ){
        this.addOption( 
            subCatId+";"+$('#sousCategories').selectedTexts()+";"+$('#categories').selectedTexts(),
            $('#categories').selectedTexts() + " - " + $('#sousCategories').selectedTexts()
        );
    }
};

//Supprimer une Sous-Categories
jQuery.fn.deleteSubCategories = function( subCatId ) {
    if ( subCatId != "null" ){
        this.removeOption( subCatId );
    }
};