window.app=function(){function i(){return(typeof t=="undefined"||t==="")&&$.get(constant.appRoot+"templates/commentlisttemplate.mustache",function(n){t=n}),t}function r(t){switch(t){case constant.postListTemplateType.a:return(typeof n.a=="undefined"||n.a==="")&&$.get(constant.appRoot+"templates/postlistatemplate.mustache",function(t){n.a=t}),n.a;case constant.postListTemplateType.c:return(typeof n.c=="undefined"||n.c==="")&&$.get(constant.appRoot+"templates/postlistctemplate.mustache",function(t){n.c=t}),n.c;case constant.postListTemplateType.d:return(typeof n.d=="undefined"||n.d==="")&&$.get(constant.appRoot+"templates/postlistdtemplate.mustache",function(t){n.d=t}),n.d;case constant.postListTemplateType.e:return(typeof n.e=="undefined"||n.e==="")&&$.get(constant.appRoot+"templates/postlistetemplate.mustache",function(t){n.e=t}),n.e;case constant.postListTemplateType.f:return(typeof n.f=="undefined"||n.f==="")&&$.get(constant.appRoot+"templates/postlistftemplate.mustache",function(t){n.f=t}),n.f;case constant.postListTemplateType.g:return(typeof n.g=="undefined"||n.g==="")&&$.get(constant.appRoot+"templates/postlistgtemplate.mustache",function(t){n.g=t}),n.g;case constant.postListTemplateType.h:return(typeof n.h=="undefined"||n.h==="")&&$.get(constant.appRoot+"templates/postlisthtemplate.mustache",function(t){n.h=t}),n.h;case constant.postListTemplateType.search:return(typeof n.search=="undefined"||n.search==="")&&$.get(constant.appRoot+"templates/searchlisttemplate.mustache",function(t){n.search=t}),n.search;case constant.postListTemplateType.b:default:return(typeof n.b=="undefined"||n.b==="")&&$.get(constant.appRoot+"templates/postlistbtemplate.mustache",function(t){n.b=t}),n.b}}function f(n,t){var i=r(n);return Mustache.to_html(i,t)}function e(n){var t=i();return Mustache.to_html(t,n)}function o(n){return'<p class="font-resize"><strong style="font-size:11px;">Font Size<\/strong><br/><a style="font-size:14px;margin-left:10px;" href="javascript:window.app.makeFontSmall(\''+n+'\');">A<\/a><a style="font-size:18px;margin-left:10px;" href="javascript:window.app.makeFontMedium(\''+n+'\');">A<\/a><a style="font-size:22px;margin-left:10px;" href="javascript:window.app.makeFontLarge(\''+n+"');\">A<\/a><\/p>"}function s(n,t){n.addClass("on"),t.addClass("on")}function u(n,t){n.removeClass("on"),t.removeClass("on")}var n={a:"",b:"",c:"",d:"",e:"",f:"",g:"",h:"",search:""},t="";return{getGaqAccount:function(){return constant.gaqAccount},getGaqDomainName:function(){return constant.gaqDomainName},getPaqSiteId:function(){return constant.paqSiteId},logError:function(n,t,i){if(n.length&&i>0){var r={Message:n||"",LineNumber:i,Url:t||window.location,Referrer:document.referrer||"",UserAgent:navigator.userAgent};$.ajax({type:"POST",url:constant.appRoot+"error/log",data:r,dataType:"json"})}},postComment:function(){var t=$(this),u=t.parents(".detail[data-role=page]"),f=t.parents(".ui-btn").find(".ui-btn-text"),h=t.parents(".comments-section").find(".comments.ui-listview"),r=t.parents(".post-comment"),o=r.find(".post-comment-name"),s=r.find(".post-comment-email"),e=r.find(".post-comment-comment"),n={contenttype:u.data("contentType"),postid:u.data("postId"),author:o.val(),authoremail:s.val(),text:e.val()};if(!n.contenttype||!n.postid||!n.author||!n.authoremail||!n.text){alert("Please enter name, email and comment.");return}if(!n.authoremail.match(constant.regexEmail)){alert("Please enter valid email address.");return}$.cookie(constant.cookieCommentKeyUserName,n.author,{expires:constant.cookieCommentExpireDays}),$.cookie(constant.cookieCommentKeyUserEmail,n.authoremail,{expires:constant.cookieCommentExpireDays}),$.ajax({url:constant.apiUrl+"comment?apiKey="+constant.apiKey,type:"POST",dataType:"json",data:n,crossDomain:!0,beforeSend:function(){i(),t.attr("disabled","disabled"),f.text("Submitting...")},success:function(){e.val(""),alert("Thank you for joining the discussion. Your comment is pending approval.")},error:function(){alert("There was an error. Comment could not be posted.")},complete:function(){t.removeAttr("disabled"),f.text(t.text())}})},loadAllComments:function(){var n=$(this),r=n.parents(".ui-btn").find(".ui-btn-text"),f=n.parents("li.ui-li"),t=n.parents("ul.comments"),u=n.parents(".detail[data-role=page]"),o=u.data("contentType"),s=u.data("postId"),h=constant.apiUrl+"comment?apiKey="+constant.apiKey+"&contenttype="+o+"&id="+s;$.ajax({url:h,crossDomain:!0,beforeSend:function(){i(),n.attr("disabled","disabled"),r.text("Loading...")},success:function(n){var i=e(n);t.html(i),t.find("span.date").each(function(n,t){$(t).text($.format.date($(t).text()+"-08:00","M/d/yyyy h:mm:ss a"))}),t.listview("refresh"),f.remove()},error:function(n,t,i){alert("jqXHR: "+n.status+", Status: "+t+", Error: "+i)},complete:function(){n.removeAttr("disabled"),r.text(n.text())}})},loadMorePosts:function(n){n.stopImmediatePropagation(),n.preventDefault;var t=$(this),e=t.find(".ui-btn-inner .ui-icon"),h=t.parents(".posts-section"),c=h.find("ul.posts"),l=t.data("channel")?"&f_channel="+t.data("channel"):"",a=t.data("contentType")?"&f_contenttype="+t.data("contentType"):"",v=t.data("excludeType")?"&fe_type="+t.data("excludeType"):"",y=t.data("excludeId")?"&fe_posts="+t.data("excludeId"):"",o=t.data("templateType"),i=t.data("pageNumber"),p=t.data("pageSize"),s=t.attr("href"),u=t.data("trackUrl"),w=constant.apiUrl+"post?apiKey="+constant.apiKey+l+a+v+y+"&pagenumber="+i+"&pagesize="+p;return $.ajax({url:w,crossDomain:!0,beforeSend:function(){r(o),t.attr("disabled","disabled"),e.addClass("spinning")},success:function(n){var e=f(o,n),r,h,l;e?(c.append(e).listview("refresh"),$.support.pushState&&window.history.pushState({page:i},document.title,s),r=i+1,t.data("pageNumber",r),h=s.replace("/page/"+i,"/page/"+r),t.attr("href",h),l=u.replace("/page/"+i,"/page/"+r),t.data("trackUrl",l),window.app.reloadGoogleAnalytics(u),window.app.reloadPiwik(u)):t.hide()},error:function(){alert("There was an error loading more.")},complete:function(){t.removeAttr("disabled"),e.removeClass("spinning")}}),!1},loadMoreSearchPosts:function(n){n.stopImmediatePropagation(),n.preventDefault;var t=$(this),e=t.find(".ui-btn-inner .ui-icon"),h=t.parents(".search-posts-section"),c=h.find("ul.search-posts"),l=t.data("excludeType")?"&fe_type="+t.data("excludeType"):"",a=t.data("searchKeyword"),o=t.data("templateType"),i=t.data("pageNumber"),v=t.data("pageSize"),s=t.attr("href"),u=t.data("trackUrl"),y=constant.apiUrl+"search?apiKey="+constant.apiKey+l+"&q="+a+"&pagenumber="+i+"&pagesize="+v;return $.ajax({url:y,crossDomain:!0,beforeSend:function(){r(o),t.attr("disabled","disabled"),e.addClass("spinning")},success:function(n){var e=f(o,n),r,h,l;e?(c.append(e).listview("refresh"),$.support.pushState&&window.history.pushState({page:i},document.title,s),r=i+1,t.data("pageNumber",r),h=s.replace("&page="+i,"&page="+r),t.attr("href",h),l=u.replace("&page="+i,"&page="+r),t.data("trackUrl",l),window.app.reloadGoogleAnalytics(u),window.app.reloadPiwik(u)):t.hide()},error:function(){alert("There was an error loading more.")},complete:function(){t.removeAttr("disabled"),e.removeClass("spinning")}}),!1},enewsSignup:function(){var i=$(this),n=i.parents(".enews-signup").find(".enews-signup-email").val(),t=constant.emailPreferenceUrl_Textbox.replace(/&amp;+/g,"&");n&&($.cookie(constant.cookieCommentKeyUserEmail,n,{expires:constant.cookieCommentExpireDays}),t+="&em="+n),window.open(t,"_blank")},initSlider:function(n,t){var u,f,i,r,e;if(t.length&&(t.empty(),u=n.find(".swipe-wrap").children().length,u>0)){for(f=$("<em/>"),i=$("<div/>"),r=0;r<u;r++)e=f.clone(),r===0&&e.addClass("on"),i.append(e);return t.append(i.html()),f.remove(),i.remove(),new Swipe(n.get(0),{callback:function(n){t.find("em").removeClass(),t.find("em:nth-child("+(n+1)+")").addClass("on")}})}return null},initPhotoSwipe:function(){var n=$(this),t={getImageCaption:function(n){var i="",t,r,u;for(n.nodeName==="IMG"&&(i=n.getAttribute("alt")),t=0,r=n.childNodes.length;t<r;t++)u=n.childNodes[t],n.childNodes[t].nodeName==="IMG"&&(i=u.getAttribute("alt"));return $("<div/>").html($("<div/>").html(i).text())},enableMouseWheel:!1,enableKeyboard:!1},i=n.find(".gallery a").photoSwipe(t)},initPhotoOverlay:function(){var n=$(this),t;$(".story img").each(function(){var n=$(this),t,i;n.parent().is("a")||(t=n.attr("src"),n.addClass("image"),i=$("<a/>").attr("href",t).addClass("imgwrap"),n.wrap(i))}),t={getImageCaption:function(n){var i="",t,r,u;for(n.nodeName==="IMG"&&(i=n.getAttribute("alt")),t=0,r=n.childNodes.length;t<r;t++)u=n.childNodes[t],n.childNodes[t].nodeName==="IMG"&&(i=u.getAttribute("alt"));return $("<div/>").html($("<div/>").html(i).text())},enableMouseWheel:!1,enableKeyboard:!1},n.find(".story a.imgwrap").length>0&&n.find(".story a.imgwrap").photoSwipe(t)},reloadGoogleAnalytics:function(n,t,i){var r="//www.google-analytics.com/plugins/ga/inpage_linkid.js";_gaq.push(["_require","inpage_linkid",r]),_gaq.push(["_setAccount",constant.gaqAccount]),_gaq.push(["_setDomainName",constant.gaqDomainName]),t&&_gaq.push(["_setCustomVar",1,"PubDate",t+"",3]),i&&_gaq.push(["_setCustomVar",3,"Author",i,3]),n?_gaq.push(["_trackPageview",n]):_gaq.push(["_trackPageview"])},reloadPiwik:function(n){n?_paq.push(["trackPageView",n]):_paq.push(["trackPageView"]),_paq.push(["enableLinkTracking"]),_paq.push(["setCookieDomain",constant.paqCookieDomain])},reloadAddThis:function(n){var t=n.find(".social-tools"),i;t.length&&(window.addthis&&(window.addthis=null),i={data_ga_property:constant.gaqAccount,data_ga_social:!0},$.getScript("http://s7.addthis.com/js/300/addthis_widget.js#pubid="+constant.addThisPubId))},makeFontSmall:function(n){$("#"+n+" section.content").removeClass("medium").removeClass("large")},makeFontMedium:function(n){$("#"+n+" section.content").removeClass("large").addClass("medium")},makeFontLarge:function(n){$("#"+n+" section.content").removeClass("medium").addClass("large")},reloadFontTools:function(n){var r=n.attr("id"),t=n.find("section.content .story"),i;t.length&&t.find(".font-resize").length===0&&(i=o(r),t.children("p img").first().length>0?t.children("p img").first().parent().after(i):t.children("p").first().before(i))},reloadNavMore:function(n){var t=n.find(".navbar-more"),i=n.find(".navbar-more-box");u(t,i),t.unbind("click").click(function(){t.hasClass("on")?u(t,i):s(t,i)}),$(document).mouseup(function(n){t.has(n.target).length===0&&u(t,i)})},prefillNameAndEmail:function(n){n.find(".post-comment-name").val($.cookie(constant.cookieCommentKeyUserName)),n.find(".post-comment-email").val($.cookie(constant.cookieCommentKeyUserEmail)),n.find(".enews-signup-email").val($.cookie(constant.cookieCommentKeyUserEmail))},showAdIframe:function(n,t){$(".ad-"+n).height(t).parent().show()}}}(),window.slider={},window.onerror=function(n,t,i){window.app.logError(n,t,i)},$(document).bind("ready",function(){$.mobile.ajaxEnabled=$.support.pushState,$.mobile.pushStateEnabled=$.support.pushState,$.mobile.defaultPageTransition="none",$.support.pushState&&(window.onpopstate=function(n){n&&n.state&&n.state.page&&$.mobile.changePage(window.location.pathname+window.location.search+window.location.hash,{reverse:!1,changeHash:!1})});$(document).on("click",".post-comment-submit",window.app.postComment);$(document).on("click",".comments-load-all",window.app.loadAllComments);$(document).on("click",".posts-load-more",window.app.loadMorePosts);$(document).on("click",".search-posts-load-more",window.app.loadMoreSearchPosts);$(document).on("click",".enews-signup-submit",window.app.enewsSignup)});$(document).on("pageshow","[data-role=page]",function(){var n=$(this),i=window.location.hash.replace("#",""),r=n.data("trackPageView"),t=r?r:i?i:window.location.pathname+window.location.search;n.hasClass("detail")&&t!="/"?window.app.reloadGoogleAnalytics(t,n.data("pubDate"),n.data("author")):window.app.reloadGoogleAnalytics(t),window.app.reloadPiwik(t),window.app.reloadFontTools(n),window.app.reloadNavMore(n),window.app.prefillNameAndEmail(n)});$(document).on("pageshow","#page-home",function(){var n=$(this);window.slider.homeTop=window.app.initSlider(n.find(".sliderHomeTop"),n.find(".sliderHomeTopPosition")),window.slider.homePhotos=window.app.initSlider(n.find(".sliderHomePhotos"),n.find(".sliderHomePhotosPosition")),window.slider.homeProducts=window.app.initSlider(n.find(".sliderHomeProducts"),n.find(".sliderHomeProductsPosition")),addToHome.show()});$(document).on("pageshow","#page-photo-detail",window.app.initPhotoSwipe);$(document).on("pageshow","#page-article-detail, #page-news-detail, #page-blogpost-detail, #page-product-detail",window.app.initPhotoOverlay);$(document).on("pageshow","#page-channel-gangs, #page-channel-swat, #page-channel-weapons, #page-channel-careers-training, #page-channel-patrol, #page-channel-technology, #page-channel-vehicles, #page-channel-women-in-law-enforcement",function(){var n=$(this);window.slider.channelTop=window.app.initSlider(n.find(".sliderChannelTop"),n.find(".sliderChannelTopPosition"))})