$(document).ready(function(){ 
	  $('#noscript').hide();
      ResultEtEvent();
      $('#credits').nyroModal({width:null,height:null});
      $("#warp-panier").load("panier/confirmAjout.php", function() { ResultEtEvent(); });
      $('.prod a').nyroModal({width:null,height:null,
          endFillContent: function(){
              $("#controle a:first-child").click( function(){  $("#imgProd img").css("top","0px"); $("#controle .actif").attr("class",""); $(this).attr("class","actif");   return false;} );
              $("#controle a:nth-child(2)").click( function(){  $("#imgProd img").css("top","-380px");  $("#controle .actif").attr("class",""); $(this).attr("class","actif"); return false; } );
              $("#controle a:nth-child(3)").click( function(){  $("#imgProd img").css("top","-760px");  $("#controle .actif").attr("class",""); $(this).attr("class","actif"); return false; } );
              $("#controle a:last-child").click( function(){  $("#imgProd img").css("top","-1140px"); $("#controle .actif").attr("class","");  $(this).attr("class","actif"); return false; } );
              $("#addPanier").click(function() {
                         
                  $.get("panier/confirmAjout.php", { 
                  action:"ajout", 
                  l: $(".Ficheproduit ul .ref span").text(), 
                  q: $("#blocAchat .quantite select").val(),
                  t: $("#blocAchat .taille select").val(),
                  p: $("#blocAchat .achat .prix span").text() 
                  
              },
                function(data){
                $("#warp-panier").html(data),
                  $.nyroModalManual({content:data,minWidth:220,width:220,
                    endFillContent: function(){
                    ResultEtEvent();           
                    } 
                  });
                } );

              });
              $("#imgProd").click( function(){  
                  var position = $("#imgProd img").position();
                  if(position.top > -1139) {
                      val = position.top - 380; 
                      $("#controle .actif").attr("class","").next().attr("class","actif");
                      }
                  else {
                        val=0; $("#controle .actif").attr("class","");
                        $("#controle a:first-child").attr("class","actif");
                        }
                  $("#imgProd img").css("top",val);
                  return false;
                   } );
              }
      });
      

});
  
function ResultEtEvent() {
      $(".dlBDC").click(function( ){
          $.get("commande/creaBDC.php", { 
            action:"telecharger",
            i:'info'
            },
            function(data){ // the fonction
            // alert(data); 
              $.nyroModalManual({content:data ,minWidth:567,width:590,minHeight:600 }), ResultEtEvent(); 
                } 
                
               );
               //ResultEtEvent();
               return false;
      } );
      
       $.timer(3000, function (timer) {
       	$(".confirmation").fadeOut(); 
       	timer.stop();
       });
    $(".btnDelete").click( function(){  //ciblre uniquement la warp.
      ref = $(this).attr('name');
        $.get("panier/confirmAjout.php", { 
        action:"suppression", 
        l: ref
        } 
        //callback = recharger le resultat
        
       ,
        function(data){ // the fonction
           $("#warp-panier").html(data), $.nyroModalManual({content:data ,minWidth:220,width:240 }), ResultEtEvent();  } 
            
           );
           //ResultEtEvent();
           return false;
      } );
                      
                      
}

function VerifForm() {  
  $(".ob").css('background','#BFB5B2').css('color','#000');
  var cnt=0;
  $(".ob").each(function() {      
      if( $(this).val() == ""){
          $(this).css('background','#A13D41').css('color','#FFF');
          var c=$(this).attr("id");
          cnt++;
        }
        
  });
  if(cnt!=0) {
    $("p.info").html("Veuillez remplir ce formulaire pour finaliser votre Bon de Commande:<br /><span class='error'>Veuillez remplir tous les champs obligatoires (*).</span>");
    return false; 
  }
  
  
}


/*

if($(this).text() =="")   {
      $("label:has(for)").addClass("error")  ;
      
    }

*/