
// Vide une liste SELECT
function clearSelect(elmtID) {
	var selectLst = document.getElementById(elmtID);
    if (selectLst) {
      for (loop = selectLst.childNodes.length -1; loop >= 0 ; loop--) {
        selectLst.removeChild(selectLst.childNodes[loop]);
      }
    }
}

// Ajout un élement à une liste SELECT
function appendOptionInSelect(elmtIDtarget, optionValue, optionDesc, toSelectOptionCreated) {
	// Set the optional parameter if needed
	if ( (typeof toSelectOptionCreated == 'undefined') || (toSelectOptionCreated == 'undefined') ) {
		toSelectOptionCreated = false;
   	}
   	
	var selectLst = document.getElementById(elmtIDtarget);
	if (selectLst) {
	    var opt;
	    opt = document.createElement("option");
	    opt.setAttribute("value",optionValue);
	    var optText = document.createTextNode(optionDesc);
	    opt.appendChild(optText);
	    selectLst.appendChild(opt);
		if(toSelectOptionCreated==true){
   			selectLst.selectedIndex=selectLst.length-1;
		}
	}
}

// Supprime un élement d'une liste SELECT depuis sa propriété 'value'
function deleteOptionInSelect(elmtIDtarget, optionValue) {
	var selectLst = document.getElementById(elmtIDtarget);
    if (selectLst) {
		for (loop = selectLst.childNodes.length -1; loop >= 0 ; loop--) {
      		if(selectLst.childNodes[loop].value == optionValue){
        		selectLst.removeChild(selectLst.childNodes[loop]);
        		return;
      		}
		}
    }
}


// Update DESC d'un élement à une liste SELECT depuis sa propriété 'value'
function updateOptionInSelect(elmtIDtarget, optionValue, optionDesc, toSelectOptionUpdated) {
	// Set the optional parameter if needed
	if ( (typeof toSelectOptionUpdated == 'undefined') || (toSelectOptionUpdated == 'undefined') ) {
		toSelectOptionUpdated = false;
   	}

	var selectLst = document.getElementById(elmtIDtarget);
    if (selectLst) {
		for (loop = selectLst.childNodes.length -1; loop >= 0 ; loop--) {
      		if(selectLst.childNodes[loop].value == optionValue){
      			selectLst.childNodes[loop].text=optionDesc;
				//selectLst.childNodes[loop]=new Option(optionDesc, optionValue, false, false);
      			if(toSelectOptionUpdated==true){
      				selectLst.selectedIndex=loop;
      			}
        		return;
      		}
		}
    }
}

/* Cache tous les DIV - Used in ajax_categoryactions.js */ 
function hideAllCategorySectionDIV()
{
	// Category
	hideDIV('createCategoryDIV');
	hideDIV('showEditCategoryDIV');

	//Section1
	hideDIV('createSection1DIV');
	hideDIV('showEditSection1DIV');

	//Section2
	hideDIV('createSection2DIV');
	hideDIV('showEditSection2DIV');

	//Section3
	hideDIV('createSection3DIV');
	hideDIV('showEditSection3DIV');
}


/* Cache tous les DIV USER PRICE - Used in ajax_userpriceactions.js */ 
function hideAllUserPriceDIV()
{
	hideDIV('createUserPriceDIV');
	hideDIV('showEditUserPriceDIV');
}

/* Cache tous les DIV USER PRO PRICE - Used in ajax_userpropriceactions.js */ 
function hideAllUserProPriceDIV()
{
	hideDIV('createUserProPriceDIV');
	hideDIV('showEditUserProPriceDIV');
}

