﻿var $j = jQuery;

$j(document).bind('ajaxComplete', function(e, xhr, options) {
  if (xhr.getResponseHeader('Content-Type').indexOf('text/javascript') !== -1) {
    eval(xhr.responseText);
  }
})

function Post(form) {
  form = $j(form);
  $j.post(form.attr('action'), form.serialize());
}

function Invoke(params, confirmation) {
  if (typeof confirmation === 'string') { if (!confirm(confirmation)) { return; } }
  $j.post(document.location.href, params);
}



jQuery(function() {
  var options;
  options = {
    serviceUrl: '/search/',
    minChars: 2,
    maxHeight: 400,
    width: 200,
    onSelect: function(value, data) {
      if (document.getElementById("query")) { window.location = '/search/?q=' + value; }
    }
  };
  if (document.getElementById("query")) { $j('#query').autocomplete(options); }
});


