/// <reference path="jquery.js"/>

function productSearch(){
  var searchterm = $("#searchstr").val();

  if(searchterm != ''){
    document.location.href = "/Produkter/Search.aspx?searchstr=" + searchterm;
  }
  return false;
}



$(document).ready(function() {

  $("#searchstr").keydown(function(e){
    if (e.keyCode == 13) {
      productSearch();
      return false;
    }
  });

  $("#search-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());
	  });
	}
);

});
