if(!Array.indexOf){ Array.prototype.indexOf = function(obj){ for(var i=0; i 0) { document.getElementById('comparebuttonbottom').innerHTML = "Comparer " + selectionLength + " produit(s)"; document.getElementById('comparebuttontop').innerHTML = "Comparer " + selectionLength + " produit(s)"; //document.getElementById('cancelselection').style.display = "inline"; }else{ document.getElementById('comparebuttonbottom').innerHTML = "Cocher pour comparer"; document.getElementById('comparebuttontop').innerHTML = "Cocher pour comparer"; //document.getElementById('cancelselection').style.display = "none"; } } compare = function(action){ selection = getSelection(); query = ""; for (i = 0; i < selection.length; i++){ query += "&selection" + (i + 1) + "=" + selection[i]; } destination = action + "?" + query; if (selection.length == 0 ){ alert("Selectionnez jusqu'à 4 produits"); }else if (selection.length > 4){ alert("Vous pouvez comparer 4 produits au maximum"); }else{ location.href = destination; } } switchFormSection = function(selected){ for (var id = 1; document.getElementById('tab' + id) != null; id++){ tab = document.getElementById('tab' + id); section = document.getElementById('section' + id); tab.className = "off"; section.style.display = "none"; } for (var id = 1; document.getElementById('tab' + id) != null; id++){ tab = document.getElementById('tab' + id); section = document.getElementById('section' + id); if (id == selected){ tab.className = "on"; section.style.display = "block"; section.style.visible = "true"; section.style.visible = "false"; } } } switchFormSection2 = function(selected){ for (var id = 1; document.getElementById('tab' + id) != null; id++){ tab = document.getElementById('tab' + id); section = document.getElementById('section' + id); if (id == selected){ tab.className = "on"; section.style.display = "block"; }else{ tab.className = "off"; section.style.display = "none"; } } } discloseSubmenu = function(id){ submenu = document.getElementById(id); submenuOn = document.getElementById(id + "on"); submenuOff = document.getElementById(id + "off"); if (submenu.style.display == "none"){ submenu.style.display = "block"; submenuOn.style.display = "block"; submenuOff.style.display = "none"; }else{ submenu.style.display = "none"; submenuOn.style.display = "none"; submenuOff.style.display = "block"; } } deleteProduct = function(id){ if (confirm('Ce produit sera supprimé définitivement')){ window.location = "products?action=delete&id=" + id; } } deleteMatch = function(id){ if (confirm('Ce match sera supprimé définitivement')){ window.location = "http://www.ecocompare.com/matches/delete?id=" + id; } } deleteSubrating = function(id){ if (confirm('Ce critère sera supprimé définitivement')){ window.location = "http://www.ecocompare.com/subratings/delete?id=" + id; } } deleteCategory = function(id){ if (confirm('Cette catégorie sera supprimée définitivement')){ window.location = "categories?action=delete&id=" + id; } } deleteArticle = function(id){ if (confirm('Cet article sera supprimée définitivement')){ window.location = "articles?action=delete&id=" + id; } } deleteCompany = function(id){ if (confirm('Cette entreprise sera supprimée définitivement')){ window.location = "companies?action=delete&id=" + id; } } function updateTotalRating(){ total = 0; ratings = 0; for (i = 1; i <=3; i++){ if (document.getElementById("rating" + i + 'enabled').checked == false){ ratings++; total += parseInt(document.getElementById("rating" + i).value); } } if (ratings == 0){ document.getElementById("rating4").value = 0; } document.getElementById("rating4").value = Math.round(total / ratings); } function changeSubrating(ratingId, key){ if (document.getElementById("rating" + ratingId + '-' + key).checked == true){ document.getElementById("precisions" + ratingId + '-' + key).style.display="block"; }else{ document.getElementById("precisions" + ratingId + '-' + key).style.display="none"; } liveRating(ratingId); } function liveRating(id){ for(id=1; id<=3; id++){ total = 0; for (i = 0; document.getElementById("rating" + id + '-' + i) != null; i++){ if (document.getElementById("rating" + id + '-' + i).checked == true){ total += parseInt(document.getElementById("rating" + id + '-' + i + '-points').value); } } if (total > 5){ total = 5; } document.getElementById("rating" + id).value = total; } updateTotalRating(); }