String.prototype.trim = function()
{
return this.replace(/(?:^\s+|\s+$)/g, "");
} 


function choixUnique(nom_champs,id_profil_libelle_reponse){
	var champsInput = document.getElementsByTagName("input");
	var nbInput = champsInput.length;
	for(var t=0;t<nbInput;t++){
		if(champsInput[t].name == nom_champs){
			if(champsInput[t].value==id_profil_libelle_reponse){
				champsInput[t].checked = true;
			}
			else{
				champsInput[t].checked = false;
			}
		}
		
	}
}


function removeOptionSelected(hasVisited)
{
	if(hasVisited){	
		var listeDestination = document.getElementById('destination');
	}
	else{
		var listeDestination = document.getElementById('destination2');
	}
	var i;
	for (i = listeDestination.length - 1; i>=0; i--) {
		if (listeDestination.options[i].selected) {
				var nouvelleDestination = document.createElement('option');
				nouvelleDestination.text = listeDestination.options[i].text;
				nouvelleDestination.value = listeDestination.options[i].value;
				nouvelleDestination.id = listeDestination.options[i].id;
				nouvelleDestination.innerHTML = listeDestination.options[i].text;//POUR IE !!!!
				if(hasVisited){	
					var idGroup = listeDestination.options[i].id.replace('E','G');
				}
				else{
					var idGroup = listeDestination.options[i].id.replace('E','GG');
				}
				var listeOriginale = document.getElementById(idGroup);
				listeOriginale.appendChild(nouvelleDestination);
				nouvelleDestination.selected = true;
				listeDestination.remove(i);
			}
			
		}
}


function appendOptionLast(hasVisited)
{
	if(hasVisited){	
		var listeDestination = document.getElementById('destination');
		var listeSource = document.getElementById('source');
	}
	else{
		var listeDestination = document.getElementById('destination2');
		var listeSource = document.getElementById('source2');
	}
	var i;
	for (i = listeSource.length - 1; i>=0; i--) {
		if (listeSource.options[i].selected) {
			var nouvelleDestination = document.createElement('option');
			nouvelleDestination.text = listeSource.options[i].text;
			nouvelleDestination.value = listeSource.options[i].value;
			nouvelleDestination.id = listeSource.options[i].id;
			if(nouvelleDestination.value!=0){
				try{
					listeDestination.add(nouvelleDestination, null);
				}
				catch(ex){
					listeDestination.add(nouvelleDestination); // IE
				}
				
				listeSource.remove(i);
				
			}
			
		}
	}
 
}

function selectChoices(){
	var i, j;
	var listeDestination1 = document.getElementById('destination');
	for (i = listeDestination1.length - 1; i>=0; i--) {
		listeDestination1.options[i].selected = true;
	}
	
	var listeDestination2 = document.getElementById('destination2');
	for (j = listeDestination2.length - 1; j>=0; j--) {
		listeDestination2.options[j].selected = true;
	}
	document.forms.listeDestination.submit();
}





