/*##############################################################################################
##################### JS DES FONCTIONS POUR LA DIV PRIX STOCK LOCAL  ############################# 
/*############################################################################################## */
/*############################################################################################## */
var marquePassion;

/*############################################################################################## */
/* Methode dans la fonction de post chargement d un article en magasin pour remplir le gabarit du div prix-stock-local (avec ou sans eresa)
*/
function openLiveStock(){	   
             loaded = false;
                var func = function (xmlHttp, httpStatus) {
                    oGlobalText = xmlHttp.responseText;
                    if(oGlobalText!=null) {     	                
                        setBlocByHtml('popup-local-price',xmlHttp.responseText);
                        loaded = true;
                    }
                };
                 var oProcess = new IAjaxProcess(urlDivLocalPrice, func);	
                oProcess.run();
}
/*############################################################################################## */ 
/* Remplis les blocs declares dans la div prix stock local avec ou sans eresa par les infos prix recuperees de la methode getPriceStockModele  */
function displayLiveStock(serverDate) {
         if (loaded) {
                    // Remplit bloc photo modele si existe
                    var oHotPict = document.getElementById("hot_pict");
                    if (oHotPict) {
                        if (urlPhotoProduitLocalStock!='') {
                            createElement_img("hot_pictureModel","",urlPhotoProduitLocalStock,"","","",oHotPict);
                        }
                    }
                    //marque passion
                    marquePassion=getBlocHtml('marquePassion');
                    // Remplit bloc marque modele                   
                    setBlocByHtml('hot_brand',getTitleBloc('logoMarqueCourante'));      
                     // Remplit bloc libelle modele
                    setBlocByHtml('hot_libelleModel',libelleModele);	
                    // Remplit bloc numero modele
                    setBlocByHtml('hot_numModel',_modelId);              
                    // Remplit bloc numero article
                    setBlocByHtml('hot_numItem',s.value);
                    // Remplit bloc declinaison article            
                    setBlocByHtml('hot_declinaison', s[s.selectedIndex].text);        
                    // Affichage du logo fin de collection uniquement si l article est en etape 3 ou 7 ou 8
                    if (etape==3 || etape==7 || etape==8) {
                            showBloc('fin-collection');                                                                                         
                     }
                   // Remplit bloc prix
                   if (afficheCartouchePrix=='Y') {
                       // Pour prix rouge
                       if (affichePrixRouge) {
                            changeBlocClass('hot_price','local-price-prixRouge');
                        }                     
                        setBlocByHtml('hot_price',displayPriceArticle());
                    }
                    else{
                        hideBloc('local-price');
                    }
                     // Remplit bloc stock et bloc quantite si eresa possible
                    if (stock==2) {
                        showBloc('hot_libStockIndispo','inline');
                        hideBloc('help-resa');
                        // Affichage du lien pour acceder aux VS
                        getAffichageVsStock();
                    }
                    if (stock==3) {
                        showBloc('hot_libStockProchainement','inline');
                    }
                    if (stock==1) {
                        if (parseInt(valeur_stock) < 2) {
                            setBlocByHtml('hot_stock1',valeur_stock);
                            showBloc('hot_stock_sing','inline');
                        }
                        else {
                            setBlocByHtml('hot_stock2',valeur_stock);
                            showBloc('hot_stock_plur','inline');
                        }

                        // On test si la famille du modele est exclue de la eresa
                        var modelExcludedFromEresa = false;
                        try {
                            for(var k = 0; k < irTab_eresaExcluded.length; k++){
                                if(irTab_eresaExcluded[k] == modeleFamilleId) modelExcludedFromEresa = true;
                            }
                        } catch (e) {}
                        
                         // Remplisssage liste quantite et test affichage bloc quantite et bouton reserver
                         // Si stock pas egal a 0  ET affichage prix produits ami autorisee ET article pas en etape 2 
                         // ET pays autorise reservation sur articles soldes en periode de soldes
                         // ET famille du modele ne fait pas partie des familles exclues de la eresa
                        listQuantity = document.getElementById("liste-quantite");
                        if (listQuantity && !modelExcludedFromEresa) {
                            if ( (marquePassion == 'true' || (marquePassion != 'true' && getSwitchSite('AMI_MAGASIN'))) && getSwitchSite('ACTIVATION_PRIX_MAGASIN') && getSwitchMagasin('ACTIVATION_PRIX_MAGASIN')) {                             
                                if (!isSoldPrice || (isSoldPrice && getSwitchSite('RESERVATION_PERIODE_SOLDE')) ) {
                                        for (var i = 1; i <= valeur_stock; i++) { 
                                            listQuantity.options[listQuantity.options.length] = new Option(i,i);
                                        }                                         
                                      showBloc('book');
                                    }              
                                }
                        }                   
                   }       
                   // Remplit bloc etapes eresa
                    extractEbookingSteps(urlEbookingSteps, 'steps-ebooking', POST_EXTRACT_EBOOKING_STEPS_LOCAL_PRICE_FUNCTION);
                    // Remplit bloc nom du magasin
                    setBlocByHtml('hot_storeLabel1',getEltFromUrl(cookieMagasin, 'magasin'));
                    setBlocByHtml('hot_storeLabel2',getEltFromUrl(cookieMagasin, 'magasin'));
                    setBlocByHtml('hot_storeLabel3',getEltFromUrl(cookieMagasin, 'magasin'));                    
                   // Remplit bloc date et heure serveur
                    setBlocByHtml('hot_infoDate',serverDate.getLiteralDate(getFormatDateHeure()));
                    // Affichage de la div prix stock local 			
                   show_filter('filter');			
                   show_popup('popup-local-price');
                   defineWidth('formBook');
          }
           else {
                    window.setTimeout(function(){displayLiveStock(serverDate);}, 10);
         }
}
/*############################################################################################## */ 
/* Validation du formulaire*/
function checkForAddBasketLiveStock() {
    var qty = document.getElementById('liste-quantite')[document.getElementById('liste-quantite').selectedIndex].value;

    if (parseInt(qty) < 1) alert(libSelectQuantity);
    else addBasket(qty);
}