var box_connexion_state = 0;

box_width = 0;
box_height = 0;

/*############################################*/
/*##  Accordeon de la colonne de gauche  #####*/

	
	
$(document).ready(function(){
	
	   $('.datepicker').datepicker({
                    changeMonth: true,
                    changeYear: true,
                    autoSize: true,
                    dateFormat: 'yy-mm-dd',
                    dayNames:['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
                    dayNamesMin:['Di','Lu','Ma','Me','Je','Ve','Sa'],
                    dayNamesShort:['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
                    monthNames:['Janvier','F&eacute;vrier','Mars','Avril','Mai','Juin','Juillet','Ao&ucirc;t','Septembre','Octobre','Novembre','D&eacute;cembre'],
                    monthNamesShort:['Jan','F&eacute;v','Mars','Avr','Mai','Juin','Juil','Ao&ucirc;t','Sept','Oct','Nov','D&eacute;c']
            });

	$.sAccordion({
		container : 'sAccordion', // ID du container
		activeContent : $("#active_accordion").val(), // Accordeon ouvert par defaut
		speed : 400 // vitesse de l'effet slideToggle ( slow, medium, speed )
	});
						   
	/*############################################*/
	/*##  Ouverture du panier dans la LC  ########*/
	
	$("#icone_expand").live("click", function(){
			
		if($(this).data('close_state'))
		{
			$(this).data('close_state', false);
			$(this).toggleClass('icone_close');
			$("#mon_panier_content").stop(true, true).slideDown(500);
		}
		else
		{
			$(this).data('close_state', true);
			$(this).toggleClass('icone_close');
			$("#mon_panier_content").stop(true, true).slideUp(500);
		}
		return false;
	});
	
	
	$(".btn_add_cart_decomp").click(function(){
		$(this).effect("transfer", {to : "#mon_panier_content", className: 'transfer_element'}, 1000);
		$(this).parent().parent().effect('highlight', {color: '#FFF8AF'}, 2000);
		//activate_clear_btn();
	});
	
	/*########################################################*/
	/*##  Ouverture de la personnalisation du panier  ########*/
	
	
	
	$("#toggle_perso_commande").click(function(){
		if(!$(this).data('close_state'))
		{
			
			$(this).data('close_state', true);
			$(this).toggleClass('perso_opened');
			
			$("#inner_perso_commande").stop(true, true).slideDown(500);
		}
		else
		{
			$(this).data('close_state', false);
			$(this).toggleClass('perso_opened');
			$("#inner_perso_commande").stop(true, true).slideUp(500);
		}
		return false;
	});
	
	/*############################################################*/
	/*##  Ouverture de la Connexion Box dans le header  ##########*/
	
	var original_width  = '';
	$("#btn_connexion").click(function(){
									 
		$("#box_conn_text_1").show();
		$("#box_conn_text_2").hide();
		$("#login_redirect").val("");
		
		if(original_width == '')
		{
			original_width = $(this).width();
		}
		
		if(!$(this).data('cb_close_state'))
		{
			$(this).data('cb_close_state', true);
			$(this).toggleClass('connexion_opened');
			$(this).stop(true, true).animate({width: 170}, 300, function(){
				$("#box_connexion").fadeIn(500);
			});
			
		}
		else
		{
			$(this).data('cb_close_state', false);
			$(this).toggleClass('connexion_opened');
			$("#box_connexion").stop(true, true).fadeOut(500, function(){
				$("#btn_connexion").animate({width: original_width}, 300);
			});
			
		}
		return false;
	});
		
		
	$("#btn_hotbuys").click(function(){	
									 
		$("#box_conn_text_2").show();
		$("#box_conn_text_1").hide();
		$("#login_redirect").val("default.asp?p=gallery&noCategorie=44");
		
		if(original_width == ''){
			original_width = $("#btn_connexion").width();	
		}
		
		if(original_width == '')
		{
			original_width = $(this).width();
		}
		
		if(!$("#btn_connexion").data('cb_close_state'))
		{
			$("#btn_connexion").data('cb_close_state', true);
			$("#btn_connexion").toggleClass('connexion_opened');
			$("#btn_connexion").stop(true, true).animate({width: 170}, 300, function(){
				$("#box_connexion").fadeIn(500);
			});
			
		}
		else
		{
			$("#btn_connexion").data('cb_close_state', false);
			$("#btn_connexion").toggleClass('connexion_opened');
			$("#box_connexion").stop(true, true).fadeOut(500, function(){
				$("#btn_connexion").animate({width: original_width}, 300);
			});
			
		}
		return false;
	});

	/*############################################*/
	/*##  Sous-menus du menu principal  ##########*/

		$("#menu_princ ul li:has(ul)").hover(function(){
			$(this).children('ul').stop(true, true).slideToggle(450);
		}, function(){
			$(this).children('ul').stop(true, true).hide();
		});
	
	/*############################################*/
	/*##  Box connexion  #########################*/
	
		$("#title_connexion").click(function(){
			
			if(box_connexion_state == 0)
			{
				$("#box_connexion").stop(true, true).slideToggle('slow', function(){
					box_connexion_state = 1;					
				});
				$("div.connexion_icon").stop(true, true).toggleClass("arrow_down");
			}
			else
			{
				$("#box_connexion").stop(true, true).slideToggle('slow', function(){
					box_connexion_state = 0;
					$("#login_error_box").hide();
				});
				$("div.connexion_icon").stop(true, true).toggleClass("arrow_down");
				
			}
		});
	
	/*#################################################*/
	/*##  Envoi du formulaire de la box de connexion  #*/
	
		$("#submit_login").click(function(){
		
			if(login())
			{
				$("#box_connexion").stop(true, true).slideToggle('slow', function(){
					box_connexion_state = 0;
				});
				$("div.connexion_icon").toggleClass("arrow_down");
				$("#login_error_box").hide();
			}
		});
		
		$(".text_input").keypress(function(e){
		
			if(e.keyCode == "13")
			{
				//login()
				if(login())
				{
					$("#box_connexion").stop(true, true).slideToggle('slow', function(){
						box_connexion_state = 0;
					});
					$("div.connexion_icon").toggleClass("arrow_down");
					$("#login_error_box").hide();
				}
			}
			else
			{
				//alert('Jello');
				$("#login_error_box").fadeOut(200);
			}
	
		});
		
		function login(){
		
			var hidePrix = 0;
			if (document.formAccessPrivilege.input_mode_vente.checked) hidePrix = 1;
			
			//alert("Login");
			$.ajax({
					type: 'POST',
					url: 'gestion/log.asp',
					data: {hidePrix: hidePrix , user : document.formAccessPrivilege.usager.value, password: document.formAccessPrivilege.password.value, language: "fr"},
					dataType: 'html',
					success: function(html, textStatus){
						//alert("Cool");
						//alert(html);
						
						/*############################################*/
						/*###  Gestion des erreurs de login  #########*/
						
						//alert(html);
						if(html == "0")
						{
							var error_msg = "";
							switch(html)
							{
								case "0":
									if(lang_site == "en"){
										error_msg = "Invalid informations!";	
									} else {
										error_msg ="Les informations que vous avez entr&eacute;es sont incorrectes.";
									}
									break;
							}
							$("#login_error_box").html('<p>'+error_msg+'</p>');
							$("#login_error_box").fadeIn('slow');
							//alert('hello');
							return false;
						}
						else
						{
							$("#box_connexion").stop(true, true).fadeOut('slow', function(){
								box_connexion_state = 0;
							});
							$("div.connexion_icon").toggleClass("arrow_down");
							$("#login_error_box").hide();
							//alert(html);
							if(document.formAccessPrivilege.login_redirect.value == ""){
								if(html == "2"){
									document.location.href = "default.asp?p=commandes";
								} else if(html == "3"){
									document.location.href = "default.asp?p=lstmarchands";
								} else if(html == "1"){
									document.location.href = "default.asp?p=gallery&noCategorie=15";
								} else {
									document.location.reload();
								}
							} else {
								document.location.href = document.formAccessPrivilege.login_redirect.value;	
							}
						}
						
					},
					error: function(xhr, textStatus, errorThrown){
						
						alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
					}
				});
		
		}
		
		$(".text_input").focusin(function(){
			if($(this).val() == $(this).attr('title'))
			{
				$(this).val('');
			}
		});
		
		$(".text_input").focusout(function(){
			if($(this).val() == '')
			{
				$(this).val($(this).attr('title'));
			}
		});
		
		$("#b_ctr_friend .text_input").focusin(function(){
			if($(this).val() == $(this).attr('title'))
			{
				$(this).val('');
			}
			$(this).addClass('input_focus');
		});
		
		$("#b_ctr_friend .text_input").focusout(function(){
			if($(this).val() == '')
			{
				$(this).val($(this).attr('title'));
			}
			$(this).removeClass('input_focus');
		});
		
		$("#b_ctr_friend textarea").focusin(function(){
		
			$(this).addClass('textarea_focus');
		});
		
		$("#b_ctr_friend textarea").focusout(function(){
		
			$(this).removeClass('textarea_focus');
		});
		
		
		
	/*########################################################*/
	/*##  Envoi du formulaire de la box d'envoi à un ami  ####*/
	
		$("#btn_send_friend").click(function(){
		
			if(submitSendFriend())
			{
				$("#send_friend_error_box").hide();
				//document.getElementById('send_friend_form').submit();
				
				$.ajax({
					type: 'POST',
					url: 'includes/send_friend.asp',
					data: {myname:  document.send_friend_form.myname.value, myemail:  document.send_friend_form.myemail.value, friendname:  document.send_friend_form.friendname.value, friendemail:  document.send_friend_form.friendemail.value, content_send_friend:  document.send_friend_form.content_send_friend.value, url:  document.send_friend_form.sendfriend_url.value},
					dataType: 'html',
					success: function(html, textStatus){						
						
						$("#b_ctr_friend").stop(true,true).animate({opacity: 0}, 300, function(){
							$(this).css('left', '-9000px');
							$("#b_black").fadeOut(200);
						});
						
					},
					error: function(xhr, textStatus, errorThrown){
						alert(xhr.responseText)
						alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
					}
				});
			}
		});
		
		function submitSendFriend(){
			var a_error = new Array();
			var myForm = document.getElementById('send_friend_form')
		
			if (trim(myForm.myname.value) == "" || trim(myForm.myname.value.toLowerCase()) == "votre nom") {
				if(lang_site == "en"){
					a_error.push("Insert your name.");	
				} else {
					a_error.push("Entrer votre nom.");
				}
			}
			
			if (!isEmail(myForm.myemail.value)) {
				if(lang_site == "en"){
					a_error.push("Your email address is invalid!");
				} else {
					a_error.push("Votre adresse courriel est invalide.");
				}
			}	
			
			if (trim(myForm.friendname.value) == "" || trim(myForm.friendname.value.toLowerCase()) == "nom de votre ami") {
				if(lang_site == "en"){
					a_error.push("Insert your friend's name!");				
				} else {
					a_error.push("Entrer le nom de votre ami.");
				}
			}
			
			if (!isEmail(myForm.friendemail.value)) {
				if(lang_site == "en"){
					a_error.push("Your friend's email are invalid!");				
				} else {
					a_error.push("L'adresse courriel de votre ami est invalide.");
				}
			}	
			
			if (a_error.length>0){
				$.wt_validation('send_friend_error_box', a_error);
				return false
			}else
				return true;
		}
		
		$(".text_input").keypress(function(e){
				$("#send_friend_error_box").fadeOut(200);
		});
	
	/*####################################################################*/
	/*##  Fonction d'affichage d'erreurs  ################################*/
	
		$.wt_validation = function(error_container, error)
		{
			var i = 0;
			var errors = '<ul>';
			if($.isArray(error))
			{
				while(i < error.length)
				{
					errors += '<li>'+error[i]+'</li>';
					i = i + 1;
				}
			}
			errors += '</ul>';
			$("#"+error_container+"").html(errors).fadeIn('slow');
		}
	
	/*####################################################################*/
	
	$("#cp_deb").keyup(function(e){
		
		if ($("#cp_deb").val().length == 3){
			document.getElementById("cp_fin").focus();
		}
	});
	
	
	/*####################################################################*/
	/*##  Ajustement de la hauteur des <p> en float dans le OU ACHETER ###*/
	
	var produits_total = $('#succursales_resultats p').length;
	for (var produits_compteur = 0; produits_compteur < produits_total; produits_compteur = produits_compteur + 4) {
		var produits_top = 0;
		// on trouve les 4 produits sur la ligne actuelle
		var produits_ligne = $('#succursales_resultats p:eq(' + produits_compteur + '),#succursales_resultats p:eq(' + (produits_compteur + 1) + '),#succursales_resultats p:eq(' + (produits_compteur + 2) + '),#succursales_resultats p:eq(' + (produits_compteur + 3) + ')');
		// pour chaque produit de la ligne, on trouve le plus haut item et on ajuste les 3 autres en consequence
		produits_ligne.each(function(){
			var hauteur = $(this).height();
			if ($(this).height() > produits_top) {
				produits_top = hauteur;
			}
		}).height(produits_top);
	}

	
	
	/*####################################################################*/
	/*##  Envoi du formulaire de la box d'inscription à la newsletter ####*/
	
		$("#btn_nl_particulier").click(function(){
		
			if(submitNLParticulier())
			{
				$("#nl_particulier_error_box").hide();
				$.ajax({
					type: 'POST',
					url: 'mailing/newsletters_upd.asp',
					data: {prenomContact:  document.nl_particulier_form.nl_prenom.value, nomContact:  document.nl_particulier_form.nl_nom.value, courriel:  document.nl_particulier_form.nl_courriel.value, noGroupe:  document.nl_particulier_form.noGroupe.value, langue:  document.nl_particulier_form.langue.value},
					dataType: 'html',
					success: function(html, textStatus){	
		
						$('#b_ctr_newsletter').html(html);
						
					},
					error: function(xhr, textStatus, errorThrown){
						error_response = xhr.responseText
						error_given = 'An error occurred! ' + (errorThrown ? errorThrown : xhr.status);
						error_response += error_given;
						$('#b_ctr_newsletter').html(error_response);
					}
				});
			}
		});
		
		function submitNLParticulier(){
			var a_error = new Array();
			var myForm = document.getElementById('nl_particulier_form')
		
			if (trim(myForm.nl_prenom.value) == "") {
				if(lang_site == "en"){
					a_error.push("Insert your first name!");				
				} else {
					a_error.push("Entrer votre pr&eacute;nom.");
				}
			}
			
			if (trim(myForm.nl_nom.value) == "") {
				if(lang_site == "en"){
					a_error.push("Insert your last name!");				
				} else {
					a_error.push("Entrer votre nom.");
				}
			}
			
			if (!isEmail(myForm.nl_courriel.value)) {
				if(lang_site == "en"){
					a_error.push("Your email address is invalid!");				
				} else {
					a_error.push("Votre adresse courriel est invalide.");
				}
			}	
		
		
			if (a_error.length>0){
				/*alert("error : "+a_error)*/
				$.wt_validation("nl_particulier_error_box",a_error);
				return false
			}else
				return true;
		
		}
		
		$("#btn_nl_marchand").click(function(){
		
			if(submitNLMarchand())
			{
				$("#nl_marchand_box").hide();
				$.ajax({
					type: 'POST',
					url: 'mailing/newsletters_upd.asp',
					data: {prenomContact:  document.nl_marchand_form.nl_prenom_marchand.value, nomContact:  document.nl_marchand_form.nl_nom_marchand.value, courriel:  document.nl_marchand_form.nl_courriel_marchand.value, auto_4:  document.nl_marchand_form.nl_entreprise_marchand.value, auto_1:  document.nl_marchand_form.nl_tel_marchand.value, noGroupe:  document.nl_marchand_form.noGroupe.value, langue:  document.nl_marchand_form.langue.value},
					dataType: 'html',
					success: function(html, textStatus){
						document.getElementById('b_ctr_newsletter').innerHTML = html
					},
					error: function(xhr, textStatus, errorThrown){
						alert(xhr.responseText)
						alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
					}
				});

			}
		});
		
		function submitNLMarchand(){
			var a_error = new Array();
			var myForm = document.getElementById('nl_marchand_form')
		
			if (trim(myForm.nl_entreprise_marchand.value) == "") {
				if(lang_site == "en"){
					a_error.push("Insert your business name!");				
				} else {
					a_error.push("Entrer votre nom d'entreprise.");
				}								
			}			
			
			if (trim(myForm.nl_prenom_marchand.value) == "") {
				if(lang_site == "en"){
					a_error.push("Insert your first name!");				
				} else {
					a_error.push("Entrer votre pr&eacute;nom.");
				}
			}
			
			if (trim(myForm.nl_nom_marchand.value) == "") {
				if(lang_site == "en"){
					a_error.push("Insert your last name!");				
				} else {
					a_error.push("Entrer votre nom.");
				}
			}
			
			if (!isEmail(myForm.nl_courriel_marchand.value)) {
				if(lang_site == "en"){
					a_error.push("Your email address are invalid!");				
				} else {
					a_error.push("Votre adresse courriel est invalide.");
				}
			}
		
			if (a_error.length>0){
				//alert("error : "+a_error)
				$.wt_validation("nl_marchand_box",a_error);
				return false
			}else
				return true;
		}
	
		$("#b_ctr_newsletter .text_input").focusin(function(){
			if($(this).val() == $(this).attr('title'))
			{
				$(this).val('');
			}
			$(this).addClass('input_focus');
		});
		
		$("#b_ctr_newsletter .text_input").focusout(function(){
			if($(this).val() == '')
			{
				$(this).val($(this).attr('title'));
			}
			$(this).removeClass('input_focus');
		});
		
	$("#button_ouacheter").click(function(){
		$("#findsuccursale_form").submit();
		return false
	});
	
	/*############################################*/
	/*##  System de tabs  ########################*/
	
		$("#tabs, .tabs").tabs();
		
		$(".product_tabs").tabs({
			collapsible: true
		});
		
		$("#tabs_rc").tabs();
	
	/*############################################*/
	/*##  Caroussel accueil  #####################*/
	
		$.wt_carrousel();
		
	/*############################################*/
	/*##  Lightbox Send to a friend  #############*/
		
		$("#send_friend_button").click(function(){
			
			$("#content_send_friend").val("");
			$("#sendfriend_url").val(document.location.href);
			
			$.wt_lightbox_friend();
			return false;
			
		});
		
	//##############################################
	//##  Loading de la page Ou acheter  ###########
	
	/*$("#searchCP_submit").click(function(){
		var td_map = $("#td_map");
		var td_loading = $("#ou_acheter_loading");
		var height_td = td_map.outerHeight();
		var td_offset = td_map.offset();
		var td_top = Math.round(td_offset.top) - 40;
		
		if($("#td_map strong").length != 0)
		{
			$("#td_map strong").fadeOut(300, function(){
				td_loading.css({'top': td_top+'px','left':'0'}).html($("#searchCP_submit").attr('title')).fadeIn(500).effect("pulsate", { times: 50}, 2000);
			});
		}
		else
		{
			td_loading.css({'top': td_top+'px','left':'0'}).html($(this).attr('title')).fadeIn(500).effect("pulsate", { times: 50}, 2000);
		}
		
		$("#searchCP_form").submit();
		return false;
	});*/
	
	
	$("#searchCP_submit2").click(function(){
		var td_map = $("#td_map");
		var td_loading = $("#ou_acheter_loading2");
		var height_td = td_map.outerHeight();
		var td_offset = td_map.offset();
		var td_top = Math.round(td_offset.top) - 100;
		
		if($("#td_map strong").length != 0)
		{
			$("#td_map strong").fadeOut(300, function(){
				td_loading.css({'top': td_top+'px','left':'1px'}).html($("#searchCP_submit2").attr('title')).fadeIn(500).effect("pulsate", { times: 50}, 2000);
			});
		}
		else
		{
			td_loading.css({'top': td_top+'px','left':'0'}).html($(this).attr('title')).fadeIn(500).effect("pulsate", { times: 50}, 2000);
		}
		
		$("#searchCP_form").submit();
		return false;
	});
		
	/*######################################################################*/
	/*##  Section Produits  ################################################*/
	
	$(".drawer_toggle").data('o_c', true);
	
	$(".drawer_toggle").click(function(){
		if($(this).data('o_c'))
		{
			$(this).html('- Infos');
			$(this).data('o_c', false);
		}
		else
		{
			$(this).html('+ Infos');
			$(this).data('o_c', true);
		}
		$(this).parent().parent().next().next().find(".produits_specs_drawer").stop(true,true).slideToggle('slow');
		
		return false;
	
	});
	
	/*############################################*/
	/*##  Zoom Lightbox images  ##################*/
	
		$(".image_zoom").click(function(){
			$.wt_lightbox($(this).attr('title'));
			return false;
		});
		
		$("#product_image_zoom").click(function(){
			$.wt_lightbox($(this).parent().find("img:visible").attr('title'));
			return false;
		});
	
	/*############################################*/
	/*##  Gallery de photos de série #############*/
	
	var $counter_z = 20;
	var $counter = 0;
	var $pics = $("#product_image img");
	var $nbr_pics = $pics.length;
	
	//console.log($nbr_pics);
	
	if($nbr_pics > 1){
		
		$nav_box = $("#produits_gallery_nav");
		$nav_box.show();
		$nav_box_list = $("#produits_gallery_nav ul");
		$("#product_image").data("cur_img","image_1");
		
		
		//console.log($("#product_image").data("cur_img"));
		
		$("#product_image img").each(function(){
			$counter_z--;
			$counter++;
			$(this).css("z-index",$counter_z);
			$nav_box_list.append('<li id="image_link_'+$counter+'" target_img="image_'+$counter+'">'+$counter+'</li>');
		});
		
		$("#image_link_1").addClass("current_image_link");
		
		function switch_img(target_image, current_button){
			$cur_image = $("#product_image").data("cur_img");
			
			if(target_image != $cur_image){
				
				var $cur_pic = $("#"+$cur_image);
				var $target_pic = $("#"+target_image);
				
				if(!$cur_pic.is(":animated")){
				
					$target_pic.addClass("cur_image").css("z-index",$cur_pic.css("z-index")-1).show();
					
					$("#produits_gallery_nav ul li.current_image_link").removeClass("current_image_link");
					current_button.addClass("current_image_link");
					
					$cur_pic.removeClass("cur_image").fadeOut(500, function(){
						$target_pic.css("z-index","20");
						$(this).css("z-index",$target_pic.css("z-index")-1)
						$("#product_image").data("cur_img",target_image).end().find("img[class!=cur_image]").hide();
					});
				}
			}
		}
		
		$("#produits_gallery_nav ul li").click(function(){
			$trg_img = $(this).attr("target_img");
			var $cur_button = $(this);
			switch_img($trg_img, $cur_button);
		});
	}
	
	/*######################################################################*/
	/*######################################################################*/
	
	/*############################################*/
	/*##  Section Panier Step 1  #################*/
	
	$(".panier_tableau tbody tr:odd").css("background-color", "#f2f2f2");
	
	/*############################################*/
	/*##  Section Panier Step 2  #################*/
	
	$(".header_adresse").click(function(){
	
		$(".a_w_selected").removeClass('a_w_selected');
		$(this).parent().addClass('a_w_selected');
	
	});
	
	/*############################################*/
	/*##  Section Panier Step 3  #################*/
	
	$("#final_panier_table tr td table tbody tr:even").css("background-color", "#f2f2f2");
	
	/*############################################*/
	/*############################################*/
	
	$(".decompose_article").click(function(event){
		$(this).toggleClass("decompose_article_opened").parent().parent().parent().parent().next(".decomp_sous_table").stop(true,true).slideToggle('slow');
		$(this).parent().parent().toggleClass("decomp_item_full_active");					   		
		event.preventDefault();
	});
	
	
	
	
	createDropDown();
	 
	$(".dropdown_color dt a").click(function(e) {
		e.preventDefault();											 
		$(".dropdown_color dd ul").toggle();
    });

	$(document).bind('click', function(e) {	
       	
		var $clicked = $(e.target);
        if (! $clicked.parents().hasClass("dropdown_color"))
			//e.preventDefault();
			$(".dropdown_color dd ul").hide();
    });

	$(".dropdown_color dd ul li a").click(function(e) {
		e.preventDefault();									   
		var text = $(this).html();
		$(".dropdown_color li").removeClass("active");
		$(this).parent().addClass("active");
        $(".dropdown_color dt a").html(text);
        $(".dropdown_color dd ul").hide();
        var source = $("#source");
        source.val($(this).find("span.value").html());
		display_right_color($(this).find("span.value").html());
    });

	
});

function display_right_color(color_id){
	switch(color_id){
		case "0":
					//Toutes les couleurs
					$(".decomp_container").show();
					break;
		default:	
					$(".decomp_container").hide();
					$(".display_color_"+color_id).show();
					//Selon la couleur sélectionné
					break;	
	}
}

function createDropDown(){

	var source = $("#source");
	var selected = source.find("option[selected]");
	var options = $("option", source);

    $("body").append('<dl id="target" class="dropdown_color"></dl>');
	
	$("#target").append('<dt><a href="#">' + selected.text() + 
						'<span class="value">' + selected.val() + 
						'</span></a></dt>');

	$("#target").append('<dd><ul></ul></dd>');
	
	options.each(function(){
		$("#target dd ul").append('<li><a href="#">' + 
					                $(this).text() + '<span class="value">' + 
				                    $(this).val() + '</span></a></li>');
     });
}

