$(document).ready(
	function () {
		$('a.hndle').bind('click', toggleContent);

                $('#phototheque a[rel*="lightbox"]').lightBox();


                jQuery('#mycarousel').jcarousel();

                $('#attrib1').livequery('change', updateIdAttribute);
                $('#attrib2').livequery('change', updateIdAttribute);

		$('h2.devis').click(function(){
			$(this).next('div').slideToggle("slow");
		});

		var reponse_devis = $("#reponse_devis");
		if (reponse_devis.size() > 0){
			$("h2.devis").html(reponse_devis.html());
		}

	}

);

var updateIdAttribute = function(e)
{

	var id_produit = $('#id').val();
	var id_option_attribute1 = $('#attrib1').val();
	var id_option_attribute2 = ($('#attrib2').length) ? $('#attrib2').val() : 1;



	$.post("ajax/produits.php",
      { action: "getIdAttribute", id_product:id_produit, id_option_attribute1:id_option_attribute1, id_option_attribute2:id_option_attribute2 },

      function (data){
    	  //alert(data.id_prod_attrib +' '+ data.ref +' '+data.prix);

    	  $('#id_prod_attribut').val(data.id_prod_attrib);
    	  $('#ref').html(data.ref);
    	  $('#price_area').html(data.prix);
    	  $('#attrib2_area').html(data.attrib2);
    	  $('#form_panier').html(data.order);
    	  $('#form_caddie').attr("action", data.url);

      },"json"

    );

}



var toggleContent = function(e)
{
	var targetContent = $("#dicr_area");

        //if (targetContent.hasClass("postbox")){
          if (targetContent.css('display') == 'none') {
                  targetContent.slideDown(800);
                  //$(this).children("span").html(" [-]");
          } else {
                  targetContent.slideUp(800);
                  //$(this).children("span").html(" [+]");
          }
        //}

	return false;
};
