function validation(obj){var index=GetGroupId(obj);if(obj.checked)productChecked[index]+=1;else productChecked[index]-=1}function check(){if(!IsValidBasket()){alert("Vous n'avez pas sélectionné le bon nombre de produits");return false}return true}function GetGroupId(theCheckBox){return theCheckBox.attributes["groupId"].value}function IsValidBasket(){for(i=0;i<mask.length;i++)if(mask[i]!=productChecked[i])return false;return true}function GetTotalSelectedProducts(){var count=0;for(i=0;i<productChecked.length;i++)count+=productChecked[i];return count}function GetSelectionProductType(groupId){var nbToSelect=mask[groupId]-productChecked[groupId];if(nbToSelect>1)return "vos "+nbToSelect+" autres produits";return "votre dernier produit"}function SelectionMessage(){var totalSelectedProducts=GetTotalSelectedProducts();if(totalSelectedProducts==0)return "Commencez votre sélection";var theString="Choisissez ";for(i=0;i<mask.length;i++){if(productChecked[i]>mask[i])return "Vous ne pouvez sélectionner que "+mask[i]+GetProductType(mask[i]);if(productChecked[i]<mask[i])theString+=GetSelectionProductType(i)}return theString}function GetProductType(nbProduct){if(nbProduct>1)return " produits";return " produit"}function CurrentSelection(){var theString="Vous avez sélectionné ";for(i=0;i<mask.length;i++){if(i>0)theString+=" et ";theString+=productChecked[i]+GetProductType(productChecked[i])}return theString}function ValidMessage(){return "Cliquez sur ajouter au panier"}function ManageBasket(theCheckBox){var theString,groupId=GetGroupId(theCheckBox),totalString;theString=CurrentSelection()+"<br/>  ";if(IsValidBasket())totalString="Pour un total de "+totalPrice+"€<br/>Cliquez sur valider ma sélection";else{theString+=SelectionMessage();totalString=""}if(document.getElementById){document.getElementById("selection").innerHTML=theString;document.getElementById("Total").innerHTML=totalString}else if(document.all){document.all["selection"].innerHTML=theString;document.all["Total"].innerHTML=totalString}if(totalString.length>0)setVisibility("Total",true);else setVisibility("Total",false)};
