      function getElementByClass(classe)
      {
           var divs = document.getElementsByTagName('table');
           var resultats = new Array();
           for(var i=0; i<divs.length; i++)
                if(divs[i].className == classe)
                     resultats.push(divs[i]);
           return resultats;

      }

	  function cocher_tout(form, checkbox, balise) {

		var cocher = document.getElementById(checkbox).checked;

		if(cocher == true) { action = 1; } else { action = 0; }

		if(balise == "") {
			var Table = document.getElementById(form);
			var Chckbox = Table.firstChild;
		}
		else if(balise == "class") {
			var Table = getElementByClass(form);
			var Chckbox = Table[0].firstChild;
		}
		else if(balise == "id") {
			var Table = document.getElementById(form);
			var Chckbox = Table.firstChild;
		}

		while (Chckbox!=null) {

			if (Chckbox.nodeName=="TBODY") {

				var Chckbox2 = Chckbox.firstChild;

				while (Chckbox2!=null) {

					if (Chckbox2.nodeName=="TR") {

						var Chckbox3 = Chckbox2.firstChild;

						while (Chckbox3!=null) {

							if (Chckbox3.nodeName=="TD") {

								var Chckbox4 = Chckbox3.firstChild;

								while (Chckbox4!=null) {

									if (Chckbox4.nodeName=="INPUT") {

										if (Chckbox4.getAttribute("type")=="checkbox" || Chckbox4.id != checkbox) {

											if(Chckbox4.name == "tab_id[]") {

												Chckbox4.checked = action;
											}
										}
									}

									Chckbox4 = Chckbox4.nextSibling;
								}
							}

							Chckbox3 = Chckbox3.nextSibling;
						}

					}

					Chckbox2 = Chckbox2.nextSibling;
				}
			}

			Chckbox = Chckbox.nextSibling;
		}
	}

