
var browser = {
    IE: !!(window.attachEvent && !window.opera) ? true : false,
    Opera: !!window.opera ? true : false,
    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1 ? true : false,
    Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1 ? true : false,
    MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) ? true : false,
    Safari: !!navigator.userAgent.match(/Apple.*Safari/) ? true : false
}

$(document).ready(function(){  

     $(".pack").click(function () { 
     
     	$(this).addClass("pack_on");
     	$(".fiche").removeClass("fiche_on");
     	$(".accessoires").removeClass("accessoires_on");
     	
     	 $(".content").slideUp();
     	 $("#content_1").slideDown();   
     });  
     $(".fiche").click(function () { 
     
     	$(this).addClass("fiche_on");
     	$(".pack").removeClass("pack_on");
     	$(".accessoires").removeClass("accessoires_on");
     	
     	 $(".content").slideUp();
     	 $("#content_2").slideDown();   
     });  
     $(".accessoires").click(function () { 
     
     	$(this).addClass("accessoires_on");
     	$(".fiche").removeClass("fiche_on");
     	$(".pack").removeClass("pack_on");
     	
     	 $(".content").slideUp();
     	 $("#content_3").slideDown();
     });  
     
     $("#v1").click(function () { 
     
     	$(".cadre_img2").hide();
     	$(".cadre_img3").hide();
     	$(".cadre_img1").show();
     	$("#v1").fadeTo("speed", 1);
     	$("#v2").fadeTo("speed", 0.33);
     	$("#v3").fadeTo("speed", 0.33);
     });  

     if ($("#pro_vignette2").length > 0)
     {
         $("#v2").click(function () {
            $(".cadre_img1").hide();
            $(".cadre_img3").hide();
            $(".cadre_img2").show();
            $("#v1").fadeTo("speed", 0.33);
            $("#v2").fadeTo("speed", 1);
            $("#v3").fadeTo("speed", 0.33);
         });
     }

     if ($("#pro_vignette3").length > 0)
     {
         $("#v3").click(function () {
            $(".cadre_img1").hide();
            $(".cadre_img2").hide();
            $(".cadre_img3").show();
            $("#v2").fadeTo("speed", 0.33);
            $("#v1").fadeTo("speed", 0.33);
            $("#v3").fadeTo("speed", 1);
         });
     }

 id_i=1;
      
 function getWithspanSetwith( id1, id2){

var larg_img = 0;
var min_width = 150;

	if(browser.IE){
		var larg_img = document.getElementById(id1).clientWidth;
  } else {
  		var larg_img = document.getElementById(id1).offsetWidth;
  }
  var larg_txt = 560 - larg_img;
  
  
  if( larg_txt < min_width ){ 
  	document.getElementById(id2).style.margin="5px 0 0 10px";
  } else {
 	document.getElementById(id2).style.width=larg_txt+"px";
  	$(id2).css({width:larg_txt+"px"});
  }

}

while($(".desc")){
 if(document.getElementById("img_pack"+id_i) == null) {  break; }
	getWithspanSetwith("img_pack"+id_i,"desc"+id_i);
	id_i++;
}    
     
  });
  
 
