TK.registerNS("TK.search");TK.search=new function(){var result=null;var pagesize=40;var MSG_BOOK="";var MSG_BOOKED="";var MSG_RESERVED="";var MSG_HOLES9="";var MSG_HOLES18="";var MSG_LOADING="";var MSG_COURSE="";var MSG_SLOTS="";var MSG_INCLUDES="";var TEETIMES_PER_ROW=6;var recClubs=new Array();var regioncode=null;
var mid=null;var view="";var timer=null;var hour1=null;var hour2=null;var min1=null;var min2=null;var displaySliderDefault=true;this.curpage=1;this.date=null;this.rid=null;this.cid=null;this.zid=null;this.crid=null;this.currency="";this.book="";this.booked="";this.reserved="";this.holes9="";this.holes18="";
this.init=function(args,perrow){MSG_BOOK=args[0];MSG_BOOKED=args[1];MSG_RESERVED=args[2];MSG_HOLES9=args[3];MSG_HOLES18=args[4];MSG_LOADING=args[5];MSG_COURSE=args[6];MSG_SLOTS=args[7];MSG_INCLUDES=args[8];MSG_ALTERNATIVES=args[9];regioncode=args[10];mid=args[11];if(TK.actions.isNotBlank(mid)||TK.actions.isNotBlank(TK.search.zid)){view="overview";
}TEETIMES_PER_ROW=perrow;TK.search.getTeetimes();$(window).resize(function(){clearTimeout(timer);timer=setTimeout(TK.search.loadTables(),500);});};this.maxPage=function(max){var maxPage=parseInt(max/pagesize);if(max%pagesize!=0){++maxPage;}return maxPage;};this.getTeetimesByBtn=function(elem){displaySliderDefault=true;
TK.search.date=$(elem).data("date");TK.search.getTeetimes();};this.getTeetimesByDate=function(date){TK.search.date=date;TK.search.getTeetimes();};this.getTeetimes=function(){if(TK.actions.getLock()){$("#tk-search-divResult").html("");$("#tk-search-results").hide();$("#tk-search-rec-results").hide();$("#tk-search-loadingMsg").show();
TK.actions.hideError("tk-search-error");TK.actions.hideError("tk-search-warn");$("#tk-search-loading").show();TKGeneral.getTeetimes(TK.search.date,TK.search.rid,TK.search.cid,mid,TK.search.zid,TK.search.getTeetimesReturn);}};this.setDisplaySliderDefault=function(){displaySliderDefault=true;};this.getTeetimesReturn=function(data){TK.actions.releaseLock();
result=data;$("#gs-searchbtn0").data("date",result.date0.date);$("#gs-searchbtn1").data("date",result.date1.date);$("#gs-searchbtn2").data("date",result.date2.date);$("#gs-searchbtn3").data("date",result.date3.date);$("#gs-searchbtn4").data("date",result.date4.date);$("#gs-searchbtn5").data("date",result.date5.date);
$("#gs-searchbtn6").data("date",result.date6.date);$("#gs-searchbtn1").html(result.date1.monthDay+" "+result.date1.dayOfWeek);$("#gs-searchbtn2").html(result.date2.monthDay+" "+result.date2.dayOfWeek);$("#gs-searchbtn3").html(result.date3.monthDay+" "+result.date3.dayOfWeek);$("#gs-searchbtn4").html(result.date4.monthDay+" "+result.date4.dayOfWeek);
$("#gs-searchbtn5").html(result.date5.monthDay+" "+result.date5.dayOfWeek);TK.search.curpage=1;if(result.searchDTO[0].error==TK.constants.SUCCESS){if(TK.actions.isBlank(view)||result.clubs.length==1){view=result.clubs[0].encryptedId;}TK.search.sort();TK.search.loadTables();$("#tk-search-loading").hide();
$("#tk-search-rec-results").hide();$("#tk-search-results").show();}else{if(result.searchDTO[0].error==TK.constants.WARN){$("#tk-search-loadingMsg").hide();TK.actions.showError("tk-search-warn",result.searchDTO[0].misc);}else{if(result.searchDTO[0].error==TK.constants.WARN2){$("#tk-search-loadingMsg").hide();
TK.actions.showError("tk-search-warn",result.searchDTO[0].misc);}else{$("#tk-search-loadingMsg").hide();TK.actions.showError("tk-search-error",result.searchDTO[0].misc);}}}};this.getRecClubsReturn=function(data){if(data!=null&&data.length>0){recClubs=data;var msg="";var limit=5;msg="
"+MSG_ALTERNATIVES+'
';msg+=''+recClubs[i].name+" ";msg+=' ';msg+=''+recClubs[i].cost+"/"+MSG_HOLES18;
msg+=" | ";}}msg+="