function equalHeight(columns) {
    tallest = 0;
    columns.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    columns.height(tallest);
}

$(document).ready(function(){
						   
			if($(".paiement_final form")[0]){
			$(".paiement_final form").submit()
			}			   
			if($(".so_colissimo form")[0]){
			$(".so_colissimo form").submit()
			}			   
			
			$.datepicker.regional['fr'] = {
				closeText: 'Fermer',
				prevText: '&#x3c;Préc',
				nextText: 'Suiv&#x3e;',
				currentText: 'Courant',
				monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
				'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
				monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun',
				'Jul','Aoû','Sep','Oct','Nov','Déc'],
				dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
				dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
				dayNamesMin: ['Di','Lu','Ma','Me','Je','Ve','Sa'],
				weekHeader: 'Sm',
				dateFormat: 'dd/mm/yy',
				firstDay: 1,
				isRTL: false,
				showMonthAfterYear: false,
				yearSuffix: ''};
				$.datepicker.setDefaults($.datepicker.regional['fr']); 
						   	
			equalHeight($(".box"));			
			equalHeight($(".artbox"));

			$(".text_rapidsearch, .memotext").click(function(){$(this).val('')});

			$('a[rel*=facebox]').facebox();
			
			// COMPTE CLIENT
			$("#log_client").hide();
         	$(".connect").mouseover(function(){$("#log_client").show();});
					$("#menu, #minipanier, #rightcol, #logo, .rapid_search, .insc_new, .backtohome, #menu_boutique, #leftcolboutique, #contenu_boutique, #fullcol, .illus01, .illus02, #top").mouseover(function(){$("#log_client").hide();});
			
			//PANIER MINI
			$("#minipanier_details").hide();
         	$(".openpanier").mouseover(function(){$("#minipanier_details").show();});
			$("#menu, #logboutique, #rightcol, #logo, .rapid_search, .insc_new, .backtohome, #menu_boutique, #leftcolboutique, #contenu_boutique, #fullcol").mouseover(function(){$("#minipanier_details").hide();});
			$("#liste_art").click(function(){$("#minipanier_details").hide();});
			
			//hint fdp
			$("#fdpspecialdiv").hide();
			$("#fdpspecial").toggle(function(){$("#fdpspecialdiv").slideDown();},
									 function(){$("#fdpspecialdiv").slideUp();});	
			$("#panier, #fdpspecialdiv, #seen").click(function(){$("#fdpspecialdiv").hide();});
			
			$("#sliderart").easySlider({
				auto: true,
				continuous: true 
			});
			
			$("#sliderselectart").easySlider({
				auto: true,
				continuous: true 
			});
			
			//Ajout panier
			$(".addpanier").click(function(){
				
				id_ref = $(".select_opt option:selected").val();
				$(".qte").attr("name","quantite["+id_ref+"]");
				
			});
			
			
			
			if(document.location.href.indexOf('action=add_to_cart')!=-1){
					$("#minipanier_details").slideDown(1200);
			}
			
			 // + OU - QUANTITE
				$("#td_minus").click(function(){
					var valeur = $('.qte').val();
					if (valeur >= 1) { 
        			var nouvelleValeur = parseFloat(valeur) - 1; 
        			} 
        			$('.qte').val(nouvelleValeur);
				});
				$("#td_hplus").click(function(){
					var valeur = $('.qte').val();
					var nouvelleValeur = parseFloat(valeur) + 1;
					$('.qte').val(nouvelleValeur); 
				});
				
				
				
			// GALERIE D'IMAGES
			$('a.tickbox').attr('rel', 'colorbox');
			$("a[rel='colorbox']").colorbox({height:"80%", width:"70%"});
			$("a[rel='galerie']").colorbox({transition:"fade", height:"80%", width:"70%"}); 
			
			$(".petit").mouseover(function(){ 
				thesrc=$(this).attr("src")
				thealt=$(this).attr("alt")
				thetitle=$(this).parent().attr("title")
				
				fileName="upload/"+thesrc.substr(thesrc.lastIndexOf("/")+3)
				$("#grande").attr("alt",thealt)
				$("#grande").parent().attr("title",thetitle)
				$("#grande").attr("src",fileName)
			});
			
			// PARTAGER RESEAUX SOCIAUX
				$("#reseaux").hide();
				$(".partage").toggle(function(){$("#reseaux").slideDown();},
									 function(){$("#reseaux").slideUp();});	
				
				$("#article, #other_choice, #seen").click(function(){$("#reseaux").hide();});
				
			// RECALCUL PANIER
				 $("#panierform select").change(function(){
						$("#panierform").submit();						   
					})	
					
			// supression article panier 
				 $("#thepanier .supp_art").click(function(){
                            n=$(this).attr('id').substring(5);
                           cible="#thepanier #qte"+n;
                           $(cible).val(0);
                           $("#panierform").submit()
  				})
				 
			// message error
			$(".closemessage").click(function(){
				$("#message").hide();
			})
			
			// Affichage formulaire inscription
				$("#form_insc").hide();
				$("#noclient span").click(function(){
						$("#form_insc").show();
						$("#client, #noclient").hide();
				});
			// affichage adresse de facturation
		 	$(".viewlivraison").click(function(){
					   if($(this).attr('checked')){
						  $("fieldset#livraisonfield").show();
					   }else{
						  $("fieldset#livraisonfield").hide();
					   }
				  })
			
			// OPEN MODIFICATION ADRESSES
			$('.addressDOMWindow').openDOMWindow({ 
				height:290, 
				width:600,
				eventType:'click', 
				loader:1, 
				loaderImagePath:'design/element/loading.gif', 
				loaderHeight:16, 
				loaderWidth:17 
				});
			
			
			
			$('.date').datepicker(); 
			
			$('#menu1').bind('mouseover', function hoverIn(){$('#menu1').css("z-index","4");
			$('#menu1').bind('mouseout', function hoverOut(){$('#menu1').css("z-index","1");});		
			});
			$('#menu2').bind('mouseover', function hoverIn(){$('#menu2').css("z-index","4");
			$('#menu2').bind('mouseout', function hoverOut(){$('#menu2').css("z-index","1");});		
			});
			$('#menu3').bind('mouseover', function hoverIn(){$('#menu3').css("z-index","4");
			$('#menu3').bind('mouseout', function hoverOut(){$('#menu3').css("z-index","1");});		
			});
			$('#menu4').bind('mouseover', function hoverIn(){$('#menu4').css("z-index","4");
			$('#menu4').bind('mouseout', function hoverOut(){$('#menu4').css("z-index","1");});		
			});
			$('#menu5').bind('mouseover', function hoverIn(){$('#menu5').css("z-index","4");
			$('#menu5').bind('mouseout', function hoverOut(){$('#menu5').css("z-index","1");});		
			});
			$('#menu6').bind('mouseover', function hoverIn(){$('#menu6').css("z-index","4");
			$('#menu6').bind('mouseout', function hoverOut(){$('#menu6').css("z-index","1");});		
			});
			$('#menu7').bind('mouseover', function hoverIn(){$('#menu7').css("z-index","4");
			$('#menu7').bind('mouseout', function hoverOut(){$('#menu7').css("z-index","1");});		
			});
			$('#menu8').bind('mouseover', function hoverIn(){$('#menu8').css("z-index","4");
			$('#menu8').bind('mouseout', function hoverOut(){$('#menu8').css("z-index","1");});		
			});
			$('#menu9').bind('mouseover', function hoverIn(){$('#menu9').css("z-index","4");
			$('#menu9').bind('mouseout', function hoverOut(){$('#menu9').css("z-index","1");});		
			});
			$('#menu15').bind('mouseover', function hoverIn(){$('#menu15').css("z-index","4");
			$('#menu15').bind('mouseout', function hoverOut(){$('#menu15').css("z-index","1");});		
			});
			
			$(".ssmenu").hide();
         	$(".rac").mouseover(function(){
				$(".rac").removeClass("linkhover")						 
            	var cible=$("+ .ssmenu",this);
				if(cible[0]){
					$(this).addClass("linkhover")
				}
				testvis=$("+ .ssmenu:visible",this);
				if(testvis.size()==0){ 
				   $(".ssmenu:visible").hide();
				   cible.show();
				   }
			});
			$("#leftcol, #rightcol, #fullcol, #logo, #minipanier, #logboutique").mouseover(function(){$(".ssmenu").hide();});
			
			// PLUS MOINS PANIER	 
	 
			 $("#panierform .moins").click(function(){ 
											 n=$(this).attr('id').substring(5);
											cible="#panierform #qte"+n;
											p=$(cible).val();
											if(Number(p)>1){
												$(cible).val(Number($(cible).val())-1);
											}
			})
			$("#panierform .plus").click(function(){
											 n=$(this).attr('id').substring(4);
											cible="#panierform #qte"+n;
											$(cible).val(Number($(cible).val())+1);
			})
			
			$("#panierform .qte").change(function(){ v=$(this).val(); if(Number(v)<1){$(this).val(0);}$("#panierform").submit()})
			
			
			

		
}); 

