/// <reference path="jquery.js"/>

function productSearch(){
  var searchterm = $("#search-input").val();

  if(searchterm != '' && searchterm != 'Søg'){
    document.location.href = "/Produkter/Search.aspx?searchstr=" + searchterm;
  }
  return false;
}


$(document).ready(function() {

  $("#search-input").keydown(function(e){
    if (e.keyCode == 13) {
      productSearch();
      return false;
    }
  });

  $("a.button#seach-button").bind("click", function(){
    productSearch();
  });


// this should be refactored to another file (Lars Buur - 25.jan 09)


$(".zipcode-lookup").blur(function(){
	
	var targetfield = $(this).attr('lookuptarget');
	
	$.get("/?altTemplate=AjaxProxy&ajax-lookupzip=" + this.value,
	  function(data){
	  	$('#' + targetfield).val(data.trim());
	  });
	}
);

});

