/* A TARGET */
(function($) {
  $.fn.target = function() {
    return this.each(function(index, elm) {
      if (substr($(this).attr("class"), 0, 7) == 'target-') {
        $(this).attr("target", substr($(this).attr("class"), 7));
      }
    });
  }
})(jQuery);

$(document).ready(function() {
	$(".e-bezorging .image").html("");
	$(".e-bezorging .image").html('<img src="/etc/sites/paazl.com/images/slim.png" alt="De slimme manier van verzenden" />');
	
	
  $("a").target();

  if ($.browser.msie) {
  	$("div#contactCloseButton").css("margin-top", "-143");
  }
  	
  if ($.browser.msie && $.browser.version < 7) {
  	$("div#distribiteur").css("width", $("div#distribiteur").width() - 1);
  	$("div.b3button").css("margin-top", "7px");
  }
  
  /* Content pages "Contact Block" toggler */
  $("div#contact_close img").bind("click", function() {
  	$("div#contact_close").hide();
  	$("div#contact_open").show();
  });
  
  $("div#contactCloseButton").bind("click", function() {
  	$("div#contact_close").show();
  	$("div#contact_open").hide();  	
  });
  
  $("div.button_contact").bind("click", function() {
    $.ajax({
      type: "POST",
      cache: false,
      dataType: 'text',
      url: '/ajax/site-contact/',
      data: {
        pa_bedrijfsnaam: $(":input[name='pa_bedrijfsnaam']").val(),
        pa_telefoon: $(":input[name='pa_telefoon']").val(),
        pa_email: $(":input[name='pa_email']").val()
      },
      success: function(msg) {
				if (msg == 'ok') {
				  alert('Uw verzoek is met succes door ons ontvangen, wij zullen spoedig mogelijk contact met u opnemen.');
				} else {
					alert('Er is een fout opgetreden, probeert u het later nogmaals.');
				}
      }
    });
  });
  
  /* Homepage blokken klikbaar maken */
//  $("div#consument").bind("click", function() {
//  	window.location.href = '/consument/';
//  });
//  
//  $("div#webwinkel").bind("click", function() {
//  	window.location.href = '/webwinkel/';
//  });
//  
//  $("div#distribiteur").bind("click", function() {
//  	window.location.href = '/distribiteur/';
//  });
  
	$("div.b1").bind("click", function() {
		window.location.href = $(this).children("a").attr("href");
	});
	
	$("div.b2").bind("click", function() {
		window.location.href = $(this).children("a").attr("href");
	});
	
	$("div.b3").bind("click", function() {
		window.location.href = $(this).children("a").attr("href");
	});
	
	$("div.b4").bind("click", function() {
		window.location.href = $(this).children("a").attr("href");
	});
	
	if ($.browser.msie && $.browser.version < 7) {		
		$("div.container div.middle").css("width", "981px");
	}
	
	$("img[src@='png']").pngfix();
	
});