$(document).ready(function(){
  
 if($("#map").length){
   var myLatlng = new google.maps.LatLng(50.98851929849964, 3.534519150853157);
   var myOptions = {
     zoom: 14,
     center: myLatlng,
     mapTypeId: google.maps.MapTypeId.ROADMAP
   };
   var map = new google.maps.Map(document.getElementById("map"), myOptions);

   var marker = new google.maps.Marker({
       position: myLatlng, 
       map: map,
       title:"Wink"
   });
 }
 
 $(".promo_buttons .promo_item").hover(
   function(){
     $(this).children("ul").slideDown('fast');
   },
   function(){
     $(this).children("ul").slideUp('slow');
   }
 );
 $(".promo_buttons .promo_item").click(function(){
   window.location = $(this).find(".more a").attr("href");
 });

 var step = 1;
 $(".step").click(function(){
   if(step<4){
     var prev_step = step;
     step++;
     $("#tab_"+prev_step).fadeOut("fast",function(){
       $(".legend li").removeClass("active");
       $(".legend li").removeClass("before_active");
       $(".legend li").removeClass("last_active");
       $("#legend_tab_"+prev_step).addClass("before_active");
       $("#tab_"+step).fadeIn("slow");
       $("#legend_tab_"+step).addClass("active");
       if($("#legend_tab_"+step).hasClass("last")){
         $("#legend_tab_"+step).addClass("last_active");
       }
     });
   }
   
 });
 
 // Forms
 if($("#order_textile").length>0 && $("#order_textile").val()!="other"){
   $("#order_textile_other").hide();
 }
 $("#order_textile").change(function(){
   if($(this).val()=="other"){
     $("#order_textile_other").addClass("visible").slideDown('fast');
   }else{
     if($("#order_textile_other").hasClass("visible")){
       $("#order_textile_other").removeClass("visible").slideUp('fast');
     }else{
       $("#order_textile_other").removeClass("visible").hide();
     }
   }
 });
 
 $("#order_print .checkbox").click(function(){
   var target = $(this).attr("id")+"_quantity";
   if($(this).is(':checked')){
    $("#"+target).slideDown('fast');
   }else{
     $("#"+target).slideUp('fast');
   }
 });
 if($(".datepicker").length>0){
   var tomorrow = new Date();
    tomorrow.setDate(tomorrow.getDate()+7);
    $(".datepicker").datepicker({dateFormat: 'yy-mm-dd', minDate: tomorrow, showAnim: 'fadeIn'});
 }
 
 $(".collapse").each(function(){
   $(this).attr("href","javascript:;");
 });
 $(".collapse").click(function(){
   var sender = $(this);
   var target = "#"+sender.attr("rel");
   var title = $(this).attr("title");
   if(!sender.hasClass("collapsed")){
     sender.addClass("collapsed");
     $(target).show(1,function(){
       sender.html(title.replace("Meer","Minder"));
     });
   }else{
     $(target).hide(1,function(){
       sender.removeClass("collapsed");
       sender.html(title.replace("Minder","Meer"));
     });
   }
 });
 
 $("a[rel='t_blank']").each(function(){
   $(this).attr("target","_blank");
 });

 var order_print_total = 0;
 $("#order_print select").change(function(){
   order_print_total = 0;
   $("#order_print select").each(function(){
     order_print_total += Number($(this).val());
   });
   $("#order_print #promo_total").html(order_print_total);
 });
 
});

$.easing.easeout = function(x, t, b, c, d) {
  return -c*t*t/(d*d) + 2*c*t/d + b;
};
