$(document).ready(function() { //check to see if there is a search offset start_offset = $.jget['start_offset']; var terms = $.jget['search']; var presentation_id = $("#presentation_id").val(); var minisite_id = $("#minisite_id").val(); if (terms != null && terms != '') { var from_presentation = $.jget['from_presentation']; var from_presentation_offset = $.jget['from_presentation_offset']; $(".search_input").val(terms); $.ajax({ type: "GET", url: "/ajax/search_json/index.php", data: {mode: 'single', search: terms, presentation_id: presentation_id, minisite_id: minisite_id, from_presentation: from_presentation, from_presentation_offset: from_presentation_offset}, dataType: "json", success: function(json) { render_search(json); }, error: function() { alert('error'); } }); } single_search = function() { var options = { target: null, beforeSubmit: null, success: render_search, url: '/ajax/search_json/index.php?mode=single', type: 'get', dataType: 'json', clearForm: false, resetForm: false }; $(this).ajaxSubmit(options); return false; }; global_search = function() { var options = { target: null, beforeSubmit: null, success: render_search, url: '/ajax/search_json/index.php?mode=global', type: 'get', dataType: 'json', clearForm: false, resetForm: false }; $(this).ajaxSubmit(options); return false; }; $('#search_form').submit(single_search); $(".search_input") .focus(function (e) { $(this) .val('') .addClass('normal'); }); });