Index.VALID_WORD_SEPARATOR_CHARACTER=/^[\s\-]$/;var Autocomplete=$.autocomplete({type:"local",inputSelector:"#searchBox",outputContainerSelector:"#list",touch:Globals.TOUCH},{getLocalData:function(query){return Index.LIST_OF_ALL_SCHOOLS},filterLocalData:function(data,query){if(query==="")return data;var itemsMatchingNickName=_.filter(data,function(value){var index=value.nickname.toLowerCase().indexOf(query.toLowerCase());return (index!==-1&&index===0)});var itemsMatchingFullName=_.filter(data,function(value){var index=value.name.toLowerCase().indexOf(query.toLowerCase());return (index!==-1&&(index===0||Index.VALID_WORD_SEPARATOR_CHARACTER.test(value.name[index-1])))});return _.uniq(itemsMatchingNickName.concat(itemsMatchingFullName))},stringifyListItem:function(object,query){var url=Index.BASE_URL+object.slug+"/selection/";return '<li><a href="'+url+'">'+object.name+'</a></li>'},stringifyFailedSearch:function(query){return Index.SCHOOL_NOT_FOUND_MESSAGE},clickListItem:function(e){return},listItemWasSelected:function(elem){elem.addClass("special");window.location=$(elem).find("a").attr('href')}})
function navigateToISBNSelection(){Analytics.trackPage('isbn');Analytics.trackEvent('UI','Selected ISBN Mode','Button');window.location=Index.ISBN_URL}
function displaySearch(){$("#go").hide();$("#select").show();Autocomplete.init();if(!Globals.TOUCH)Autocomplete.focus()}
function displayLandingPageForSchool(){$("#select").hide();$("#go").show()}
function navigateToSelectionFromSchoolLandingPage(){window.location=Index.BASE_URL+Index.SCHOOL_SLUG+"/selection/"}
function userBrowsingWithUnsupportedIE(){var ielt8=navigator.userAgent.toLowerCase().indexOf('msie 6')!==-1||navigator.userAgent.toLowerCase().indexOf('msie 7')!==-1;return ielt8};$(document).ready(function(){if(userBrowsingWithUnsupportedIE()){$("body").addClass("ie");return};$("#change").click(displaySearch);$("#getStarted").click(navigateToSelectionFromSchoolLandingPage);$("#goISBN").click(navigateToISBNSelection);if(Index.IS_SCHOOL)displayLandingPageForSchool();else displaySearch()})
