	
	function AddTableRow(id,mod)
	{
	
		CptAddTableRow = parseInt($('LastId').value) + 1 ;
			
		var row = document.createElement("tr");
		
		row.className = "TableRow0";

		var cell = document.createElement("td");
	
		cell.innerHTML=CptAddTableRow;
		
		row.appendChild(cell);
		
		
		var cell = document.createElement("td");
	
		cell.innerHTML='<img id="separator" src="../images/separteur-colonne.jpg" />';
		
		row.appendChild(cell);
		
	
		var cell = document.createElement("td");
	
		cell.innerHTML='<input type="text" id="nom-'+CptAddTableRow+'" name="nom" />';
		
		row.appendChild(cell);
		
		
		var cell = document.createElement("td");
	
		cell.innerHTML='<img id="separator" src="../images/separteur-colonne.jpg" />';
		
		row.appendChild(cell);
		
		if(mod == 'UpdateCdp')
		{
		var cell = document.createElement("td");
	
		cell.innerHTML='<input type="text" id="cpt-'+CptAddTableRow+'" name="cpt" />';
		
		row.appendChild(cell);
		}
		else
		{
		var cell = document.createElement("td");
	
		cell.innerHTML='<select id="categorie-'+CptAddTableRow+'" name="categorie" /><option value="1">habitation</option><option value="2">locaux-commerciaux</option></select>';
		
		row.appendChild(cell);
		}
		
		var cell = document.createElement("td");
	
		cell.innerHTML='<img id="separator" src="../images/separteur-colonne.jpg" />';
		
		row.appendChild(cell);
		
		
		var cell = document.createElement("td");
	
		if(mod == 'UpdateCdp')
		{
		cell.innerHTML='<input type="button" value="Valider" onclick="InsertUpdateDb(\'Insert\',\''+CptAddTableRow+'\',\'nom-'+CptAddTableRow+'\',\'cpt-'+CptAddTableRow+'\');" />';
		}
		else
		{
		cell.innerHTML='<input type="button" value="Valider" onclick="InsertUpdateDb(\'Insert\',\''+CptAddTableRow+'\',\'nom-'+CptAddTableRow+'\',\'categorie-'+CptAddTableRow+'\');" />';
		}
		
		row.appendChild(cell);
				
		FinInsert(row,id);
		
	}
	
	function FinInsert(row,id)
	{
		document.getElementById(id).appendChild(row);
		
		$('LastId').value = CptAddTableRow;

		new Effect.ScrollTo('ScrollToBottom',{duration:1});
	}

	function InsertUpdateDb(mod,id,nom,param)
	{
		/*if(mod=="Insert")
		{
			var reg1=new RegExp("[categorie]","g");
	
			if(param.match(reg1) && mod=="UpdateSubCat")
			{
			idSelect = document.getElementById(param);
	
			SelectedOption = idSelect.options[idSelect.selectedIndex].value;
			
			document.location = 'InsertUpdateDb.php?mod='+mod+'&id='+id+'&nom='+$(''+nom+'').value+'&param='+SelectedOption+'';
			}
			else
			document.location = 'InsertUpdateDb.php?mod='+mod+'&id='+id+'&nom='+$(''+nom+'').value+'&param='+$(''+param+'').value+'';
			
		}
		else
		{*/
			var reg1=new RegExp("[categorie]","g");
	
			if(param.match(reg1) && mod=="UpdateSubCat")
			{
			idSelect = document.getElementById(param);
	
			SelectedOption = idSelect.options[idSelect.selectedIndex].value;
			
			document.location = 'InsertUpdateDb.php?mod='+mod+'&id='+id+'&nom='+$(''+nom+'').value+'&param='+SelectedOption+'';
			}
			else
			document.location = 'InsertUpdateDb.php?mod='+mod+'&id='+id+'&nom='+$(''+nom+'').value+'&param='+$(''+param+'').value+'';
		
				//new Ajax.Updater('update', 'InsertUpdateDb.php?mod='+mod+'&id='+id+'&nom='+$(''+nom+'').value+'&param='+SelectedOption+'');
		//new Ajax.Updater('update', 'InsertUpdateDb.php?mod='+mod+'&id='+id+'&nom='+$(''+nom+'').value+'&param='+$(''+param+'').value+'');
		
		//}

	}
	
	
	/*
	*
	* APPEL D'UN FICHIER VIA AJAX
	*
	* @Url				Le fichier appelé par l'AJAX
	* @champRetour		L'ID du div dans lequel affiché le résultat du traitement
	*
	***************************************************************************************/
	function urlAjax (Url, champRetour) {
		var requeteAjax	= new Ajax.Updater(	champRetour, Url);
	}
	
	/*
	*
	* APPEL D'UN FICHIER VIA AJAX AVEC UN EFFET DE "YELLOW FADE" A LA FIN
	*
	* @Url				Le fichier appelé par l'AJAX
	* @champRetour		L'ID du div dans lequel affiché le résultat du traitement
	* @couleurFlash		La couleur du "Flash" au format Hexa (#FF0055)
	*
	***************************************************************************************/
	function urlAjaxInfosFin (Url, champRetour, couleurFlash) {
		var requeteAjax	= new Ajax.Updater(	champRetour, Url, {
															onSuccess:function () {
																Fat.fade_element(champRetour, '15', '1500', couleurFlash);
															}
															});
	}

	/*
	*
	* Affiche / masque un div à chaque appel Ajax afin de montrer à l'utilisateur que 
	* quelquechose se passe !
	*
	**************************************************************************************/
	var myGlobalHandlers = {
		onCreate: function(){
			Element.show('systemWorking');
		},

		onComplete: function() {
			if(Ajax.activeRequestCount == 0){
				Element.hide('systemWorking');
			}
		}
	};

	Ajax.Responders.register(myGlobalHandlers);
