$(document).ready(function() {
	if ($.browser.msie) {
	    $('input[type=text]').keydown(function(e){
	      if (e.keyCode == 13) {
	        $(':submit').click();
	        return false;
	      }
	    });
	  }
	$("#staffelkorting").hover(function(){
		$('#center .tier_fade').css('visibility', 'visible');
		$("#center div.tier").animate({opacity: 1}, 1500);
			clearTimeout(aanbodtimer);
		}, function(){
			aanbodtimer = setTimeout(function() {
				$("#center div.tier").animate({opacity: 0}, 1500);
			}, 1000);
	});
  
  $('span.coupon input').focus(function(){
	  if ($(this).attr('value')=='indien van toepassing') {
		  $(this).attr('value', '');
		  $(this).css('color', '#666');
	  }
  });
  $('#shoppingcart span.coupon input').blur(function(){
	  if ($(this).attr('value')=='') {
		  $(this).attr('value', 'indien van toepassing');
		  $(this).css('color', '#aaa');
	  }
  });

  $('span.coupon input').blur();

  $("#shoppingcart .update").css('display', 'none');

  $("#shoppingcart .cart_change").change(function(){
    var array = $("#shoppingcart");
    var form = array.serialize();

    form += "&type=update";

    $.post("/cart/post", form, function(data){
      location.reload();
    });
  });

  $("#other_adress").click(function(){
	  if ($(this).is(':checked')) {
		  $("#shipping_details").css('display', 'block');
	  } else {
		  $("#shipping_details").css('display', 'none');
		  $('#shoppingcart_Delivery_address').val('');
		  $('#shoppingcart_Delivery_zipcode').val('');
		  $('#shoppingcart_Delivery_city').val('');
	  }
  });

  $("#center p").each(function(){
	  $(this).html($(this).html().replace(/STUKADOORSMARKT.NL/, "<span class=\"orange\">STUKADOORS</span><span class=\"blue\">MARKT.NL</span>"));
  });
  
  $('a#show-contact-form').click(function(){
	  $('form#contact-form').slideToggle('slow');
  });
  
  $('#sm_contact_interest_other').click(function(){
	  $('#sm_contact_interest-other').attr('disabled', ! $(this).is(':checked'));
  });
  
  $.fn.pulse = function() {
	  var e = $(this);
	  e.animate({opacity: 0}, 1000, function(){
		  $(this).animate({opacity: 1}, 1000);
	  });
	  setTimeout("$('#img-price-guarantee').pulse()", 3000);
  }
  $('#img-price-guarantee').pulse();
});

  var aanbodtimer;
