var debug=!1;function log(){if(!debug)return;console.log.apply(null,arguments)}
if(!Array.prototype.find){Object.defineProperty(Array.prototype,'find',{value:function(predicate){if(this==null){throw TypeError('"this" is null or not defined')}
var o=Object(this);var len=o.length>>>0;if(typeof predicate!=='function'){throw TypeError('predicate must be a function')}
var thisArg=arguments[1];var k=0;while(k<len){var kValue=o[k];if(predicate.call(thisArg,kValue,k,o)){return kValue}
k++}
return undefined},configurable:!0,writable:!0})}
var hashTarget=window.location.hash;window.location.hash="";function getUrlParamByName(name){name=name.replace(/[\[\]]/g,'\\$&');var url=window.location.href;var regex=new RegExp('[?&]'+name+'(=([^&#]*)|&|#|$)');var results=regex.exec(url);if(!results||!results[2])return'';return decodeURIComponent(results[2].replace(/\+/g,' '))}
function set_currency(currency){jQuery('.currency-dropdown').each(function(){var on_sale=jQuery(this).closest('.app-price').hasClass('sale');var active_item=jQuery(this).find('.dropdown-item[data-currency="'+currency+'"]');jQuery(this).siblings('.price-value').text(active_item.attr('data-prefix')+active_item.attr('data-price'));if(on_sale){jQuery(this).siblings('.sale-value').text(active_item.attr('data-prefix')+active_item.attr('data-sale-price'))}
jQuery(this).find('.currency-value').text(active_item.text())})}
var app_finder_db={pro:{question:"What best describes your work?",answer_type:"radio",options:{'acute-care':{icon:"hospital",label:"Acute Care",description:'',recommendation_content:'You’re busy and probably don’t have a lot of time for one-on-one x, but you need quality tools at your fingertips for quick assessments, treatment ideas, and communication supports. We’ve got you covered!',recommendations:[{name:'Dysphagia',},{name:'Language',},{name:'Visual Attention',},{name:'AlphaTopics',},],recommended_for:'acute care'},rehab:{icon:"clinic",label:"Rehab",description:'inpatient, outpatient, or home health',recommendation_content:'Did you know that ALL of the Tactus x apps were designed by an SLP working in inpatient and outpatient rehab? That means they are all perfect for your work! You can use them, your clients can use them, and you’ll both see better results.',recommendations:[{name:'Language',},{name:'Advanced Language',},{name:'Apraxia',},{name:'Category',},],recommended_for:'rehab'},'residential-care':{icon:"care-home",label:"Long-Term or Residential Care",description:'',recommendation_content:'You need evidence-based tools to help those with degenerative conditions improve their quality of life. These apps will make your treatments more engaging, documentation faster, and goals more patient-centered.',recommendations:[{name:'Dysphagia',},{name:'Conversation',},{name:'Spaced Retrieval',},{name:'Language',},],recommended_for:'long-term or residential care'},pediatrics:{icon:"child",label:"Pediatrics",description:'schools or private practice',recommendation_content:'All of the Tactus x apps were developed with adults in mind, but they can work great with children aged 5-18 in the right hands. Try the free Lite version of all apps to preview the exercises before using them with kids on your caseload.',recommendations:[{name:'Speech Flipbook',},{name:'Language',},{name:'Category',},{name:'Conversation',},],recommended_for:'pediatrics'},faculty:{icon:"university",label:"University Faculty",description:'',recommendation_content:'We provide free copies of all of our apps to university clinics training the next generation of speech-language pathologists. We also provide apps for professors who wish to include them in the curriculum, and to researchers who wish to use our apps in their investigations. <br/><br/>If you qualify, please follow <a href="https://help.tactusx.com/hc/en-us/articles/360024411152">these instructions</a> to claim your free apps. <br/>If not, please go <a class="back_finder_3" href="'+window.location.origin+'/find/pro/">back</a> and select the closest setting to match your needs.',recommendations:[]},student:{icon:"school",label:"Student of Speech Pathology",description:'',recommendation_content:'Imagine having evidence-based treatment materials loaded on your device, giving you one less thing to worry about when you’re treating your clients. It’s possible when you go into your clinical experiences armed with Tactus x apps!',recommendations:[{name:'Dysphagia',},{name:'Speech Flipbook',},{name:'Language',},{name:'Conversation',},],recommended_for:'students of speech pathology'},}},home:{question:"What do you want to improve?",answer_type:"checkbox",options:{talking:{icon:"speech-bubble-outline",name:"Talking",description:"verbal expression",question:"How bad is the problem?",answer_type:"radio",options:{severe:{icon:"severe",label:"Severe: Tries to speak, but usually can't get anything meaningful out. Sometimes can say automatic words or phrases.",recommendations:[{name:'Apraxia',score:5,importance:1},{name:'Naming',package:'Language',score:2,importance:2},{name:'AlphaTopics',score:1,importance:3},],recommended_for:'a severe problem with talking'},'moderate-severe':{icon:"moderate-severe",label:"Moderate-Severe: With effort and help, can say some appropriate words and phrases.",recommendations:[{name:'Naming',package:'Language',score:5,importance:1},{name:'Apraxia',score:2,importance:2},{name:'Category',score:1,importance:3},],recommended_for:'a moderate-severe problem with talking'},moderate:{icon:"moderate",label:"Moderate: Can participate in routine conversations with familiar partners using simple words and phrases. With help, can use short sentences.",recommendations:[{name:'Naming',package:'Language',score:5,importance:1},{name:'Conversation',score:2,importance:2},{name:'Number',score:1,importance:3},],recommended_for:'a moderate problem with talking'},'mild-moderate':{icon:"mild-moderate",label:"Mild-Moderate: Can speak to anyone, but isn't always able to get the message across clearly.",recommendations:[{name:'Advanced Naming',package:'Advanced Language',score:5,importance:1},{name:'Conversation',score:2,importance:2},],recommended_for:'a mild-moderate problem with talking'},mild:{icon:"mild",label:"Mild: Able to communicate effectively in most everyday situations, but occasionally has word-finding problems or difficulty expressing complex ideas.",recommendations:[{name:'Conversation',score:5,importance:1},{name:'Advanced Naming',package:'Advanced Language',score:2,importance:2},],recommended_for:'a mild problem with talking'}}},understanding:{icon:"ear-hearing",name:"Understanding",description:"auditory comprehension",question:"How bad is the problem?",answer_type:"radio",options:{severe:{icon:"severe",label:"Severe: Follows simple, personally-relevant directions and answers simple yes/no questions in context, but needs slow, simplified speech and visual supports.",recommendations:[{name:'Comprehension',package:'Language',score:5,importance:1},{name:'Category',score:1,importance:3},],recommended_for:'a severe problem with understanding'},'moderate-severe':{icon:"moderate-severe",label:"Moderate-Severe: Follows simple directions and answers yes/no questions most of the time with some help. Struggles with complex messages and less-frequent words.",recommendations:[{name:'Comprehension',package:'Language',score:5,importance:1},{name:'Category',score:2,importance:2},],recommended_for:'a moderate-severe problem with understanding'},moderate:{icon:"moderate",label:"Moderate: Understands everyday conversations with familiar partners, but still needs help with details and more complex ideas.",recommendations:[{name:'Advanced Comprehension',package:'Advanced Language',score:5,importance:1},{name:'Number',score:1,importance:3},],recommended_for:'a moderate problem with understanding'},'mild-moderate':{icon:"mild-moderate",label:"Mild-Moderate: Understands most conversations with anyone, but complicated ideas may require restating or written supports.",recommendations:[{name:'Advanced Comprehension',package:'Advanced Language',score:5,importance:1},{name:'Advanced Reading',package:'Advanced Language',score:2,importance:2},],recommended_for:'a mild-moderate problem with understanding'},mild:{icon:"mild",label:"Mild: Able to follow complex directions and understand most conversations, but occasionally has difficulty with work or social activities in large groups or for complex sentences.",recommendations:[{name:'Advanced Reading',package:'Advanced Language',score:5,importance:1},{name:'Advanced Comprehension',package:'Advanced Language',score:2,importance:2},],recommended_for:'a mild problem with understanding'}}},writing:{icon:"pencil",name:"Writing",description:"written expression",question:"How bad is the problem?",answer_type:"radio",options:{severe:{icon:"severe",label:"Severe: Can write own name with help, and copies letters and words.",recommendations:[{name:'Writing',package:'Language',score:5,importance:1},],recommended_for:'a severe problem with writing'},'moderate-severe':{icon:"moderate-severe",label:"Moderate-Severe: Can write common words independently, but needs help for longer or less familiar ones.",recommendations:[{name:'Writing',package:'Language',score:5,importance:1},{name:'Advanced Writing',package:'Advanced Language',score:2,importance:2},],recommended_for:'a moderate-severe problem with writing'},moderate:{icon:"moderate",label:"Moderate: Can write words and phrases needed for daily activities, but needs help to write sentences.",recommendations:[{name:'Advanced Comprehension',package:'Advanced Language',score:5,importance:1},{name:'Advanced Writing',package:'Advanced Language',score:2,importance:2},],recommended_for:'a moderate problem with writing'},'mild-moderate':{icon:"mild-moderate",label:"Mild-Moderate: Can write sentences, but needs help with paragraphs, complex sentences, and challenging words.",recommendations:[{name:'Advanced Writing',package:'Advanced Language',score:5,importance:1},{name:'Advanced Naming',package:'Advanced Language',score:2,importance:2},{name:'Number',score:1,importance:3},],recommended_for:'a mild-moderate problem with writing'},mild:{icon:"mild",label:"Mild: Can write paragraphs, but may need to use strategies or tools to help. Difficulties may still be noticed in work-related writing or for more complex ideas.",recommendations:[{name:'Advanced Writing',package:'Advanced Language',score:5,importance:1},{name:'Conversation',score:2,importance:2},],recommended_for:'a mild problem with writing'}}},reading:{icon:"book",name:"Reading",description:"reading comprehension",question:"How bad is the problem?",answer_type:"radio",options:{severe:{icon:"severe",label:"Severe: Recognizes letters and common words with help.",recommendations:[{name:'Comprehension',package:'Language',score:5,importance:1},{name:'Visual Attention',score:1,importance:3},],recommended_for:'a severe problem with reading'},'moderate-severe':{icon:"moderate-severe",label:"Moderate-Severe: Reads common words, but needs help for less familiar words.",recommendations:[{name:'Comprehension',package:'Language',score:5,importance:1},{name:'Reading',package:'Language',score:2,importance:2},{name:'Category',score:1,importance:3},],recommended_for:'a moderate-severe problem with reading'},moderate:{icon:"moderate",label:"Moderate: Reads words and phrases in daily activities, but needs help with sentences or more complex words.",recommendations:[{name:'Reading',package:'Language',score:5,importance:1},{name:'Advanced Comprehension',package:'Advanced Language',score:2,importance:2},{name:'Number',score:1,importance:3},],recommended_for:'a moderate problem with reading'},'mild-moderate':{icon:"mild-moderate",label:"Mild-Moderate: Reads simple sentences well, but needs help with complex sentences and paragraphs.",recommendations:[{name:'Advanced Reading',package:'Advanced Language',score:5,importance:1},{name:'Advanced Comprehension',package:'Advanced Language',score:2,importance:2},],recommended_for:'a mild-moderate problem with reading'},mild:{icon:"mild",label:"Mild: Reads most things well, but it takes longer than usual and is tiring.",recommendations:[{name:'Advanced Reading',package:'Advanced Language',score:5,importance:1},{name:'Advanced Comprehension',package:'Advanced Language',score:2,importance:2},],recommended_for:'a mild problem with reading'}}},speech:{icon:"speech",name:"Slurred Speech",description:"dysarthria",question:"How bad is the problem?",answer_type:"radio",options:{severe:{icon:"severe",label:"Severe: Tries to speak, but the sounds are unclear with limited oral movements. A partner must interpret the message through context.",recommendations:[{name:'AlphaTopics',score:5,importance:1},{name:'Advanced Writing',package:'Advanced Language',score:2,importance:2,exceptions:{writing:['severe']}},],recommended_for:'a severe problem with speech'},'moderate-severe':{icon:"moderate-severe",label:"Moderate-Severe: Some words are intelligible, but oral movements are imprecise and repetitions are required to be understood.",recommendations:[{name:'Speech Flipbook',score:5,importance:1},{name:'AlphaTopics',score:2,importance:2},],recommended_for:'a moderate-severe problem with speech'},moderate:{icon:"moderate",label:"Moderate: Can be understood by familiar partners in routine conversations. Strangers have a difficult time understanding.",recommendations:[{name:'Apraxia',score:5,importance:1},{name:'Naming',package:'Language',score:2,importance:2},],recommended_for:'a moderate problem with speech'},'mild-moderate':{icon:"mild-moderate",label:"Mild-Moderate: The speech problem is obvious, but it doesn't get in the way of communication in most situations. Increased effort or strategies are required.",recommendations:[{name:'Conversation',score:5,importance:1,exceptions:{talking:['severe','moderate-severe',]}},{name:'Advanced Reading',package:'Advanced Language',score:2,importance:2,exceptions:{talking:['severe','moderate-severe',]}},],recommended_for:'a mild-moderate problem with speech'},mild:{icon:"mild",label:"Mild: Speech is generally normal, but it can become slurred or irregular when tired or stressed.",recommendations:[{name:'Conversation',score:5,importance:1,exceptions:{talking:['severe','moderate-severe',]}},{name:'Advanced Naming',package:'Advanced Language',score:2,importance:2,exceptions:{talking:['severe','moderate-severe',]}},],recommended_for:'a mild problem with speech'},}},thinking:{icon:"thinking",name:"Thinking Skills",description:"cognition",question:"What do you want to work on?",answer_type:"radio",options:{speed:{icon:"speedometer",label:"Speed of Processing",recommendations:[{name:'Visual Attention',score:5,importance:1},{name:'Advanced Naming',package:'Advanced Language',score:2,importance:2,exceptions:{talking:['severe','moderate-severe','moderate']}},],recommended_for:'improving speed of processing',exceptions:[{issue:'talking',severity:'severe'}]},attention:{icon:"gears",label:"Attention",recommendations:[{name:'Visual Attention',score:5,importance:1},{name:'Advanced Comprehension',package:'Advanced Language',score:2,importance:2,exceptions:{understanding:['severe','moderate-severe']}},],recommended_for:'improving attention'},memory:{icon:"lightbulb",label:"Memory",recommendations:[{name:'Spaced Retrieval',score:5,importance:1},{name:'Number',score:2,importance:2},],recommended_for:'improving memory'},organizing:{icon:"categories",label:"Organizing Thoughts",recommendations:[{name:'Category',score:5,importance:1},{name:'Advanced Naming',package:'Advanced Language',score:2,importance:2,exceptions:{talking:['severe','moderate-severe','moderate']}},],recommended_for:'improving thought organization'},reasoning:{icon:"magnifying-glass",label:"Reasoning",recommendations:[{name:'Conversation',score:5,importance:1,exceptions:{talking:['severe','moderate-severe','moderate']}},{name:'Category',score:2,importance:2},],recommended_for:'improving reasoning'},}}}}};var issuesOrder={talking:1,understanding:2,writing:3,reading:4,speech:5,thinking:6};var appOrder={"Language":{order:1,fullname:'Language x',id:56},"Advanced Language":{order:2,fullname:'Advanced Language x',id:153},"Comprehension":{order:4,fullname:'Comprehension x',id:170},"Naming":{order:5,fullname:'Naming x',id:166},"Reading":{order:6,fullname:'Reading x',id:171},"Writing":{order:7,fullname:'Writing x',id:172},"Advanced Naming":{order:8,fullname:'Advanced Naming x',id:167},"Advanced Comprehension":{order:9,fullname:'Advanced Comprehension x',id:168},"Advanced Reading":{order:10,fullname:'Advanced Reading x',id:174},"Advanced Writing":{order:11,fullname:'Advanced Writing x',id:175},"Conversation":{order:12,fullname:'Conversation x',id:111},"Apraxia":{order:13,fullname:'Apraxia x',id:152},"Category":{order:16,fullname:'Category x',id:150},"Number":{order:17,fullname:'Number x',id:155},"Visual Attention":{order:18,fullname:'Visual Attention x',id:24},"Dysphagia":{order:19,fullname:'Dysphagia x',id:156},"Speech Flipbook":{order:20,fullname:'Speech FlipBook Standard',id:178},"Spaced Retrieval":{order:21,fullname:'Spaced Retrieval x',id:165},"AlphaTopics":{order:22,fullname:'AlphaTopics - AAC',id:177}};var appFinderSetup={getSelections:function(){var step_1_selection=jQuery("#app-finder-step_1 input[name='step_1']:checked").val();var step_2_selections=[];jQuery.each(jQuery("#app-finder-step_2 input[name='step_2']:checked"),function(){step_2_selections.push(jQuery(this).val())});var step_3_selections={};jQuery.each(jQuery('#app-finder-step_3 .question-options'),function(){jQuery.each(jQuery(this).find('input.step_3:checked'),function(){if(!step_3_selections.hasOwnProperty(jQuery(this).attr('name'))){step_3_selections[jQuery(this).attr('name')]=[]}
step_3_selections[jQuery(this).attr('name')].push(jQuery(this).val())})});return{step_1:step_1_selection,step_2:step_2_selections,step_3:step_3_selections}},step_1:function(selections){log('Setup: step_1');selections=(typeof selections!=='undefined')?selections:{};if(selections.hasOwnProperty('step_1')){jQuery("#app-finder-step_1 input[name='step_1'][value='"+selections.step_1+"']").prop('checked',!0);if(selections.step_1=='professional_toolbox'||selections.step_1=='professional_client'){jQuery('#user_type_pro').prop('checked',!0)}
if(selections.step_1=='home_user'){jQuery('#user_type_home').prop('checked',!0)}}
jQuery('.app-finder-step').removeClass('active');jQuery('#app-finder-step_1').addClass('active')},step_2:function(selections){log('Setup: step_2');selections=(typeof selections!=='undefined')?selections:{};jQuery('#app-finder-step_2 .question').html('');jQuery('#app-finder-step_2 .question-options').html('');if(selections.hasOwnProperty('step_1')){switch(selections.step_1){case 'professional_toolbox':jQuery('.app-finder').attr('data-flow','pro');jQuery('#app-finder-step_2 .question').html(app_finder_db.pro.question);for(workType in app_finder_db.pro.options){var option=app_finder_db.pro.options[workType];jQuery('#app-finder-step_2 .question-options').append('<div class="form-check">'+'<input class="form-check-input" type="radio" name="step_2" id="'+workType+'" value="'+workType+'">'+'<label class="form-check-label" for="'+workType+'">'+'<div class="icon-wrapper"><span class="icon icon-'+option.icon+' is-style-outline icon-sm icon-tactus-purple"></span></div>'+'<span>'+option.label+(option.description.length>0?' <small>('+option.description+')</small>':'')+'</span>'+'</label>'+'</div>')}
break;case 'professional_client':case 'home_user':jQuery('.app-finder').attr('data-flow','home');jQuery('#app-finder-step_2 .question').html(app_finder_db.home.question);for(issue in app_finder_db.home.options){var option=app_finder_db.home.options[issue];jQuery('#app-finder-step_2 .question-options').append('<div class="form-check">'+'<input class="form-check-input" type="checkbox" name="step_2" id="'+issue+'" value="'+issue+'">'+'<label class="form-check-label" for="'+issue+'">'+'<div class="icon-wrapper"><span class="icon icon-'+option.icon+' is-style-outline icon-sm icon-tactus-purple"></span></div>'+'<span>'+option.name+(option.description.length>0?' <small>('+option.description+')</small>':'')+'</span>'+'</label>'+'</div>')}
break}}
if(selections.hasOwnProperty('step_1')){jQuery("#app-finder-step_1 input[name='step_1'][value='"+selections.step_1+"']").prop('checked',!0);if(selections.step_1=='professional_toolbox'||selections.step_1=='professional_client'){jQuery('#user_type_pro').prop('checked',!0)}
if(selections.step_1=='home_user'){jQuery('#user_type_home').prop('checked',!0)}}
if(selections.hasOwnProperty('step_2')){selections.step_2.forEach(function(item){jQuery("#app-finder-step_2 input[value='"+item+"']").prop('checked',!0)})}
jQuery('.app-finder-step').removeClass('active');jQuery('#app-finder-step_2').addClass('active')},step_3:function(selections){log('Setup: step_3');selections=(typeof selections!=='undefined')?selections:{};jQuery('#app-finder-step_3 .options').html('');if(selections.hasOwnProperty('step_2')){selections.step_2.forEach(function(issue,index){var option=app_finder_db.home.options[issue];jQuery('#app-finder-step_3 .options').append('<div id="option_'+issue+'" class="option">'+'<h4 class="question"></h4>'+'<div class="form-group question-options"></div>'+'</div>');jQuery('#app-finder-step_3 .options .option:last-child .question').html(option.name+' - '+option.question);for(severity in option.options){var q_option=option.options[severity];if(option.answer_type=='radio'){jQuery('#app-finder-step_3 .options .option:last-child .question-options').append('<div class="form-check">'+'<input class="form-check-input step_3" type="radio" name="'+issue+'" id="'+issue+'_'+severity+'" value="'+severity+'">'+'<label class="form-check-label" for="'+issue+'_'+severity+'">'+'<div class="icon-wrapper"><span class="icon icon-'+q_option.icon+' icon-tiny icon-tactus-purple"></span></div>'+q_option.label+'</label>'+'</div>')}else if(option.answer_type=='checkbox'){jQuery('#app-finder-step_3 .options .option:last-child .question-options').append('<div class="form-check">'+'<input class="form-check-input step_3" type="checkbox" name="'+issue+'" id="'+issue+'_'+severity+'" value="'+severity+'">'+'<label class="form-check-label" for="'+issue+'_'+severity+'">'+'<div class="icon-wrapper"><span class="icon icon-'+q_option.icon+' icon-tiny icon-tactus-purple"></span></div>'+q_option.label+'</label>'+'</div>')}}})}
if(selections.hasOwnProperty('step_1')){jQuery('#app-finder-step_1 input[name="step_1"][value="'+selections.step_1+'"]').prop('checked',!0);if(selections.step_1=='professional_toolbox'||selections.step_1=='professional_client'){jQuery('#user_type_pro').prop('checked',!0)}
if(selections.step_1=='home_user'){jQuery('#user_type_home').prop('checked',!0)}}
if(selections.hasOwnProperty('step_2')){selections.step_2.forEach(function(item){jQuery("#app-finder-step_2 input[value='"+item+"']").prop('checked',!0)})}
if(selections.hasOwnProperty('step_3')){for(var issue in selections.step_3){selections.step_3[issue].forEach(function(item){jQuery('#app-finder-step_3 input[name="'+issue+'"][value="'+item+'"]').prop('checked',!0)})}}
jQuery('.app-finder-step').removeClass('active');jQuery('#app-finder-step_3').addClass('active')},results:function(selections){log('Setup: results');selections=(typeof selections!=='undefined')?selections:{};var flow=jQuery('.app-finder').attr('data-flow');jQuery('#app-finder-results .results').html('');if(flow=='home'&&selections.hasOwnProperty('step_3')){var recommendations=getHomeRecommendations(selections);var recommended_issues=[];recommendations.forEach(function(recommendation,i){var best_str='The best app'+(recommendation.apps.length>1?'s':'');var more_str=(recommendation.apps.length>1)?'Other great apps':'Another great app';jQuery('#app-finder-results .results').append('<div class="result">'+'<h4>'+(recommendation.recommended_for.every(function(val){return recommended_issues.indexOf(val)>=0})?more_str:best_str)+' for '+recommendation.group+' '+(recommendation.apps.length>1?'are:':'is:')+'</h4>'+'<div class="apps"></div>'+'</div>');recommendation.apps.forEach(function(app){jQuery('#app-finder-results .results .result:last-child .apps').append(app_finder_app_cards[appOrder[app].id])});recommended_issues=recommended_issues.concat(recommendation.recommended_for);recommended_issues=recommended_issues.filter(function(item,pos){return recommended_issues.indexOf(item)==pos})})}
if(flow=='pro'&&selections.hasOwnProperty('step_2')){var recommendations=getProRecommendations(selections);recommendations.forEach(function(recommendation,i){jQuery('#app-finder-results .results').append('<div class="results_content"><p>'+recommendation.content+'</p></div>');if(recommendation.apps.length>0){jQuery('#app-finder-results .results').append('<div class="result">'+'<h4>The best apps for '+recommendation.group+' '+(recommendation.apps.length>1?'are:':'is:')+'</h4>'+'<div class="apps"></div>'+'</div>');recommendation.apps.forEach(function(app){jQuery('#app-finder-results .results .result:last-child .apps').append(app_finder_app_cards[appOrder[app].id])})}else{}})}
jQuery('.app_finder_email_form .recommendations').val(JSON.stringify(recommendations));if(selections.hasOwnProperty('step_1')){jQuery('#app-finder-step_1 input[name="step_1"][value="'+selections.step_1+'"]').prop('checked',!0);if(selections.step_1=='professional_toolbox'||selections.step_1=='professional_client'){jQuery('#user_type_pro').prop('checked',!0);jQuery('#intercept_user_type_pro').prop('checked',!0)}
if(selections.step_1=='home_user'){jQuery('#user_type_home').prop('checked',!0);jQuery('#intercept_user_type_home').prop('checked',!0)}}
if(selections.hasOwnProperty('step_2')){selections.step_2.forEach(function(item){jQuery("#app-finder-step_2 input[value='"+item+"']").prop('checked',!0)})}
if(selections.hasOwnProperty('step_3')){for(var issue in selections.step_3){selections.step_3[issue].forEach(function(item){jQuery('#app-finder-step_3 input[name="'+issue+'"][value="'+item+'"]').prop('checked',!0)})}}
jQuery('.app-finder-step').removeClass('active');jQuery('#app-finder-results').addClass('active');if(jQuery('#app-finder-results').hasClass('intercept')){setTimeout(function(){jQuery('#app-finder-results .results-intercept').addClass('loaded');window.scrollTo(0,jQuery('.app-finder').closest('.app-finder').closest('section').offset().top-40)},4000)}
if(typeof wp!=='undefined'&&wp.currency){set_currency(wp.currency)}}}
jQuery(function($){function scrollToHash(duration){var scrollStart=$(window).scrollTop();var currentTime=0;var incrementTime=20;var animateScroll=function(){currentTime+=incrementTime;var distance=calculateScrollDistance(currentTime,scrollStart,$(hashTarget).offset().top-scrollStart,duration);$(window).scrollTop(distance);if(currentTime<duration){setTimeout(animateScroll,incrementTime)}}
animateScroll()}
function calculateScrollDistance(t,b,c,d){t/=d/2;if(t<1)return c/2*t*t+b;t--;return-c/2*(t*(t-2)-1)+b}
if(hashTarget&&$(hashTarget).length>0){scrollToHash(200)}
jQuery('.row > div:has(> .card:only-child)').addClass('d-flex');var navbarShrink=function(){if($(window).scrollTop()>50){$("#header").addClass("header-shrink")}else{$("#header").removeClass("header-shrink")}};navbarShrink();var navbarDisplay=function(){var el=document.scrollingElement||document.documentElement;var scrollTop=($(el).scrollTop()<=0)?0:($(el).scrollTop()>$(el).prop('scrollHeight')-$(el).outerHeight())?$(el).prop('scrollHeight')-$(el).outerHeight():$(el).scrollTop();var scrollHeight=$("#wrapper").hasClass('active-x')?$('#main_navbar').outerHeight()+$('#top_x').outerHeight():$('#main_navbar').outerHeight();if(scrollTop>lastScrollTop&&scrollTop>scrollHeight){$("#wrapper").addClass("scrolled")}else{$("#wrapper").removeClass("scrolled")}
lastScrollTop=scrollTop}
$('#main_nav').on('show.bs.collapse',function(e){$('.navbar-toggler').addClass('open');$('body').addClass('nav-open')});$('#main_nav').on('hide.bs.collapse',function(e){$('.navbar-toggler').removeClass('open');$('body').removeClass('nav-open')});$('#main_nav a').on('click',function(){$('#main_nav').collapse('hide')});$('#main_nav .dropdown-toggle').on('click',function(){if(!$(this).closest('.dropdown').hasClass('show')){$('#main_nav').find('.dropdown, .dropdown-menu').removeClass('show')}
$(this).closest('.dropdown').toggleClass('show');$(this).siblings('.dropdown-menu').toggleClass('show')});$(document).click(function(event){if($(event.target).closest("#main_nav").get(0)==null&&$(document).width()>=768){$('#main_nav').find('.dropdown, .dropdown-menu').removeClass('show')}});var _clientY=null;function disableRubberBand(e){var clientY=e.targetTouches[0].clientY-_clientY;if($('body').hasClass('nav-open')){if(clientY>0&&$('#main_navbar').scrollTop()===0){e.preventDefault()}}else if($('body').hasClass('filter-open')){if(clientY>0&&$('.filters.open').scrollTop()===0){e.preventDefault()}}
if(clientY<0&&isOverlayTotallyScrolled()){e.preventDefault()}}
function isOverlayTotallyScrolled(){if($('body').hasClass('nav-open')){return $('#main_navbar').prop('scrollHeight')-$('#main_navbar').scrollTop()<=$('#main_navbar').outerHeight()}else if($('body').hasClass('filter-open')){return $('.filters.open').prop('scrollHeight')-$('.filters.open').scrollTop()<=$('.filters.open').outerHeight()}}
$('#wrapper').on('touchstart',function(){if($('body').hasClass('nav-open')||$('body').hasClass('filter-open')){if(event.targetTouches.length===1){_clientY=event.targetTouches[0].clientY}}});$('#wrapper').on('touchmove',function(e){if($('body').hasClass('nav-open')||$('body').hasClass('filter-open')){if(event.targetTouches.length===1){disableRubberBand(event)}}});function showx(x,animate){animate=(typeof animate==='undefined')?!0:animate;var today=new Date();var now=today.getTime();$('#header').prepend('<div id="top_x" '+(x.type=='sale'?'class="sale-x"':'')+'>'+'<div class="container">'+'<div class="row align-middle align-center">'+'<div class="col-12 col-sm-8 col-md-7 col-lg-6 col-xl-5">'+(x.type=='sale'&&now>x.changeover_date?'<p id="x_text">Sale ends in <span class="countdown" data-date="'+x.end_date+'"></span></p>':'<p id="x_text">'+x.x_text+'</p>')+'</div>'+'<div class="col-12 col-sm-4 col-md-3 col-lg-2">'+'<p class="btn-row">'+'<a class="btn '+(x.type=='sale'?'btn-tactus-purple':'btn-tactus-teal')+' has-arrow" href="'+x.x_link+'">'+(x.type=='sale'?'Save Now':'Learn More')+'</a>'+'</p>'+'</div>'+'</div>'+'</div>'+'</div>');if(animate){$('#wrapper').addClass('animate-x')}
setTimeout(function(){$('#wrapper').addClass('active-x')},0);$('#top_x .countdown').each(function(){var $this=$(this);var countdown_date=$this.attr('data-date');var update_timer=function(){var now=new Date().getTime();var distance=countdown_date-now;var days=Math.floor(distance/(1000*60*60*24));var hours=Math.floor((distance%(1000*60*60*24))/(1000*60*60));var minutes=Math.floor((distance%(1000*60*60))/(1000*60));var seconds=Math.floor((distance%(1000*60))/1000);days='<span class="number">'+days.toString().split('').join('</span><span class="number">')+'</span>';hours='<span class="number">'+hours.toString().split('').join('</span><span class="number">')+'</span>';minutes='<span class="number">'+minutes.toString().split('').join('</span><span class="number">')+'</span>';seconds='<span class="number">'+seconds.toString().split('').join('</span><span class="number">')+'</span>';$this.html(days+'d '+hours+'h '+minutes+'m '+seconds+'s');if(distance<0){clearInterval(x);$('#top_x').remove();$('#wrapper').removeClass('active-x');$('.app-card,.bundle-card').removeClass('sale');$('.app-card .app-price, .bundle-card .app-price').removeClass('sale');removeStorage('x_info')}};var x=setInterval(update_timer,1000);update_timer()})}
function showSalePrice(id,sale_prices){var item=$('.app-card[data-app-id='+id+'], .bundle-card[data-bundle-id='+id+']')
$(item).find('.app-price').addClass('sale');if(!$(item).find('.app-price .sale-value').length){$(item).find('.app-price .price-value').after('<span class="sale-value loading">$</span>')}
$(item).find('.app-price .currency-dropdown .dropdown-item').each(function(){$(this).attr('data-sale-price',sale_prices[$(this).attr('data-currency')])});var currency=getCookie('currency')||'usd';var active_item=$(item).find('.app-price .currency-dropdown .dropdown-item[data-currency="'+currency+'"]');$(item).find('.app-price .price-value').text(active_item.attr('data-prefix')+active_item.attr('data-price'));$(item).find('.app-price .sale-value').removeClass('loading').text(active_item.attr('data-prefix')+active_item.attr('data-sale-price'));$(item).find('.app-price .currency-dropdown .currency-value').text(active_item.text());if(typeof app_finder_app_cards!=='undefined'&&app_finder_app_cards.hasOwnProperty(id)){var app_card=$(app_finder_app_cards[id]);app_card.find('.app-price').addClass('sale');app_card.find('.app-price .price-value').after('<span class="sale-value">$</span>');app_card.find('.app-price .currency-dropdown .dropdown-item').each(function(){$(this).attr('data-sale-price',sale_prices[$(this).attr('data-currency')])});app_finder_app_cards[id]=app_card}}
var x_info=getStorage('x_info');if(x_info){var x=JSON.parse(x_info);var today=new Date();var now=today.getTime();if(now>x.start_date&&now<x.end_date){console.log('x from storage');showx(x,!1)}else{removeStorage('x_info')}}
$.get('//tactusx.com/wp-json/wp/v2/sale',function(sales){var today=new Date();var now=today.getTime();var offset=today.getTimezoneOffset();var filtered_sales=sales.filter(function(sale){var start=new Date(sale.start_date*1000).getTime();var end=new Date(sale.end_date*1000).getTime();return(now>start&&now<end)});if(filtered_sales.length>0){var fetched_apps=!1;var fetched_bundles=!1;var active_sale=filtered_sales[0];var active_sale_start=new Date(active_sale.start_date*1000).getTime();var active_sale_end=new Date(active_sale.end_date*1000).getTime();var active_sale_changeover=(active_sale.has_last_minute_text)?new Date(active_sale.last_minute_change_over_date*1000).getTime():active_sale_end+(1000*60);var active_sale_link=active_sale.x_link;var active_sale_items=active_sale.items_on_sale;var x={type:'sale',id:active_sale.id,x_text:active_sale.sale_text,x_link:active_sale_link,start_date:active_sale_start,changeover_date:active_sale_changeover,end_date:active_sale_end,items_on_sale:active_sale_items,sale_prices:{}};if($('#top_x').length){$('#top_x').remove();showx(x,!1)}else{showx(x)}
$.each(active_sale_items,function(index,id){var item=$('.app-card[data-app-id='+id+'], .bundle-card[data-bundle-id='+id+']');$(item).find('.app-price').addClass('sale');$(item).find('.app-price .price-value').after('<span class="sale-value loading">$</span>');$(item).find('.app-price .currency-dropdown .dropdown-item').attr('data-sale-price','')});$.get('//tactusx.com/wp-json/wp/v2/app?per_page=100',function(apps){$.each(apps,function(index,app){if(active_sale_items.indexOf(app.id)!==-1){showSalePrice(app.id,app.sale_prices);x.sale_prices[app.id]=app.sale_prices}});fetched_apps=!0;if(fetched_bundles){setStorage('x_info',JSON.stringify(x))}});$.get('//tactusx.com/wp-json/wp/v2/bundle?per_page=100',function(bundles){$.each(bundles,function(index,bundle){if(active_sale_items.indexOf(bundle.id)!==-1){showSalePrice(bundle.id,bundle.sale_prices);x.sale_prices[bundle.id]=bundle.sale_prices}});fetched_bundles=!0;if(fetched_apps){setStorage('x_info',JSON.stringify(x))}})}else{$.get('//tactusx.com/wp-json/wp/v2/info-x',function(xs){var today=new Date();var now=today;var offset=today.getTimezoneOffset();var filtered_xs=xs.filter(function(x){var start=new Date(x.start_date*1000);var end=new Date(x.end_date*1000);return(now.getTime()>start.getTime()&&now.getTime()<end.getTime())});if(filtered_xs.length>0){var active_x=filtered_xs[0];var x={type:'info-x',id:active_x.id,x_text:active_x.x_text,x_link:active_x.x_link,start_date:new Date(active_x.start_date*1000).getTime(),end_date:new Date(active_x.end_date*1000).getTime(),};if($('#top_x').length){$('#top_x').remove();showx(x,!1)}else{showx(x)}
setStorage('x_info',JSON.stringify(x))}else{$('#top_x').remove();$('#wrapper').removeClass('active-x');$('.app-card,.bundle-card').removeClass('sale');$('.app-card .app-price, .bundle-card .app-price').removeClass('sale');removeStorage('x_info')}})}});$('#search_widget .card-header').on('click',function(){$('#search_widget').toggleClass('open');$('body').toggleClass('search-open')});$('#search_widget .search-button').on('click',function(){$('#search_widget').removeClass('open');$('body').removeClass('search-open')});$('#search_widget .search-box').on('keyup',function(e){if(e.keyCode===13){$('#search_widget').removeClass('open');$('body').removeClass('search-open')}});var searchWidgetDisplay=function(){var scrollheight=($('section.x:first-child').length==1)?$('section.x:first-child').outerHeight():0
if($(window).scrollTop()>scrollheight){$("#search_widget").addClass("scrolled")}};searchWidgetDisplay();$('.accordion, .accordion-tabs').on('show.bs.collapse','.collapse',function(){var item=$(this).closest('.accordion-item')
item.addClass('open')});$('.accordion, .accordion-tabs').on('hide.bs.collapse','.collapse',function(){var item=$(this).closest('.accordion-item')
item.removeClass('open')});$('.bundle-app .app-icon').popover({trigger:'hover',placement:'bottom'});$('a').each(function(){var is_anchor=new RegExp('(?:'+window.location.origin+window.location.pathname+'#[a-zA-Z0-9_-]+|^#[a-zA-Z0-9_-]+)');var is_internal=new RegExp('(?:'+window.location.host+'|tactusx.com|help.tactusx.com)');if(is_anchor.test(this.href)){$(this).on('click',function(e){e.preventDefault();var hash=$(this).attr('href');var pos=$(hash).offset().top;window.scrollTo(0,pos);history.replaceState(null,null,hash);return!1})}else if(!is_internal.test(this.href)){$(this).attr({'target':'_blank','onclick':"if(typeof gtag === 'function') gtag('event', 'Click', { 'event_category': 'OutboundLink', 'event_label': '"+this.href+"' });"})}});if($.fn.slick){$('.testimonials .slider, .testimonials.slider').on('init',function(event,slick){setTimeout(function(){$(slick.$slideTrack).css({'height':$(slick.$slideTrack).height()+'px'})},1000)}).on('breakpoint',function(event,slick,breakpoint){$(slick.$slideTrack).css({'height':$(slick.$slideTrack).height()+'px'})}).slick({autoplay:!0,autoplaySpeed:8000,slide:'.slide',slidesToShow:3,speed:600,swipe:!1,responsive:[{breakpoint:375,settings:{slidesToShow:1}},{breakpoint:576,settings:{slidesToShow:1}},{breakpoint:768,settings:{slidesToShow:1}},{breakpoint:992,settings:{slidesToShow:1}},{breakpoint:1200,settings:{slidesToShow:3}}]});$('.tips .slider, .tips.slider').on('init',function(event,slick){setTimeout(function(){$(slick.$slideTrack).css({'height':$(slick.$slideTrack).height()+'px'})},100)}).on('breakpoint',function(event,slick,breakpoint){$(slick.$slideTrack).css({'height':$(slick.$slideTrack).height()+'px'})}).slick({autoplay:!1,slide:'.slide',slidesToShow:2,speed:600,swipe:!1,responsive:[{breakpoint:375,settings:{slidesToShow:1}},{breakpoint:576,settings:{slidesToShow:1}},{breakpoint:768,settings:{slidesToShow:1}},{breakpoint:992,settings:{slidesToShow:1}},{breakpoint:1200,settings:{slidesToShow:2}}]});$('.wp-block-tactus-video').each(function(){var id=$(this).attr('id');var num_slides=$('#slider_'+id).find('.slide').length;$('#slider_'+id).on('beforeChange',function(event,slick,currentSlide,nextSlide){var iframes=$(slick.$slides[currentSlide]).find('iframe');if(iframes.length>0){iframes[0].contentWindow.postMessage(JSON.stringify({'event':'command','func':'pauseVideo','args':[]}),"*")}}).slick({autoplay:!1,arrows:!1,fade:!0,slide:'.slide',slidesToShow:1,speed:600,swipe:!1,asNavFor:'#slider-nav_'+id});$('#slider-nav_'+id).on('init',function(event,slick){if(slick.$slides.length<=5)
$(slick.$slider).addClass('inactive');if(slick.$slides.length<=3)
$(slick.$slider).addClass('inactive-mobile')}).slick({slidesToShow:(num_slides<5?num_slides:5),slidesToScroll:1,centerMode:!0,focusOnSelect:!0,asNavFor:'#slider_'+id,responsive:[{breakpoint:576,settings:{slidesToShow:(num_slides<3?num_slides:3)}},]})});$('.screenshots .slider').slick({autoplay:!0,autoplaySpeed:5000,arrows:!1,slide:'.slide',slidesToShow:1,speed:600,swipe:!1});$('.screenshots .carousel .carousel-inner .carousel-item:first-child').addClass('active');$('.series-articles.slider').on('init',function(event,slick){setTimeout(function(){$(slick.$slideTrack).css({'height':$(slick.$slideTrack).height()+'px'})},100)}).on('breakpoint',function(event,slick,breakpoint){$(slick.$slideTrack).css({'height':$(slick.$slideTrack).height()+'px'})}).slick({autoplay:!0,autoplaySpeed:8000,slide:'.slide',slidesToShow:3,speed:600,swipe:!1,responsive:[{breakpoint:375,settings:{slidesToShow:1}},{breakpoint:576,settings:{slidesToShow:1}},{breakpoint:768,settings:{slidesToShow:1}},{breakpoint:992,settings:{slidesToShow:1}},{breakpoint:1200,settings:{slidesToShow:3}}]})}
var deviceScreenshots=$('.screenshots');if("IntersectionObserver" in window){var deviceScreenshotsObserver=new IntersectionObserver(function(entries,observer){entries.forEach(function(entry){if(entry.isIntersecting){var device=$(entry.target);var screenshots=device.find('.screenshot').slice(0,2);screenshots.each(function(){loadScreenshot($(this))});device.find('.carousel').carousel({'interval':4000,}).on('slide.bs.carousel',function(){var nextScreenshot=$(this).find('.screenshot:not(.loaded)').slice(0,1);loadScreenshot(nextScreenshot)});observer.unobserve(entry.target)}})},{rootMargin:'500px 0px'});deviceScreenshots.each(function(){deviceScreenshotsObserver.observe(this)})}
function loadScreenshot(screenshot){var theImage=screenshot.find('img.tactus-lazy-image');var srcset=theImage.attr('data-lazy-srcset');var sizes=theImage.attr('data-lazy-sizes');var theClone=theImage.clone(!0);theClone.removeAttr('data-tactus-lazy-srcset'),theClone.removeAttr('data-tactus-lazy-sizes');theClone.removeAttr('data-tactus-lazy-src');theClone.addClass('tactus-lazy-loaded');theClone.attr('data-tactus-lazy-loaded',1);if(!srcset){theClone.removeAttr('srcset')}else{theClone.attr('srcset',srcset)}
if(sizes){theClone.attr('sizes',sizes)}
theImage.replaceWith(theClone);screenshot.addClass('loaded')}
var adjustParalax=function(){$('.bg-pattern').css({'background-position':'center '+$(window).scrollTop()/2+'px'})}
adjustParalax();var lastScrollTop=0;$(window).scroll(function(){navbarShrink();adjustParalax();searchWidgetDisplay();if($(document).width()<768){navbarDisplay()}else{if($('#main_nav').find('.dropdown.show').length>0){$('#main_nav').find('.dropdown, .dropdown-menu').removeClass('show')}}});$("body").on("input propertychange",".floating-label-form-group",function(e){$(this).toggleClass("floating-label-form-group-with-value",!!$(e.target).val())}).on("focus",".floating-label-form-group",function(){$(this).addClass("floating-label-form-group-with-focus")}).on("blur",".floating-label-form-group",function(){$(this).removeClass("floating-label-form-group-with-focus")});$('.search-box').on('blur',function(e){if($('.search-box').length>1){$('.search-box').val($(this).val())}});$('.convertkit-form form').on('submit',function(e){e.preventDefault();var form=$(this);form.removeClass('error');if(form.find('[name="first_name"]').val()==''||form.find('[name="email"]').val()==''||form.find('[name="user"]:checked').val()==''){form.addClass('error');form.find('.error_message').html('Please complete all fields.');return}
if(!form.hasClass('pending')){form.addClass('pending');$.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:form.serialize(),success:function(response){if(response.status=='ok'){var selection=form.find('[name="user"]:checked').val();var form_id=selection.indexOf('-')!=-1?selection.substr(selection.indexOf('-')+1):'';form.find('.success_message').html(response.message);form.addClass('success');if(typeof gtag==='function')gtag('event','Submit',{'event_category':'FormFill','event_label':form_id})}else{form.addClass('error');form.find('.error_message').html(response.message)}},error:function(jqXHR){form.addClass('error');form.find('.error_message').html('Sorry, we seem to be experiencing problems. Please try again later.')},complete:function(){form.removeClass('pending')}})}});$(document).on('click','.formkit-submit',function(){var form=$(this).closest('form');var form_id=form.attr('data-sv-form');if(typeof gtag==='function')gtag('event','Submit',{'event_category':'FormFill','event_label':form_id})});$('#go_finder_2').on('click',function(){var selections=appFinderSetup.getSelections();var url='';var flow='';if(selections.hasOwnProperty('step_1')){switch(selections.step_1){case 'professional_toolbox':url='/find/pro/';flow='ProFlow';break;case 'professional_client':case 'home_user':url='/find/home/';flow='HomeFlow';break;default:alert("Please make a selection before continuing.");return}}
jQuery.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:{action:'app_finder_log_results',session_id:$('.app-finder').attr('data-session-id'),flow_id:$('.app-finder').attr('data-flow-id'),selections:{step_1:selections.step_1},},success:function(response){if(response.status=='ok'){$('.app-finder').attr('data-session-id',response.session_id);$('.app-finder').attr('data-flow-id',response.flow_id)}}});$('#back_finder_1').removeClass('direct');appFinderSetup.step_2(selections);if(typeof gtag==='function')gtag('event',flow,{'event_category':'AppFinder','event_label':'Step1'});history.replaceState({page:'app-finder',activeStep:'step_1',stepSelections:selections},null,'');history.pushState({page:'app-finder',activeStep:'step_2',stepSelections:selections},null,url);window.scrollTo(0,$('.app-finder').closest('section').offset().top-40)});$('#go_finder_3').on('click',function(){var selections=appFinderSetup.getSelections();var flow=(selections.step_1=='home_user'||selections.step_1=='professional_client')?'HomeFlow':'ProFlow';if(!selections.hasOwnProperty('step_2')||selections.step_2.length==0){alert("You must select at least one area to improve.");return}
jQuery.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:{action:'app_finder_log_results',session_id:$('.app-finder').attr('data-session-id'),flow_id:$('.app-finder').attr('data-flow-id'),selections:{step_1:selections.step_1,step_2:selections.step_2},},success:function(response){if(response.status=='ok'){$('.app-finder').attr('data-session-id',response.session_id);$('.app-finder').attr('data-flow-id',response.flow_id)}}});appFinderSetup.step_3(selections);if(typeof gtag==='function')gtag('event',flow,{'event_category':'AppFinder','event_label':'Step2'});history.replaceState({page:'app-finder',activeStep:'step_2',stepSelections:selections},null,'');history.pushState({page:'app-finder',activeStep:'step_3',stepSelections:selections},null,'');window.scrollTo(0,$('.app-finder').closest('section').offset().top-40)});$('#skip_to_finder_4').on('click',function(){var selections=appFinderSetup.getSelections();var flow=(selections.step_1=='home_user'||selections.step_1=='professional_client')?'HomeFlow':'ProFlow';if(!selections.hasOwnProperty('step_2')||selections.step_2==''){alert("Please make a selection before continuing.");return}
$('#app_finder_email_form_card').removeClass('in').removeClass('in-m').removeClass('open');$('.app_finder_email_form').removeClass('error');$('.app_finder_email_form').removeClass('success');if($('#app-finder-results').hasClass('intercept')){$('#app-finder-results').removeClass('intercept-complete');$('#app-finder-results').removeClass('intercept-skipped');$('#app-finder-results .results-intercept').removeClass('loaded')}
appFinderSetup.results(selections);if(typeof gtag==='function')gtag('event',flow,{'event_category':'AppFinder','event_label':'Step2'});history.replaceState({page:'app-finder',activeStep:'step_2',stepSelections:selections},null,'');history.pushState({page:'app-finder',activeStep:'results',stepSelections:selections},null,'');window.scrollTo(0,$('.app-finder').closest('section').offset().top-40)});$('#go_finder_4').on('click',function(){var selections=appFinderSetup.getSelections();var flow=(selections.step_1=='home_user'||selections.step_1=='professional_client')?'HomeFlow':'ProFlow';if(!selections.hasOwnProperty('step_3')||Object.keys(selections.step_3).length<selections.step_2.length){alert("Please answer all questions before continuing.");return}
$('#app_finder_email_form_card').removeClass('in').removeClass('in-m').removeClass('open');$('.app_finder_email_form').removeClass('error');$('.app_finder_email_form').removeClass('success');if($('#app-finder-results').hasClass('intercept')){$('#app-finder-results').removeClass('intercept-complete');$('#app-finder-results').removeClass('intercept-skipped');$('#app-finder-results .results-intercept').removeClass('loaded')}
appFinderSetup.results(selections);if(typeof gtag==='function')gtag('event',flow,{'event_category':'AppFinder','event_label':'Step3'});history.replaceState({page:'app-finder',activeStep:'step_3',stepSelections:selections},null,'');history.pushState({page:'app-finder',activeStep:'results',stepSelections:selections},null,'');window.scrollTo(0,$('.app-finder').closest('section').offset().top-40)});$('#go_finder_1').on('click',function(){jQuery.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:{action:'app_finder_log_results',session_id:$('.app-finder').attr('data-session-id'),flow_id:$('.app-finder').attr('data-flow-id'),start_over:1,},success:function(response){if(response.status=='ok'){$('.app-finder').attr('data-session-id',response.session_id);$('.app-finder').removeAttr('data-flow-id')}}});$('#app-finder-step_2 .question').html('');$('#app-finder-step_2 .question-options').html('');$('#app-finder-step_3 .options').html('');$('#app-finder-results .results').html('');$('#app-finder-results').removeClass('active');$('#app-finder-step_1').addClass('active');history.pushState({page:'app-finder',activeStep:'step_1'},null,'/find/');window.scrollTo(0,$('.app-finder').closest('section').offset().top-40)});$('#back_finder_1').on('click',function(){if($(this).hasClass('direct')){var selections=appFinderSetup.getSelections();$('#app-finder-step_2').removeClass('active');$('#app-finder-step_1').addClass('active');history.replaceState({page:'app-finder',activeStep:'step_1',stepSelections:selections},null,'/find/')}else{jQuery.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:{action:'app_finder_log_results',session_id:$('.app-finder').attr('data-session-id'),flow_id:$('.app-finder').attr('data-flow-id'),back:2,},success:function(response){if(response.status=='ok'){$('.app-finder').attr('data-session-id',response.session_id);$('.app-finder').removeAttr('data-flow-id')}}});window.history.back()}
window.scrollTo(0,$('.app-finder').closest('section').offset().top-40)});$('#back_finder_2').on('click',function(){jQuery.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:{action:'app_finder_log_results',session_id:$('.app-finder').attr('data-session-id'),flow_id:$('.app-finder').attr('data-flow-id'),back:3,},success:function(response){if(response.status=='ok'){$('.app-finder').attr('data-session-id',response.session_id);$('.app-finder').removeAttr('data-flow-id')}}});window.history.back();window.scrollTo(0,$('.app-finder').closest('section').offset().top-40)});$('#back_finder_3').on('click',function(){jQuery.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:{action:'app_finder_log_results',session_id:$('.app-finder').attr('data-session-id'),flow_id:$('.app-finder').attr('data-flow-id'),back:4,},success:function(response){if(response.status=='ok'){$('.app-finder').attr('data-session-id',response.session_id);$('.app-finder').removeAttr('data-flow-id')}}});window.history.back();window.scrollTo(0,$('.app-finder').closest('section').offset().top-40)});$('#app-finder-results').on('click','.back_finder_3',function(){jQuery.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:{action:'app_finder_log_results',session_id:$('.app-finder').attr('data-session-id'),flow_id:$('.app-finder').attr('data-flow-id'),back:4,},success:function(response){if(response.status=='ok'){$('.app-finder').attr('data-session-id',response.session_id);$('.app-finder').removeAttr('data-flow-id')}}});window.history.back();window.scrollTo(0,$('.app-finder').closest('section').offset().top-40);return!1});if("IntersectionObserver" in window){var appFInderEmailFormObserver=new IntersectionObserver(function(entries,observer){entries.forEach(function(entry){if(entry.isIntersecting){var buttons=$(entry.target);if(!$('#app_finder_email_form_card').hasClass('in')&&!$('#app_finder_email_form_card').hasClass('in-m')){$('#app_finder_email_form_card').addClass('in').addClass('in-m')}}})},{rootMargin:'-75px 0px'});$('#app-finder-results.slide-form .step-navigation').each(function(){appFInderEmailFormObserver.observe(this)})}
$('.toggle-email-form-card').on('click',function(){if($(document).width()<768){$('#app_finder_email_form_card').toggleClass('open')}else{$('#app_finder_email_form_card').toggleClass('in')}});$('#skip_intercept').on('click',function(){jQuery.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:{action:'app_finder_log_results',session_id:$('.app-finder').attr('data-session-id'),flow_id:$('.app-finder').attr('data-flow-id'),intercept_skip:1,},success:function(response){if(response.status=='ok'){$('.app-finder').attr('data-session-id',response.session_id);$('.app-finder').attr('data-flow-id',response.flow_id)}}});$(this).closest('#app-finder-results').addClass('intercept-skipped');window.scrollTo(0,$('.app-finder').closest('.app-finder').closest('section').offset().top-40)});$('.app_finder_email_form').on('submit',function(e){e.preventDefault();$(this).removeClass('error');if($(this).find('input[name="first_name"]').val()==''||$(this).find('input[name="email"]').val()==''||$(this).find('[name="user_type"]:checked').val()==''){$(this).addClass('error');$(this).find('.error_message').html('Please complete all fields.');return}
if(!$(this).hasClass('pending')){$(this).addClass('pending');if($(this).closest('.results-intercept').length>0){$(this).closest('#app-finder-results').addClass('intercept-pending')}
$(this).find('.recommendations_html').val($('#app-finder-results .results').html());var selections=appFinderSetup.getSelections();var flow=(selections.step_1=='home_user'||selections.step_1=='professional_client')?'HomeFlow':'ProFlow';var form=$(this);$.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:form.serialize(),success:function(response){if(response.status=='ok'){form.find('.success_message').html(response.message);form.addClass('success');var data={action:'app_finder_log_results',session_id:$('.app-finder').attr('data-session-id'),flow_id:$('.app-finder').attr('data-flow-id'),};if(form.closest('.results-intercept').length>0){data.intercept_email=1;setTimeout(function(){form.closest('#app-finder-results').addClass('intercept-complete');form.closest('#app-finder-results').removeClass('intercept-pending');window.scrollTo(0,$('.app-finder').closest('section').offset().top-40)},2000);if(typeof gtag==='function')gtag('event',flow,{'event_category':'AppFinder','event_label':'InterceptEmail'})}else{data.email=1;if(typeof gtag==='function')gtag('event',flow,{'event_category':'AppFinder','event_label':'ResultsEmail'})}
jQuery.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:data,success:function(response){if(response.status=='ok'){$('.app-finder').attr('data-session-id',response.session_id);$('.app-finder').attr('data-flow-id',response.flow_id)}}})}else{form.addClass('error');form.find('.error_message').html(response.message);if(form.closest('.results-intercept').length>0){form.closest('#app-finder-results').removeClass('intercept-pending')}}},error:function(jqXHR){form.addClass('error');form.find('.error_message').html('Sorry, we seem to be experiencing problems. Please try again later.');if(form.closest('.results-intercept').length>0){form.closest('#app-finder-results').removeClass('intercept-pending')}},complete:function(){form.removeClass('pending')}})}});$('.app-finder').on('click','.app-card .btn',function(){var btn=$(this).text();var app_id=$(this).closest('.app-card').attr('data-app-id');var app=Object.keys(appOrder).find(key=>appOrder[key].id==app_id);jQuery.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:{action:'app_finder_log_results',session_id:$('.app-finder').attr('data-session-id'),flow_id:$('.app-finder').attr('data-flow-id'),click:{app:app,btn:btn},},success:function(response){if(response.status=='ok'){$('.app-finder').attr('data-session-id',response.session_id);$('.app-finder').attr('data-flow-id',response.flow_id)}}})});$('.filters-label, .filter-close').on('click',function(){$(this).closest('.filters-content').find('.filters').toggleClass('open');if($(this).closest('.filters-content').find('.filters').hasClass('open')){$('body').addClass('filters-open')}else{$('body').removeClass('filters-open')}});$('.filter-label').on('click',function(){$(this).closest('.filter').toggleClass('open')});$('.filter-choices input').on('change',function(){var target=$(this).closest('#filter-bar').attr('data-filter-target');var filter=$(this).closest('.filter').attr('data-filter');var filter_option=$(this).attr('data-filter-option');var filter_option_label=$(this).attr('data-filter-option-label');if(!$(this).hasClass('active')){$(this).addClass('active');$(this).closest('#filter-bar').find('.active-filters').append('<div class="active-filter" data-filter="'+filter+'" data-filter-option="'+filter_option+'">'+filter_option_label+'<span class="filter-delete"></span></div>')}else{$(this).removeClass('active');$(this).closest('#filter-bar').find('.active-filters .active-filter[data-filter="'+filter+'"][data-filter-option="'+filter_option+'"]').remove()}
update_filters(target)});$('.active-filters').on('click','.filter-delete',function(){var filter=$(this).closest('.active-filter').attr('data-filter');var filter_option=$(this).closest('.active-filter').attr('data-filter-option');$('.filter[data-filter="'+filter+'"] .filter-choices input[data-filter-option="'+filter_option+'"]').prop('checked',!1).trigger('change')});$('.sort-dropdown .dropdown-item').on('click',function(){var target=$(this).closest('#filter-bar').attr('data-filter-target');var selection_text=$(this).text();var sort=$(this).attr('data-sort');var order=$(this).attr('data-order');$(this).closest('.sort-dropdown').find('.sort-value').text(selection_text);var cards=$(target).children().sort(function(a,b){var attr_a=$(a).attr('data-'+sort);var attr_b=$(b).attr('data-'+sort);attr_a=$.isNumeric(attr_a)?Number(attr_a):attr_a;attr_b=$.isNumeric(attr_b)?Number(attr_b):attr_b;var comparison=(attr_a<attr_b)?-1:(attr_a>attr_b)?1:0;return(order=='asc')?comparison:comparison*-1}).appendTo($(target))});function update_filters(target){var filters={};$('#filter-bar[data-filter-target="'+target+'"] .active-filters .active-filter').each(function(){var filter=$(this).attr('data-filter');var filter_option=$(this).attr('data-filter-option');if(filters.hasOwnProperty(filter)){filters[filter].push(filter_option)}else{filters[filter]=[filter_option]}});$(target).children().each(function(){var match=!0;for(var filter_category in filters){var atts=$(this).attr('data-'+filter_category).split(',');for(var filter in filters[filter_category]){if(atts.indexOf(filters[filter_category][filter])>-1){match=!0;break}
match=!1}
if(!match)break}
if(!match){$(this).attr("style","display: none !important;")}else{$(this).removeAttr('style')}});$('#filter-bar[data-filter-target="'+target+'"]').find('.results-value').text($(target).find('> :visible').length);var filter_params=Object.keys(filters).map(function(filter){return filter+'='+filters[filter]}).join('&');if(filter_params.length===0)
history.replaceState({},null,'/apps/');else history.replaceState({},null,'/apps/?'+filter_params)}
if($('body').hasClass('page-apps')&&$('#filter-bar').length>0){var filters=Array('languages','disorders','platforms');$.each(filters,function(index,filter){var filter_value=getUrlParamByName(filter);if(filter_value){var set_filter=filter_value.split(',');$.each(set_filter,function(index,value){var input=$('#filter-bar .filters .filter[data-filter="'+filter+'"] input[data-filter-option="'+value+'"]');input.prop('checked',!0).addClass('active').closest('#filter-bar').find('.active-filters').append('<div class="active-filter" data-filter="'+filter+'" data-filter-option="'+value+'">'+input.attr('data-filter-option-label')+'<span class="filter-delete"></span></div>')})}});update_filters($('#filter-bar').attr('data-filter-target'))}
$('body').on('click','.currency-dropdown .dropdown-item',function(){var expireTime=new Date();expireTime.setTime(expireTime.getTime()+(365*24*60*60*1000));var currency=$(this).attr('data-currency');document.cookie="currency="+currency+"; path=/;expires="+expireTime.toGMTString();set_currency(currency)});if(typeof wp!=='undefined'&&wp.currency){set_currency(wp.currency)}
window.addEventListener('popstate',function(e){var data=e.state||{};if(data.hasOwnProperty('page')&&data.page=='app-finder'){appFinderSetup[data.activeStep](data.stepSelections)}})});jQuery.fn.responsiveTables=function(){var breakpoint='991px';return this.each(function(i){i++;var className='responsive-table-'+i;var $this=jQuery(this);$this.addClass(className);var respondHtml='<style type="text/css">\n';respondHtml+='@media only screen and (max-width:'+breakpoint+'){\n';if($this.find('thead').length>0){$this.find('thead th').each(function(i){var $tdText=jQuery(this).text().replace(/\s+/g,' ');i++;respondHtml+='.'+className+' > tbody > tr > td.responsive-table-cell-'+i+':before{ content: "'+$tdText+'"; }\n'})}
$this.find('tbody > tr').each(function(i){var $this=jQuery(this);i++;var arrColspan=[];var modIndex=[];$this.find('td').each(function(i,c,m){var $this=jQuery(this);i++;if(modIndex>0){modIndex[0];i++}
if(arrColspan>0){m=i+arrColspan.shift()-1;modIndex.splice(0,1);modIndex.push(m);i=m}
if($this.is('[colspan]')){c=parseInt(jQuery(this).prop('colspan'),10);arrColspan.push(c)}
$this.addClass('responsive-table-cell-'+i)})});if($this.find('thead').length>0){respondHtml+='}\n';respondHtml+='</style>';$this.before(respondHtml)}})};jQuery('.responsive-table table').responsiveTables();function getCookie(cname){var name=cname+"=";var decodedCookie=decodeURIComponent(document.cookie);var ca=decodedCookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1)}
if(c.indexOf(name)==0){return c.substring(name.length,c.length)}}
return""}
function setCookie(cname,cvalue,exdays){var d=new Date();d.setTime(d.getTime()+(exdays*24*60*60*1000));var expires="expires="+d.toUTCString();document.cookie=cname+"="+cvalue+";"+expires+";path=/"}
function getStorage(name){if(!window.localStorage)return!1;return window.localStorage.getItem(name)}
function setStorage(name,value){if(!window.localStorage)return!1;window.localStorage.setItem(name,value)}
function removeStorage(name){if(!window.localStorage)return!1;window.localStorage.removeItem(name)}
function getProRecommendations(selections,log_results){selections=(typeof selections!=='undefined')?selections:{};log_results=(typeof log_results!=='undefined')?log_results:!1;var choices=(typeof selections.step_2!=='undefined')?selections.step_2:{};log('%cChoices:','color:blue; font-weight:bold;');log('    ',choices);var recommendations=[];for(var i in choices){var newGroup={group:app_finder_db.pro.options[choices[i]].recommended_for,apps:[],content:app_finder_db.pro.options[choices[i]].recommendation_content};for(var j in app_finder_db.pro.options[choices[i]].recommendations){var app=app_finder_db.pro.options[choices[i]].recommendations[j];newGroup.apps.push(app.name)}
recommendations.push(newGroup)}
jQuery.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:{action:'app_finder_log_results',session_id:jQuery('.app-finder').attr('data-session-id'),flow_id:jQuery('.app-finder').attr('data-flow-id'),selections:{step_1:selections.step_1,step_2:selections.step_2},final_results:recommendations},success:function(response){if(response.status=='ok'){jQuery('.app-finder').attr('data-session-id',response.session_id);jQuery('.app-finder').attr('data-flow-id',response.flow_id)}}});return recommendations}
function getHomeRecommendations(selections,log_results){log('');log('%cGet Recommendations','font-weight:bold; text-decoration:underline;');selections=(typeof selections!=='undefined')?selections:{};log_results=(typeof log_results!=='undefined')?log_results:!1;var choices=(typeof selections.step_3!=='undefined')?selections.step_3:{};log('%cChoices:','color:blue; font-weight:bold;');log('    ',choices);if(log_results){var talking=(choices.hasOwnProperty('talking'))?choices.talking[0]:"NONE";var understanding=(choices.hasOwnProperty('understanding'))?choices.understanding[0]:"NONE";var writing=(choices.hasOwnProperty('writing'))?choices.writing[0]:"NONE";var reading=(choices.hasOwnProperty('reading'))?choices.reading[0]:"NONE";var speech=(choices.hasOwnProperty('speech'))?choices.speech[0]:"NONE";var thinking=(choices.hasOwnProperty('thinking'))?choices.thinking[0]:"NONE";switch(speech){case 'sounds':speech='improving';break;case 'visuals':speech='supplementing'}
switch(thinking){case 'speed':thinking='speed of processing';break;case 'organizing':thinking='organization';break}}
var overlap=!1;var numChoices=0;var recommendations=[];var storedExceptionScore=0;var storedExceptionImportance=0;for(var issue in choices){numChoices++;for(var i in choices[issue]){for(var j in app_finder_db.home.options[issue].options[choices[issue][i]].recommendations){var app=app_finder_db.home.options[issue].options[choices[issue][i]].recommendations[j];log('');log('%cProcessing: %c'+app.name+' %cas recommendation '+app.importance+' for '+issue,'color:blue; font-weight:bold;','color:black; font-weight:bold;','font-weight:normal;');var exception=!1;for(var area in app.exceptions){log('    %cException: %c'+area+' = '+app.exceptions[area].join(' || '),'color:red; font-weight:bold;','color:black; font-weight:normal;');if(choices.hasOwnProperty(area)&&app.exceptions[area].includes(choices[area][0])){exception=!0;storedExceptionScore=app.score;storedExceptionImportance=app.importance;break}}
var exists=!1;for(k in recommendations){if(recommendations[k].name==app.name){exists=!0;if(!exception){overlap=!0;recommendations[k].score+=(storedExceptionScore>0)?storedExceptionScore:app.score;if(recommendations[k].recommended_for.filter(function(reco){return(reco.reason==app_finder_db.home.options[issue].options[choices[issue][i]].recommended_for)}).length==0){recommendations[k].recommended_for.push({issue:issue,reason:app_finder_db.home.options[issue].options[choices[issue][i]].recommended_for,importance:(storedExceptionImportance>0)?storedExceptionImportance:app.importance})}
if(storedExceptionScore>0)storedExceptionScore=0;if(storedExceptionImportance>0)storedExceptionImportance=0;log('    %cNew Recommendations: %cfor '+app_finder_db.home.options[issue].options[choices[issue][i]].recommended_for,'color:green; font-weight:bold;','color:black; font-weight:normal;');log('%cOverlap Created','color:grey; font-weight:bold;')}
break}
if(recommendations[k].hasOwnProperty('package')&&app.hasOwnProperty('package')&&recommendations[k].package==app.package){overlap=!0;log('%cOverlap Created from Packages','color:grey; font-weight:bold;')}}
if(!exists&&!exception){var newRecommendation={name:app.name,score:(storedExceptionScore>0)?storedExceptionScore:app.score,recommended_for:[{issue:issue,reason:app_finder_db.home.options[issue].options[choices[issue][i]].recommended_for,importance:(storedExceptionImportance>0)?storedExceptionImportance:app.importance,}]};if(storedExceptionScore>0)storedExceptionScore=0;if(storedExceptionImportance>0)storedExceptionImportance=0;if(app.hasOwnProperty('package')){newRecommendation.package=app.package}
recommendations.push(newRecommendation);log('    %cAdding: %c'+newRecommendation.name+' %cfor '+newRecommendation.recommended_for[0].reason,'color:green; font-weight:bold;','color:black; font-weight:bold;','font-weight:normal;');log('    ',newRecommendation)}
if(exception)log('    %cSkipping: %c'+app.name,'color:gold; font-weight:bold;','color:black; font-weight:bold;')}}}
recommendations.sort(function(a,b){return(a.score<b.score)?1:((b.score<a.score)?-1:((appOrder[a.name].order>appOrder[b.name].order)?1:-1))});if(log_results){var rawRecommendationsString='';if(Object.keys(choices).length>1){for(var i in recommendations){rawRecommendationsString+=appOrder[recommendations[i].name].fullname+' : '+recommendations[i].score+', '}}else{rawRecommendationsString='SINGLE SELECTION'}}
log('');log('%cRecommendations:','color:blue; font-weight:bold;');log('    ',recommendations);var recommendationsWithPackages=determineRecommendedPackages(recommendations);if(log_results){var packageRecommendationsString='';if(Object.keys(choices).length>1){for(var i in recommendationsWithPackages){packageRecommendationsString+=appOrder[recommendationsWithPackages[i].name].fullname+' : '+recommendationsWithPackages[i].score+', '}}else{packageRecommendationsString='SINGLE SELECTION'}}
log('');log('%cRecommendations:','color:blue; font-weight:bold;');log('    ',recommendationsWithPackages);var finalRecommendations=getFinalRecommendations(choices,recommendationsWithPackages);if(!overlap){log('Re-sort recommendations due to No Overlap');finalRecommendations.sort(function(a,b){return((issuesOrder[a.recommended_for[0].issue]>issuesOrder[b.recommended_for[0].issue])?1:((issuesOrder[b.recommended_for[0].issue]>issuesOrder[a.recommended_for[0].issue])?-1:((a.score<b.score)?1:-1)))})}
log('');log('%cRecommendations:','color:blue; font-weight:bold;');log('    ',finalRecommendations);var finalGroupedRecommendations=groupRecommendations(finalRecommendations,(numChoices==1));if(log_results){var finalRecommendationsString='';for(var i in finalGroupedRecommendations){for(var j in finalGroupedRecommendations[i].apps){finalRecommendationsString+=appOrder[finalGroupedRecommendations[i].apps[j]].fullname+', '}}
var csv_line=['"'+talking,understanding,writing,reading,speech,thinking,finalRecommendationsString+'"'].join('", "');document.write(csv_line+'<br/>')}
jQuery.ajax({url:wp.ajaxurl,method:'POST',dataType:'json',data:{action:'app_finder_log_results',session_id:jQuery('.app-finder').attr('data-session-id'),flow_id:jQuery('.app-finder').attr('data-flow-id'),selections:selections,raw_results:recommendations,final_results:finalGroupedRecommendations},success:function(response){if(response.status=='ok'){jQuery('.app-finder').attr('data-session-id',response.session_id);jQuery('.app-finder').attr('data-flow-id',response.flow_id)}}});log('');log('%cFinal Recommendations:','color:blue; font-weight:bold;');log('    ',finalGroupedRecommendations);return finalGroupedRecommendations}
function determineRecommendedPackages(recommendations){log('');log('%cDetermine Packages','font-weight:bold; text-decoration:underline;');var packages=recommendations.reduce(function(acc,cur){if(cur.hasOwnProperty('package')){log('');log('%cProcessing Package: %c'+cur.package,'color:blue; font-weight:bold;','color:black; font-weight:bold;');var exists=!1;for(var i in acc.packages){if(acc.packages[i].package.name==cur.package){exists=!0;acc.packages[i].package.score+=cur.score;log('    %cRecording Existing Package: %c'+acc.packages[i].package.name+' %crecommended from '+cur.name,'color:green; font-weight:bold;','color:black;','font-weight:normal;');acc.packages[i].apps.push(cur.name);log('    %cAdding App to Package: %c'+cur.name,'color:green; font-weight:bold;','color:black;','font-weight:normal;');for(var j in cur.recommended_for){if(acc.packages[i].package.recommended_for.filter(function(reco){return(reco.reason==cur.recommended_for[j].reason&&reco.importance==cur.recommended_for[j].importance)}).length==0){acc.packages[i].package.recommended_for.push({issue:cur.recommended_for[j].issue,reason:cur.recommended_for[j].reason,importance:cur.recommended_for[j].importance})}}
log('    ',jQuery.extend(!0,{},acc.packages[i]));break}}
if(!exists){var newPackage={package:{name:cur.package,score:cur.score,recommended_for:[],},apps:[cur.name]};for(var k in cur.recommended_for){newPackage.package.recommended_for.push({issue:cur.recommended_for[k].issue,reason:cur.recommended_for[k].reason,importance:cur.recommended_for[k].importance})}
acc.packages.push(newPackage);log('    %cRecording Package: %c'+newPackage.package.name+' %crecommended from '+cur.name,'color:green; font-weight:bold;','color:black; font-weight:bold;','font-weight:normal;');log('    ',jQuery.extend(!0,{},newPackage.package))}}
return acc},{packages:[]}).packages.filter(function(p){return(p.apps.length>=2)});log('');log('%cPackages:','color:blue; font-weight:bold;');log('    ',jQuery.extend(!0,{},packages));var recommendationsWithPackages=(packages.length==0)?recommendations:recommendations.filter(function(r){for(var i=0;i<packages.length;i++){if(r.package==packages[i].package.name)
return!1}
return!0});log('');log('%cRecommendations with out Packages:','color:blue; font-weight:bold;');log('    ',jQuery.extend(!0,{},recommendationsWithPackages));for(var i in packages){recommendationsWithPackages.push(packages[i].package);log('    %cAdding Package to Recommendations: %c'+packages[i].package.name,'color:green; font-weight:bold;','color:black; font-weight:bold;');log('    ',jQuery.extend(!0,{},packages[i].package))}
recommendationsWithPackages.sort(function(a,b){return(a.score<b.score)?1:((b.score<a.score)?-1:((appOrder[a.name].order>appOrder[b.name].order)?1:-1))});return recommendationsWithPackages}
function getFinalRecommendations(choices,recommendations){log('');log('%cDetermine Final Reccomendations','font-weight:bold; text-decoration:underline;');var finalRecommendations=[];var issues=[];for(var i in choices){issues.push(i)}
log('%cLimit Recomendations','color:grey; font-weight:bold;');log('%cIssues:','color:blue; font-weight:bold;');log('    ',issues);for(var i=0;i<recommendations.length;i++){finalRecommendations.push(recommendations[i]);log('');log('    %cAdding: %c'+recommendations[i].name,'color:green; font-weight:bold;','color:black; font-weight:bold;');for(var j=0;j<recommendations[i].recommended_for.length;j++){log('    %cChecking: %c'+recommendations[i].recommended_for[j].issue+' at '+recommendations[i].recommended_for[j].importance,'color:blue; font-weight:bold;','color:black; font-weight:normal;');if(issues.indexOf(recommendations[i].recommended_for[j].issue)>-1&&recommendations[i].recommended_for[j].importance==1){issues.splice(issues.indexOf(recommendations[i].recommended_for[j].issue),1);log('    %cRemoving from Issues: %c'+recommendations[i].recommended_for[j].issue,'color:red; font-weight:bold;','color:black; font-weight:bold;')}}
if(issues.length==0&&finalRecommendations.length>=4){log('%cRequirements Met: %cRecommendation per issues && Minimum 4 recommendations, ','color:grey; font-weight:bold;','color:black; font-weight:normal;');break}}
log('');log('%cRecommendations:','color:blue; font-weight:bold;');log('    ',finalRecommendations);return finalRecommendations}
function groupRecommendations(recommendations,split_non_core){log('%cGroup Recomendations','color:grey; font-weight:bold;');split_non_core=(typeof split_non_core!=='undefined')?split_non_core:!1;var finalGroupedRecommendations=[];recommendations.forEach(function(recommendation){log('');log('%cProcessing: %c'+recommendation.name,'color:blue; font-weight:bold;','color:black; font-weight:bold;');log(recommendation);var forString='';var recommendedIssues=[];for(var j=0;j<recommendation.recommended_for.length;j++){if(!recommendedIssues.includes(recommendation.recommended_for[j].issue)){if(forString.length>0){if(recommendation.recommended_for.map(function(obj){return obj.issue}).filter(function(r,i,array){return!recommendedIssues.includes(r)&&array.indexOf(r)==i}).length==1){forString+=' and '}else{forString+=', '}}
forString+=recommendation.recommended_for[j].reason;recommendedIssues.push(recommendation.recommended_for[j].issue)}}
var highest_importance=Math.max.apply(Math,recommendation.recommended_for.map(function(obj){return obj.importance}));var exists=!1;for(var k=0;k<finalGroupedRecommendations.length;k++){if(finalGroupedRecommendations[k].group==forString&&(!split_non_core||highest_importance<3)){exists=!0;log('    %cAdd to Group: %c'+forString,'color:green; font-weight:bold;','color:black; font-weight:normal;');finalGroupedRecommendations[k].apps.push(recommendation.name);break}}
if(!exists){log('    %cCreate Group: %c'+forString,'color:green; font-weight:bold;','color:black; font-weight:normal;');finalGroupedRecommendations.push({group:forString,recommended_for:recommendedIssues,apps:[recommendation.name]})}});log('');log('%cRecommendations:','color:blue; font-weight:bold;');log('    ',finalGroupedRecommendations);return finalGroupedRecommendations}
function log_results(){for(var f=0;f<=5;f++){for(var e=0;e<=2;e++){for(var d=0;d<=5;d++){for(var c=0;c<=5;c++){for(var b=0;b<=5;b++){for(var a=0;a<=5;a++){var choices={};switch(a){case 1:choices.talking=['mild'];break;case 2:choices.talking=['mild-moderate'];break;case 3:choices.talking=['moderate'];break;case 4:choices.talking=['moderate-severe'];break;case 5:choices.talking=['severe'];break}
switch(b){case 1:choices.understanding=['mild'];break;case 2:choices.understanding=['mild-moderate'];break;case 3:choices.understanding=['moderate'];break;case 4:choices.understanding=['moderate-severe'];break;case 5:choices.understanding=['severe'];break}
switch(c){case 1:choices.writing=['mild'];break;case 2:choices.writing=['mild-moderate'];break;case 3:choices.writing=['moderate'];break;case 4:choices.writing=['moderate-severe'];break;case 5:choices.writing=['severe'];break}
switch(d){case 1:choices.reading=['mild'];break;case 2:choices.reading=['mild-moderate'];break;case 3:choices.reading=['moderate'];break;case 4:choices.reading=['moderate-severe'];break;case 5:choices.reading=['severe'];break}
switch(e){case 1:choices.speech=['visuals'];break;case 2:choices.speech=['sounds'];break}
switch(f){case 1:choices.thinking=['reasoning'];break;case 2:choices.thinking=['organizing'];break;case 3:choices.thinking=['memory'];break;case 4:choices.thinking=['attention'];break;case 5:choices.thinking=['speed'];break}
getHomeRecommendations(choices,!0)}}}}}}
console.log('done results')}
var $appScores2=[{app:"Language x",score:"0",order:1},{app:"Advanced Language x",score:"0",order:2},{app:"Question x",score:"0",order:3},{app:"Comprehension x",score:"0",order:4},{app:"Naming x",score:"0",order:5},{app:"Reading x",score:"0",order:6},{app:"Writing x",score:"0",order:7},{app:"Advanced Naming x",score:"0",order:8},{app:"Advanced Comprehension x",score:"0",order:9},{app:"Advanced Reading x",score:"0",order:10},{app:"Advanced Writing x",score:"0",order:11},{app:"Conversation x",score:"0",order:12},{app:"Apraxia x",score:"0",order:13},{app:"Answering x",score:"0",order:14},{app:"Asking x",score:"0",order:15},{app:"Category x",score:"0",order:16},{app:"Number x",score:"0",order:17},{app:"Visual Attention x",score:"0",order:18},{app:"Speech FlipBook Standard",score:"0",order:19},{app:"Spaced Retrieval x",score:"0",order:20},{app:"AlphaTopics - AAC",score:"0",order:21}];var advLanguageAppPackage=["Advanced Comprehension x","Advanced Naming x","Advanced Reading x","Advanced Writing x"];var languageAppPackage=["Comprehension x","Naming x","Reading x","Writing x"];var $choices=[{section:"talking",recommended:"NONE",secondary:"NONE",noncore:"NONE",intro:"NONE",choice:"NONE",order:1},{section:"reading",recommended:"NONE",secondary:"NONE",noncore:"NONE",intro:"NONE",choice:"NONE",order:4},{section:"cognition",recommended:"NONE",secondary:"NONE",noncore:"NONE",intro:"NONE",choice:"NONE",order:6},{section:"dysathria",recommended:"NONE",secondary:"NONE",noncore:"NONE",intro:"NONE",choice:"NONE",order:5},{section:"understanding",recommended:"NONE",secondary:"NONE",noncore:"NONE",intro:"NONE",choice:"NONE",order:2},{section:"writing",recommended:"NONE",secondary:"NONE",noncore:"NONE",intro:"NONE",choice:"NONE",order:3}];function calc_apps(getWordsVal,getUnderstandVal,getWritingVal,getReadingVal,getUnclearVal,getThinkingVal){console.log(getWordsVal,getUnderstandVal,getWritingVal,getReadingVal,getUnclearVal,getThinkingVal);$choices=[{section:"talking",recommended:"NONE",secondary:"NONE",noncore:"NONE",intro:"NONE",choice:"NONE",order:1},{section:"reading",recommended:"NONE",secondary:"NONE",noncore:"NONE",intro:"NONE",choice:"NONE",order:4},{section:"cognition",recommended:"NONE",secondary:"NONE",noncore:"NONE",intro:"NONE",choice:"NONE",order:6},{section:"dysathria",recommended:"NONE",secondary:"NONE",noncore:"NONE",intro:"NONE",choice:"NONE",order:5},{section:"understanding",recommended:"NONE",secondary:"NONE",noncore:"NONE",intro:"NONE",choice:"NONE",order:2},{section:"writing",recommended:"NONE",secondary:"NONE",noncore:"NONE",intro:"NONE",choice:"NONE",order:3}];var $getWordsVal=getWordsVal?getWordsVal:!1;var $getUnderstandVal=getUnderstandVal?getUnderstandVal:!1;var $getWritingVal=getWritingVal?getWritingVal:!1;var $getReadingVal=getReadingVal?getReadingVal:!1;var $getUnclearVal=getUnclearVal?getUnclearVal:!1;var $getThinkingVal=getThinkingVal?getThinkingVal:!1;var numberSelected=0;$.each($appScores2,function(index,value){$appScores2[index].score="0"});$isVerbalException=!1;$isAuditoryException=!1;if($getWordsVal){numberSelected++;switch(parseInt($getWordsVal)){case 1:tallyScore("Conversation x","Advanced Naming x","Asking x");$choices[0].intro="a mild problem with "+$choices[0].section;$choices[0].recommended="Conversation x";$choices[0].secondary="Advanced Naming x";$choices[0].noncore="Asking x";$choices[0].choice="mild";break;case 2:tallyScore("Advanced Naming x","Conversation x","Asking x");$choices[0].intro="a mild-moderate problem with "+$choices[0].section;$choices[0].recommended="Advanced Naming x";$choices[0].secondary="Conversation x";$choices[0].noncore="Asking x";$choices[0].choice="mild-moderate";break;case 3:tallyScore("Naming x","Conversation x","Number x");$choices[0].intro="a moderate problem with "+$choices[0].section;$choices[0].recommended="Naming x";$choices[0].secondary="Conversation x";$choices[0].noncore="Number x";$choices[0].choice="moderate";$isVerbalException=!0;break;case 4:tallyScore("Naming x","Apraxia x","AlphaTopics - AAC");$choices[0].intro="a moderate-severe problem with "+$choices[0].section;$choices[0].recommended="Naming x";$choices[0].secondary="Apraxia x";$choices[0].noncore="AlphaTopics - AAC";$choices[0].choice="moderate-severe";$isVerbalException=!0;break;case 5:tallyScore("Apraxia x","AlphaTopics - AAC","Speech FlipBook Standard");$choices[0].intro="a severe problem with "+$choices[0].section;$choices[0].recommended="Apraxia x";$choices[0].secondary="AlphaTopics - AAC";$choices[0].noncore="Speech FlipBook Standard";$choices[0].choice="severe";$isVerbalException=!0;break;default:}}
if($getReadingVal){numberSelected++;switch(parseInt($getReadingVal)){case 1:tallyScore("Advanced Reading x","Advanced Comprehension x","NONE");$choices[1].intro="a mild problem with "+$choices[1].section;$choices[1].recommended="Advanced Reading x";$choices[1].secondary="Advanced Comprehension x";$choices[1].noncore="NONE";$choices[1].choice="mild";break;case 2:tallyScore("Advanced Reading x","Advanced Comprehension x","NONE");$choices[1].intro="a mild-moderate problem with "+$choices[1].section;$choices[1].recommended="Advanced Reading x";$choices[1].secondary="Advanced Comprehension x";$choices[1].noncore="NONE";$choices[1].choice="mild-moderate";break;case 3:tallyScore("Reading x","Advanced Comprehension x","Answering x");$choices[1].intro="a moderate problem with "+$choices[1].section;$choices[1].recommended="Reading x";$choices[1].secondary="Advanced Comprehension x";$choices[1].noncore="Answering x";$choices[1].choice="moderate";break;case 4:tallyScore("Comprehension x","Category x","NONE");$choices[1].intro="a moderate-severe problem with "+$choices[1].section;$choices[1].recommended="Comprehension x";$choices[1].secondary="Category x";$choices[1].noncore="NONE";$choices[1].choice="moderate-severe";break;case 5:tallyScore("Comprehension x","NONE","Visual Attention x");$choices[1].intro="a severe problem with "+$choices[1].section;$choices[1].recommended="Comprehension x";$choices[1].secondary="NONE";$choices[1].noncore="Visual Attention x";$choices[1].choice="severe";break;default:}}
if($getUnclearVal){numberSelected++;switch($getUnclearVal){case "unclear-improve":tallyScore("Speech FlipBook Standard","Apraxia x","NONE");$choices[3].intro="improving speech sounds";$choices[3].recommended="Speech FlipBook Standard";$choices[3].secondary="Apraxia x";$choices[3].noncore="NONE";$choices[3].choice="improving";break;case "unclear-supplement":tallyScore("AlphaTopics - AAC","NONE","NONE");$choices[3].intro="supplementing speech";$choices[3].recommended="AlphaTopics - AAC";$choices[3].secondary="NONE";$choices[3].noncore="NONE";$choices[3].choice="supplementing";break;default:}}
if($getUnderstandVal){numberSelected++;switch(parseInt($getUnderstandVal)){case 1:tallyScore("Advanced Comprehension x","Advanced Reading x","NONE");$choices[4].intro="a mild problem with "+$choices[4].section;$choices[4].recommended="Advanced Comprehension x";$choices[4].secondary="Advanced Reading x";$choices[4].noncore="NONE";$choices[4].choice="mild";break;case 2:tallyScore("Advanced Comprehension x","Advanced Reading x","NONE");$choices[4].intro="a mild-moderate problem with "+$choices[4].section;$choices[4].recommended="Advanced Comprehension x";$choices[4].secondary="Advanced Reading x";$choices[4].noncore="NONE";$choices[4].choice="mild-moderate";break;case 3:tallyScore("Advanced Comprehension x","NONE","Number x");$choices[4].intro="a moderate problem with "+$choices[4].section;$choices[4].recommended="Advanced Comprehension x";$choices[4].secondary="NONE";$choices[4].noncore="Number x";$choices[4].choice="moderate";break;case 4:tallyScore("Comprehension x","Category x","Answering x");$choices[4].intro="a moderate-severe problem with "+$choices[4].section;$choices[4].recommended="Comprehension x";$choices[4].secondary="Category x";$choices[4].noncore="Answering x";$choices[4].choice="moderate-severe";$isAuditoryException=!0;break;case 5:tallyScore("Comprehension x","Category x","Answering x");$choices[4].intro="a severe problem with "+$choices[4].section;$choices[4].recommended="Comprehension x";$choices[4].secondary="Category x";$choices[4].noncore="Answering x";$choices[4].choice="severe";$isAuditoryException=!0;break;default:}}
if($getWritingVal){numberSelected++;switch(parseInt($getWritingVal)){case 1:tallyScore("Advanced Writing x","Conversation x","NONE");$choices[5].intro="a mild problem with "+$choices[5].section;$choices[5].recommended="Advanced Writing x";$choices[5].secondary="Conversation x";$choices[5].noncore="NONE";$choices[5].choice="mild";break;case 2:tallyScore("Advanced Writing x","NONE","Asking x");$choices[5].intro="a mild-moderate problem with "+$choices[5].section;$choices[5].recommended="Advanced Writing x";$choices[5].secondary="NONE";$choices[5].noncore="Asking x";$choices[5].choice="mild-moderate";break;case 3:tallyScore("Advanced Writing x","Advanced Comprehension x","NONE");$choices[5].intro="a moderate problem with "+$choices[5].section;$choices[5].recommended="Advanced Writing x";$choices[5].secondary="Advanced Comprehension x";$choices[5].noncore="NONE";$choices[5].choice="moderate";break;case 4:tallyScore("Writing x","Advanced Writing x","NONE");$choices[5].intro="a moderate-severe problem with "+$choices[5].section;$choices[5].recommended="Writing x";$choices[5].secondary="Advanced Writing x";$choices[5].noncore="NONE";$choices[5].choice="moderate-severe";break;case 5:tallyScore("Writing x","NONE","NONE");$choices[5].intro="a severe problem with "+$choices[5].section;$choices[5].recommended="Writing x";$choices[5].secondary="NONE";$choices[5].noncore="NONE";$choices[5].choice="severe";break;default:}}
if($getThinkingVal){numberSelected++;switch($getThinkingVal){case "thinking-speed":if($isVerbalException){tallyScore("Visual Attention x","NONE","NONE");$choices[2].intro="improving speed of processing";$choices[2].recommended="Visual Attention x";$choices[2].secondary="NONE";$choices[2].choice="speed of processing";$choices[2].noncore="NONE"}else{tallyScore("Visual Attention x","Advanced Naming x","NONE");$choices[2].intro="improving speed of processing";$choices[2].recommended="Visual Attention x";$choices[2].secondary="Advanced Naming x";$choices[2].choice="speed of processing";$choices[2].noncore="NONE"}
break;case "thinking-attention":if($isAuditoryException){tallyScore("Visual Attention x","NONE","NONE");$choices[2].intro="improving attention";$choices[2].recommended="Visual Attention x";$choices[2].secondary="NONE";$choices[2].noncore="NONE";$choices[2].choice="attention"}else{tallyScore("Visual Attention x","Advanced Comprehension x","NONE");$choices[2].intro="improving attention";$choices[2].recommended="Visual Attention x";$choices[2].secondary="Advanced Comprehension x";$choices[2].noncore="NONE";$choices[2].choice="attention"}
break;case "thinking-memory":tallyScore("Spaced Retrieval x","Number x","NONE");$choices[2].intro="improving memory";$choices[2].recommended="Spaced Retrieval x";$choices[2].secondary="Number x";$choices[2].noncore="NONE";$choices[2].choice="memory";break;case "thinking-organize":if($isVerbalException){tallyScore("Category x","NONE","NONE");$choices[2].intro="improving thought organization";$choices[2].recommended="Category x";$choices[2].secondary="NONE";$choices[2].noncore="NONE";$choices[2].choice="organization"}else{tallyScore("Category x","Advanced Naming x","NONE");$choices[2].intro="improving thought organization";$choices[2].recommended="Category x";$choices[2].secondary="Advanced Naming x";$choices[2].noncore="NONE";$choices[2].choice="organization"}
break;case "thinking-reason":if($isVerbalException){tallyScore("NONE","Category x","NONE");$choices[2].intro="improving reasoning";$choices[2].recommended="NONE";$choices[2].secondary="Category x";$choices[2].noncore="NONE";$choices[2].choice="reasoning"}else{tallyScore("Conversation x","Category x","NONE");$choices[2].intro="improving reasoning";$choices[2].recommended="Conversation x";$choices[2].secondary="Category x";$choices[2].noncore="NONE";$choices[2].choice="reasoning"}
break;default:}}
if(numberSelected==1){$introsAJAX=[];$objectsArray=[];$passedToAJAX=[];$objectsArray=$choices.filter(function(item){return item.choice!="NONE"});$passedToAJAX[0]=$objectsArray[0].recommended;if($objectsArray[0].secondary!="NONE"){$introsAJAX[0]="For "+$objectsArray[0].intro+", the best apps are:";$passedToAJAX[1]=$objectsArray[0].secondary;$introsAJAX[1]=""}else{$introsAJAX[0]="For "+$objectsArray[0].intro+", the best apps are:"}
if($objectsArray[0].noncore!="NONE"){$passedToAJAX[2]=$objectsArray[0].noncore;$introsAJAX[2]="Another app to try for "+$objectsArray[0].section+" is:"}
$talkingChoice="";$writingchoice="";$understandingchoice="";$readingchoice="";$dysathriachoice="";$cognitionchoice="";$filteredString="SINGLE SELECTION";$weightedString="SINGLE SELECTION";$finalString="";$hyphenString=", ";$.each($passedToAJAX,function(index,value){if(typeof value!="undefined"&&value!=""){$finalString+=value+$hyphenString}});$choices.forEach(function(e){if(e.section=="talking"){$talkingChoice=e.choice}
if(e.section=="writing"){$writingchoice=e.choice}
if(e.section=="understanding"){$understandingchoice=e.choice}
if(e.section=="reading"){$readingchoice=e.choice}
if(e.section=="dysathria"){$dysathriachoice=e.choice}
if(e.section=="cognition"){$cognitionchoice=e.choice}});$("#myCarousel").carousel(2)}else if(numberSelected>1){$moveToDouble=0;$theIndexDouble=0;$exceptedApp="";$isIntroOverlaps=!1;$introCheck=$choices;$appScores2.sort(function(app1,app2){return app2.score-app1.score});setAppPackages();$lastArr=$appScores2;$lastArr.sort(function(app1,app2){return app2.score-app1.score});$filteredString="";$.each($lastArr,function(index,value){if($lastArr[index].score!=0){$filteredString+=$lastArr[index].app+" : "+$lastArr[index].score+", "}});var isDuplicateScore=!1;var isDuplicateScoreDouble=!1;$doubles=[];$firstDuplicatedAppByScore="";$lastDuplicatedAppByScore="";$firstDuplicatedAppByScoreIndex=0;$lastDuplicatedAppByScoreIndex=0;$duplicatedScore=0;$.each($lastArr,function(index,value){if($lastArr[index].score!=0){if($lastArr[index].score==$lastArr[index+1].score){$firstDuplicatedAppByScore=$lastArr[index].app;$firstDuplicatedAppByScoreIndex=index;$duplicatedScore=$lastArr[index].score;return!1}}});$notZero=0;for($i=0;$i<$lastArr.length-1;$i++){if($lastArr[$i].score!=0){$notZero++;if($lastArr[$i].score==$lastArr[$i+1].score){if($doubles.indexOf($lastArr[$i].score)==-1){$doubles.push($lastArr[$i].score)}}}}
if($doubles.length>0){isDuplicateScore=!0}
$.each($finalArray,function(index,value){if($finalArray[index].score!=0){$weightedString+=index+" : "+value+", "}});$dupScoreSort=[];$scoreTiedString="";$theRestDupIndexTest=999;if(isDuplicateScore){$.each($lastArr,function(index,value){if($lastArr[index].score==$duplicatedScore){$lastDuplicatedAppByScore=$lastArr[index].app;$lastDuplicatedAppByScoreIndex=index}});if($firstDuplicatedAppByScoreIndex==0){$dupScoreSort=$lastArr.slice($firstDuplicatedAppByScoreIndex,$lastDuplicatedAppByScoreIndex+1);$theRest=$lastArr.slice($lastDuplicatedAppByScoreIndex+1,$notZero);$dupScoreSort.sort(function(app1,app2){return app1.order-app2.order});if($doubles.length>1){$theRestDupIndex=99;$theRestDupLastIndex=99;$.each($theRest,function(index,value){if($theRest[index].score==$doubles[1]){$theRestDupIndex=index;$theRestDupIndexTest=$theRestDupIndex;return!1}});$.each($theRest,function(index,value){if($theRest[index].score==$doubles[1]){$theRestDupLastIndex=index;$theRestDupIndexTest=$theRestDupLastIndex}});if($theRestDupIndex==0&&$theRestDupLastIndex==$theRest.length-1){$theRest.sort(function(app1,app2){return app1.order-app2.order})}else if($theRestDupIndex==0&&$theRestDupLastIndex!=$theRest.length-1){$dupTemp=$theRest.slice(0,$theRestDupLastIndex+1);$dupLeftovers=$theRest.slice($theRestDupLastIndex+1,$theRest.length-1);$dupTemp.sort(function(app1,app2){return app1.order-app2.order});$theRest=$dupTemp.concat($dupLeftovers)}}
$lastArr=$dupScoreSort.concat($theRest);$lastArr.forEach(function(item,index){$scoreTiedString+=item.app+"<br />"})}else{$leadingTemp=$lastArr.slice(0,$firstDuplicatedAppByScoreIndex);$dupScoreSortTemp=$lastArr.slice($firstDuplicatedAppByScoreIndex,$lastDuplicatedAppByScoreIndex+1);$theRest=$lastArr.slice($lastDuplicatedAppByScoreIndex+1,$notZero);$dupScoreSortTemp.sort(function(app1,app2){return app1.order-app2.order});$dupScoreSort=$leadingTemp.concat($dupScoreSortTemp);if($doubles.length>1){$theRestDupIndex=99;$theRestDupLastIndex=99;$.each($theRest,function(index,value){if($theRest[index].score==$doubles[1]){$theRestDupIndex=index;return!1}});$.each($theRest,function(index,value){if($theRest[index].score==$doubles[1]){$theRestDupLastIndex=index}});if($theRestDupIndex==0&&$theRestDupLastIndex==$theRest.length-1){$theRest.sort(function(app1,app2){return app1.order-app2.order})}else if($theRestDupIndex==0&&$theRestDupLastIndex!=$theRest.length-1){$dupTemp=$theRest.slice(0,$theRestDupLastIndex+1);$dupLeftovers=$theRest.slice($theRestDupLastIndex+1,$theRest.length-1);$dupTemp.sort(function(app1,app2){return app1.order-app2.order});$theRest=$dupTemp.concat($dupLeftovers)}}
$lastArr=$dupScoreSort.concat($theRest);$lastArr.forEach(function(item,index){$scoreTiedString+=item.app+"<br />"})}}
var keep=($notZero>=4)?4:$notZero;$slicedForAJAX=$lastArr.slice(0,keep);$passedString="";$passedToAJAX=[];$.each($slicedForAJAX,function(index,value){$passedString+=$slicedForAJAX[index].app+" : "+$slicedForAJAX[index].score+"<br />";$passedToAJAX.push($slicedForAJAX[index].app)});mustIncludes();$testarraystring="";var languagePackage=["Comprehension x","Naming x","Reading x","Writing x"];var questionPackage=["Asking x","Answering x"];var advLanguagePackage=["Advanced Comprehension x","Advanced Naming x","Advanced Reading x","Advanced Writing x"];$theItem="";$numChoices=1;$sentToFunction="";var valueArr=$choices.map(function(item){return item.recommended});var valueArr2=$choices.map(function(item){return item.secondary});var valueArr3=$choices.map(function(item){return item.noncore});var choicesValuesTemp=valueArr.concat(valueArr2);var choicesValues=choicesValuesTemp.concat(valueArr3);var choicesValuesFinal=choicesValues.filter(function(item){return item!="NONE"&&typeof item!="undefined"});var doubledApps=choicesValuesFinal.filter(function(item,index){return $passedToAJAX.indexOf(item)!=-1});var isDuplicate=choicesValuesFinal.some(function(item,idx){if(choicesValuesFinal.indexOf(item)!=idx){$theItem=choicesValuesFinal.indexOf(item);$sentToFunction=choicesValuesFinal[$theItem];$numChoices++}
return choicesValuesFinal.indexOf(item)!=idx});var duplicateApps=choicesValuesFinal.filter(function(item,index,array){return array.indexOf(item)!=index&&$passedToAJAX.indexOf(item)!=-1});var areWeIn=!1;$testDuplicateAppsString="";if(duplicateApps.length>0){$isIntroOverlaps=!0;duplicateApps.forEach(function(item,index){$testDuplicateAppsString+=item+":";if(languagePackage.indexOf(item)==-1&&advLanguagePackage.indexOf(item)==-1){var areWeIn=!0;setMultipleIntrosCondensed(item)}else if(languagePackage.indexOf(item)!=-1&&$isLanguageCount<2){var areWeIn=!0;setMultipleIntrosCondensed(item)}else if(advLanguagePackage.indexOf(item)!=-1&&$isLanguageCount<2){var areWeIn=!0;setMultipleIntrosCondensed(item)}})}
$mustIncludeList="";var passedIntros={};$.each($passedToAJAX,function(index,value){passedIntros[value]="NONE"});$introString="";$introIndex=0;$choices.forEach(function(e){if("undefined"!=typeof passedIntros[e.recommended]){passedIntros[e.recommended]=e.intro}
if("undefined"==typeof passedIntros[e.recommended]&&passedIntros["Language x"]){passedIntros["Language x"]=getLanguageIntros(languagePackage)}
if("undefined"==typeof passedIntros[e.recommended]&&passedIntros["Advanced Language x"]){passedIntros["Advanced Language x"]=getAdvLanguageIntros(advLanguagePackage)}
if("undefined"==typeof passedIntros[e.recommended]&&passedIntros["Question x"]){passedIntros["Question x"]=getQuestionIntros(questionPackage)}});$introsAJAX=[];$.each(passedIntros,function(index,value){$appIndex=$passedToAJAX.indexOf(index);if($appIndex!=-1){if(value=="NONE"){value=getSecondaryIntroCondensed(index,$introCheck)}
$introString+="App: "+index+" | Intro: For "+value+"<br />";$introsAJAX.push("For "+value.trim()+", the best app is:")}});$finalIntroString="";for($i=0;$i<$introsAJAX.length;$i++){$finalIntroString+=$introsAJAX[$i]+"<br />"}
$allUnique=checkIfArrayIsUnique($introsAJAX);var justTheOne=$introsAJAX.filter(function(intro,index,array){return array.indexOf(intro)!=index});$doubleDouble=!1;$howManyExtras=0;Array.prototype.contains=function(v){for(var i=0;i<this.length;i++){if(this[i]===v)return!0}
return!1};Array.prototype.unique=function(){var arr=[];for(var i=0;i<this.length;i++){if(!arr.contains(this[i])){arr.push(this[i])}else{$howManyExtras++}}
return arr}
Array.prototype.howMany=function($theApp){$howManyDupIntros=0;$introsAJAX.forEach(function(app,index){if(app==$theApp){$howManyDupIntros++}});return $howManyDupIntros}
Array.prototype.getNonDupedIntro=function($intro){$nonDuppedIntro="";$introsAJAX.forEach(function(intro,index){if(intro!=$intro){$nonDuppedIntro=intro}});return $nonDuppedIntro}
$totalNumberIntroDuplicated=justTheOne.length+$howManyExtras;var uniques=$introsAJAX.unique();$doubleDouble=isDoubleDouble(uniques);$exceptionString="<br />";if($isVerbalException){$exceptionString="Verbal expression true. Advanced Naming x and Conversation Thereapy ineligible.<br /><br />"}
if($isAuditoryException){$exceptionString+=" Auditory comprehension exception true. Advanced Comprehension x ineligible.<br /><br />"}
if(!$allUnique){}
$listSortedApps=[];$listSortedIntros=[];if(!$isIntroOverlaps){resortForListOrder()}
if(!$allUnique){groupIntros($doubleDouble,justTheOne)}
$listSortedApps.forEach(function(e){$listSortedAppsString+=e.appName+" : "+e.appOrder+"<br />"});$finalString="";$.each($passedToAJAX,function(index,value){$finalString+=value+", "});$statsDevString=$exceptionString+"Raw results:<br />"+$weightedString+"<br />Filtered for packages: <br />"+$filteredString+"<br />The initial apps after tiebreaker for last place:<br />"+$passedString+"<br />Top Recommended apps that must be included(unless excluded):<br />"+$mustIncludeList+"<br />Final list:<br />"+$finalString;$testOutputString="Number selected: "+numberSelected+"<br /><br />Weighted :<br /><br />"+$weightedString+"<br />Filtered for packages: <br /><br />"+$filteredString+"<br />Passed to results: <br />"+$passedString+"<br />"+$finalIntroString+"<br />Overlap intros: ";$talkingChoice="";$writingchoice="";$understandingchoice="";$readingchoice="";$dysathriachoice="";$cognitionchoice="";$choices.forEach(function(e){if(e.section=="talking"){$talkingChoice=e.choice}
if(e.section=="writing"){$writingchoice=e.choice}
if(e.section=="understanding"){$understandingchoice=e.choice}
if(e.section=="reading"){$readingchoice=e.choice}
if(e.section=="dysathria"){$dysathriachoice=e.choice}
if(e.section=="cognition"){$cognitionchoice=e.choice}})}else{console.log("Please answer all sections. You can go back and uncheck a section.");return}
var csv_line=['"'+$talkingChoice,$understandingchoice,$writingchoice,$readingchoice,$dysathriachoice,$cognitionchoice,$finalString+'"'].join('", "');document.write(csv_line+'<br/>')}
function tallyScore($recommend,$secondary,$core){if($recommend!="NONE"){var total1=0;$appScores2.forEach(function(e){if($recommend==e.app){total1=parseInt(e.score)+5;e.score=total1}})}
if($secondary!="NONE"){var total2=0;$appScores2.forEach(function(e){if($secondary==e.app){total2=parseInt(e.score)+2;e.score=total2}})}
if($core!="NONE"){var total3=0;$appScores2.forEach(function(e){if($core==e.app){total3=parseInt(e.score)+1;e.score=total3}})}}
function setAppPackages(){$isLanguageCount=0;$isQuestionCount=0;$isAdvLanguageCount=0;$weightedString="";$finalArray={};$.each($appScores2,function(index,value){if($appScores2[index].score!=0){$finalArray[$appScores2[index].app]=$appScores2[index].score}});$.each($finalArray,function(index,value){if(index==="Comprehension x"||index==="Reading x"||index==="Writing x"||index==="Naming x"){$isLanguageCount++}});$.each($finalArray,function(index,value){if(index==="Asking x"||index==="Answering x"){$isQuestionCount++}});$.each($finalArray,function(index,value){if(index==="Advanced Comprehension x"||index==="Advanced Naming x"||index==="Advanced Reading x"||index==="Advanced Writing x"){$isAdvLanguageCount++}});if($isLanguageCount>1){$isIntroOverlaps=!0;$totalLanguageScore=0;$appScores2.forEach(function(e){if("Comprehension x"==e.app){$totalLanguageScore+=parseInt(e.score);e.score=0}
if("Naming x"==e.app){$totalLanguageScore+=parseInt(e.score);e.score=0}
if("Reading x"==e.app){$totalLanguageScore+=parseInt(e.score);e.score=0}
if("Writing x"==e.app){$totalLanguageScore+=parseInt(e.score);e.score=0}
if("Language x"==e.app){e.score=$totalLanguageScore}})}
if($isQuestionCount>1){$isIntroOverlaps=!0;$totalQuestionScore=0;$appScores2.forEach(function(e){if("Asking x"==e.app){$totalQuestionScore+=parseInt(e.score);e.score=0}
if("Answering x"==e.app){$totalQuestionScore+=parseInt(e.score);e.score=0}
if("Question x"==e.app){e.score=$totalQuestionScore}})}
if($isAdvLanguageCount>1){$isIntroOverlaps=!0;$totalAdvLanguageScore=0;$appScores2.forEach(function(e){if("Advanced Comprehension x"==e.app){$totalAdvLanguageScore+=parseInt(e.score);e.score=0}
if("Advanced Naming x"==e.app){$totalAdvLanguageScore+=parseInt(e.score);e.score=0}
if("Advanced Writing x"==e.app){$totalAdvLanguageScore+=parseInt(e.score);e.score=0}
if("Advanced Reading x"==e.app){$totalAdvLanguageScore+=parseInt(e.score);e.score=0}
if("Advanced Language x"==e.app){e.score=$totalAdvLanguageScore}})}}
function mustIncludes(){$mustIncludeList="";$choices.forEach(function(e){if(e.recommended!="NONE"){if($.inArray(e.recommended,$passedToAJAX)==-1){$pushTrue=!0;if($.inArray(e.recommended,languageAppPackage)==-1){$mustIncludeList+="Title: "+e.recommended+" - Not in passed list: to be appended<br />"}
if($isVerbalException){if(e.recommended=="Advanced Naming x"){$pushTrue=!1}
if(e.recommended=="Conversation x"){$pushTrue=!1}}
if($isAuditoryException){if(e.recommended=="Advanced Comprehension x"){$pushTrue=!1}}
if(languageAppPackage.indexOf(e.recommended)!=-1&&$isLanguageCount>1){$pushTrue=!1}
if(advLanguageAppPackage.indexOf(e.recommended)!=-1&&$isAdvLanguageCount>1){$pushTrue=!1}
if($pushTrue){$passedToAJAX.push(e.recommended)}}else{}}})}
function getAdvLanguageIntros(){$returnString="";$intros=getNumIntros($choices);$commaStringSev="";$commaCountSev=0;$commaStringModSev="";$commaCountModSev=0;$commaStringModerate="";$commaCountModerate=0;$commaStringMildMod="";$commaCountMildMod=0;$commaStringMild="";$commaCountMild=0;$numMild=0;$numMildModerate=0;$numModerate=0;$numModerateSevere=0;$numSevere=0;$numThinking=0;$severeString="";$moderateSevereString="";$isLevelOverlap=!1;$connectorString="";$commasAppsSevere="";$commasAppsModSevere="";$commasAppsModerate="";$commasAppsMildMod="";$commasAppsMild="";$thinkingIntro="";var advLanguageAppPackage=["Advanced Comprehension x","Advanced Naming x","Advanced Reading x","Advanced Writing x"];$choices.forEach(function(e){if(e.choice=="severe"&&advLanguageAppPackage.indexOf(e.recommended)!=-1||e.choice=="severe"&&advLanguageAppPackage.indexOf(e.secondary)!=-1||e.choice=="severe"&&advLanguageAppPackage.indexOf(e.noncore)!=-1){$numSevere++}
if(e.choice=="moderate-severe"&&advLanguageAppPackage.indexOf(e.recommended)!=-1||e.choice=="moderate-severe"&&advLanguageAppPackage.indexOf(e.secondary)!=-1||e.choice=="moderate-severe"&&advLanguageAppPackage.indexOf(e.noncore)!=-1){$numModerateSevere++}
if(e.choice=="moderate"&&advLanguageAppPackage.indexOf(e.recommended)!=-1||e.choice=="moderate"&&advLanguageAppPackage.indexOf(e.secondary)!=-1||e.choice=="moderate"&&advLanguageAppPackage.indexOf(e.noncore)!=-1){$numModerate++}
if(e.choice=="mild-moderate"&&advLanguageAppPackage.indexOf(e.recommended)!=-1||e.choice=="mild-moderate"&&advLanguageAppPackage.indexOf(e.secondary)!=-1||e.choice=="mild-moderate"&&advLanguageAppPackage.indexOf(e.noncore)!=-1){$numMildModerate++}
if(e.choice=="mild"&&advLanguageAppPackage.indexOf(e.recommended)!=-1||e.choice=="mild"&&advLanguageAppPackage.indexOf(e.secondary)!=-1||e.choice=="mild"&&advLanguageAppPackage.indexOf(e.noncore)!=-1){$numMild++}
if(e.choice=="attention"&&advLanguageAppPackage.indexOf(e.recommended)!=-1||e.choice=="attention"&&advLanguageAppPackage.indexOf(e.secondary)!=-1||e.choice=="reasoning"&&advLanguageAppPackage.indexOf(e.recommended)!=-1||e.choice=="reasoning"&&advLanguageAppPackage.indexOf(e.secondary)!=-1||e.choice=="memory"&&advLanguageAppPackage.indexOf(e.recommended)!=-1||e.choice=="memory"&&advLanguageAppPackage.indexOf(e.secondary)!=-1||e.choice=="organization"&&advLanguageAppPackage.indexOf(e.recommended)!=-1||e.choice=="organization"&&advLanguageAppPackage.indexOf(e.secondary)!=-1||e.choice=="speed of processing"&&advLanguageAppPackage.indexOf(e.recommended)!=-1||e.choice=="speed of processing"&&advLanguageAppPackage.indexOf(e.secondary)!=-1){$numThinking++;$thinkingIntro=e.choice}});if($numMild>1||$numMildModerate>1||$numModerate>1||$numModerateSevere>1||$numSevere>1){$isLevelOverlap=!0}
$choices.forEach(function(e){if(advLanguageAppPackage.indexOf(e.recommended)!=-1||advLanguageAppPackage.indexOf(e.secondary)!=-1){if($numSevere>1&&e.choice=="severe"){if($commaCountSev==0&&$numSevere!=2){$commaStringSev=", "}else if($numSevere==2&&$commaCountSev!=($numSevere-1)){$commaStringSev=" and "}else if($commaCountSev==($numSevere-2)){$commaStringSev=" and "}else if($commaCountSev==$numSevere){$commaStringSev=""}else if($commaCountSev==($numSevere-1)){$commaStringSev=""}
$commaCountSev++;$commasAppsSevere+=e.section+$commaStringSev}
if($numSevere==1&&e.choice=="severe"){$commasAppsSevere=e.section}
if($numSevere==0&&e.choice=="severe"){$commasAppsSevere=""}
if($numModerateSevere>1&&e.choice=="moderate-severe"){if($commaCountModSev==0&&$numModerateSevere!=2){$commaStringModSev=", "}else if($numModerateSevere==2&&$commaCountModSev!=($numModerateSevere-1)){$commaStringModSev=" and "}else if($commaCountModSev==($numModerateSevere-2)){$commaStringModSev=" and "}else if($commaCountModSev==$numModerateSevere){$commaStringModSev=""}else if($commaCountModSev==($numModerateSevere-1)){$commaStringModSev=""}
$commaCountModSev++;$commasAppsModSevere+=e.section+$commaStringModSev}
if($numModerateSevere==1&&e.choice=="moderate-severe"){$commasAppsModSevere=e.section}
if($numModerateSevere==0&&e.choice=="moderate-severe"){$commasAppsModSevere=""}
if($numModerate>1&&e.choice=="moderate"){if($commaCountModerate==0&&$numModerate!=2){$commaStringModerate=", "}else if($numModerate==2&&$commaCountModerate!=($numModerate-1)){$commaStringModerate=" and "}else if($commaCountModerate==($numModerate-2)){$commaStringModerate=" and "}else if($commaCountModerate==$numModerate){$commaStringModerate=""}else if($commaCountModerate==($numModerate-1)){$commaStringModerate=""}
$commaCountModerate++;$commasAppsModerate+=e.section+$commaStringModerate}
if($numModerate==1&&e.choice=="moderate"){$commasAppsModerate=e.section}
if($numModerate==0&&e.choice=="moderate"){$commasAppsModerate=""}
if($numMildModerate>1&&e.choice=="mild-moderate"){if($commaCountMildMod==0&&$numMildModerate!=2){$commaStringMildMod=", "}else if($numMildModerate==2&&$commaCountMildMod!=($numMildModerate-1)){$commaStringMildMod=" and "}else if($commaCountMildMod==($numMildModerate-2)){$commaStringMildMod=" and "}else if($commaCountMildMod==$numMildModerate){$commaStringMildMod=""}else if($commaCountMildMod==($numMildModerate-1)){$commaStringMildMod=""}
$commaCountMildMod++;$commasAppsMildMod+=e.section+$commaStringMildMod}
if($numMildModerate==1&&e.choice=="mild-moderate"){$commasAppsMildMod=e.section}
if($numMildModerate==0&&e.choice=="mild-moderate"){$commasAppsMildMod=""}
if($numMild>1&&e.choice=="mild"){if($commaCountMild==0&&$numMild!=2){$commaStringMild=", "}else if($numMild==2&&$commaCountMild!=($numMild-1)){$commaStringMild=" and "}else if($commaCountMild==($numMild-2)){$commaStringMild=" and "}else if($commaCountMild==$numMild){$commaStringMild=""}else if($commaCountMild==($numMild-1)){$commaStringMild=""}
$commaCountMild++;$commasAppsMild+=e.section+$commaStringMild}
if($numMild==1&&e.choice=="mild"){$commasAppsMild=e.section}
if($numMild==0&&e.choice=="mild"){$commasAppsMild=""}}});if($commasAppsSevere!=""){$returnString=" a severe problem with "+$commasAppsSevere;$connectorString=", and "}
if($commasAppsModSevere!=""){$returnString+=$connectorString+" a moderate-severe problem with "+$commasAppsModSevere;$connectorString=", and "}
if($commasAppsModerate!=""){$returnString+=$connectorString+" a moderate problem with "+$commasAppsModerate;$connectorString=", and "}
if($commasAppsMildMod!=""){$returnString+=$connectorString+" a mild-moderate problem with "+$commasAppsMildMod;$connectorString=", and "}
if($commasAppsMild!=""){$returnString+=$connectorString+" a mild problem with "+$commasAppsMild}
if($numThinking==1){$returnString+=", and for improving "+$thinkingIntro}
return $returnString}
function getNumIntros($choices){$commaCount=0;$choices.forEach(function(e){if(e.recommended=="Naming x"){$commaCount++}
if(e.recommended=="Reading x"){$commaCount++}
if(e.recommended=="Writing x"){$commaCount++}
if(e.recommended=="Comprehension x"){$commaCount++}});return $commaCount}
function getSecondaryIntroCondensed($app,$introCheck){$returnIntro="";$loopNo=0;$beginString=" ";var item=$app;$numSecNonIntros=0;$numSecNonIntros=getnumSecNonIntros(item);$introCheck.forEach(function(e){if(e.choice=="severe"&&e.secondary==$app&&$loopNo==0||e.choice=="severe"&&e.noncore==$app&&$loopNo==0){$beginString+=" a severe problem with "}
if(e.choice=="moderate-severe"&&e.secondary==$app&&$loopNo==0||e.choice=="moderate-severe"&&e.noncore==$app&&$loopNo==0){$beginString+=" a moderate-severe problem with "}
if(e.choice=="moderate"&&e.secondary==$app&&$loopNo==0||e.choice=="moderate"&&e.noncore==$app&&$loopNo==0){$beginString+=" a moderate problem with "}
if(e.choice=="mild-moderate"&&e.secondary==$app&&$loopNo==0||e.choice=="mild-moderate"&&e.noncore==$app&&$loopNo==0){$beginString+=" a mild-moderate problem with "}
if(e.choice=="mild"&&e.secondary==$app&&$loopNo==0||e.choice=="mild"&&e.noncore==$app&&$loopNo==0){$beginString+=" a mild problem with "}
if($numSecNonIntros>1){$isIntroOverlaps=!0;if($loopNo==0){$infoCommaString=" and "}else if($loopNo==($numSecNonIntros-1)){$infoCommaString=""}else{$infoCommaString=", and "}}else{$infoCommaString=""}
if(e.secondary==item&&e.secondary!="NONE"&&e.section=="cognition"){$returnIntro+=" improving "+e.choice+$infoCommaString;$loopNo++}
if(e.noncore==item&&e.noncore!="NONE"&&e.section=="cognition"){$returnIntro+=e.choice+$infoCommaString;$loopNo++}
if(e.secondary==item&&e.secondary!="NONE"&&e.section!="cognition"){$returnIntro+=e.section+$infoCommaString;$loopNo++}
if(e.noncore==item&&e.noncore!="NONE"&&e.section!="cognition"){$returnIntro+=e.section+$infoCommaString;$loopNo++}});return $beginString+$returnIntro}
function getnumSecNonIntros(item){$num=0;$introCheck.forEach(function(e){if(e.secondary==item){$num++}
if(e.noncore==item){$num++}});return $num}
function checkIfArrayIsUnique(myArray){for(var i=0;i<myArray.length;i++){for(var j=0;j<myArray.length;j++){if(i!=j){if(myArray[i].trim()===myArray[j].trim()){return!1}}}}
return!0}
function isDoubleDouble(uniques){if(uniques.length>1){$numberOfDoubledIntros=0;uniques.forEach(function(intro,index){if($introsAJAX.howMany(intro)>1){$numberOfDoubledIntros++}});if($numberOfDoubledIntros==2){return!0}else{return!1}}}
function groupIntros($doubleDouble,justTheOne){if($doubleDouble){$theIndex=0;$theLastIndex=0;$moveTo=0;$theIndexDouble=0;$theLastIndexDouble=0;$moveToDouble=0;$theMovedApp="";$theMovedIntro="";$theMovedAppDouble="";$theMovedIntroDouble="";$theIndex=$introsAJAX.indexOf(justTheOne[0]);$theLastIndex=$introsAJAX.lastIndexOf(justTheOne[0]);$moveTo=$theIndex+1;$theMovedApp=$passedToAJAX[$moveTo];$theMovedIntro=$introsAJAX[$moveTo];$introsAJAX[$moveTo-1]=$introsAJAX[$moveTo-1].substr(0,$introsAJAX[$moveTo-1].length-4)+"s are:";$introsAJAX[$theLastIndex]=$theMovedIntro;$introsAJAX[$moveTo]="";$passedToAJAX[$moveTo]=$passedToAJAX[$theLastIndex];$passedToAJAX[$theLastIndex]=$theMovedApp;var justTheDouble=$introsAJAX.filter(function(intro,index,array){return array.indexOf(intro)!=index});$theIndexDouble=$introsAJAX.indexOf(justTheDouble[0]);$theLastIndexDouble=$introsAJAX.lastIndexOf(justTheDouble[0]);$moveToDouble=$theIndexDouble+1;$moveToDoubleTest=$theIndexDouble+1;$theMovedAppDouble=$passedToAJAX[$moveToDouble];$theMovedIntroDouble=$introsAJAX[$moveToDouble];$introsAJAX[$moveToDouble-1]=$introsAJAX[$moveToDouble-1].substr(0,$introsAJAX[$moveToDouble-1].length-4)+"s are:";$introsAJAX[$moveToDouble]="";$introsAJAX[$theLastIndexDouble]="";$passedToAJAX[$moveToDouble]=$passedToAJAX[$theLastIndexDouble];$passedToAJAX[$theLastIndexDouble]=$theMovedAppDouble}else{$theNumberOfDupedIntro=$introsAJAX.howMany(justTheOne[0]);if($theNumberOfDupedIntro==2&&$introsAJAX.length<5){$duplicatedIntro=justTheOne[0];$theIndex=0;$theLastIndex=0;$moveTo=0;$theIndexDouble=0;$theLastIndexDouble=0;$theMovedApp="";$theMovedIntro="";$theIndex=$introsAJAX.indexOf(justTheOne[0]);$theLastIndex=$introsAJAX.lastIndexOf(justTheOne[0]);$moveTo=$theIndex+1;$theMovedApp=$passedToAJAX[$moveTo];$theMovedIntro=$introsAJAX[$moveTo];$introsAJAX[$moveTo-1]=$introsAJAX[$moveTo-1].substr(0,$introsAJAX[$moveTo-1].length-4)+"s are:";if($theLastIndex==$moveTo){$introsAJAX[$moveTo]="";$introsAJAX[$theLastIndex]=""}else{$introsAJAX[$moveTo]="";$introsAJAX[$theLastIndex]=$theMovedIntro}
$passedToAJAX[$moveTo]=$passedToAJAX[$theLastIndex];$passedToAJAX[$theLastIndex]=$theMovedApp}
if($theNumberOfDupedIntro==3&&$introsAJAX.length<5){$duplicatedIntro=justTheOne[0];if($introsAJAX[0]!=$duplicatedIntro){for($i=2;$i<$introsAJAX.length;$i++){$introsAJAX[$i]=""}
$introsAJAX[1]=$introsAJAX[1].substr(0,$introsAJAX[1].length-4)+"s are:";$introsAJAX[2]="";$introsAJAX[3]=""}else{$nonDuppedIntro=$introsAJAX.getNonDupedIntro($duplicatedIntro);$moveToIndex=$introsAJAX.indexOf($nonDuppedIntro);$introsAJAX[$moveToIndex]="";$introsAJAX[$introsAJAX.length-1]=$nonDuppedIntro;$introsAJAX[0]=$introsAJAX[0].substr(0,$introsAJAX[0].length-4)+"s are:";$introsAJAX[1]="";$introsAJAX[2]="";$appToMove=$passedToAJAX[$moveToIndex];$passedToAJAX[$moveToIndex]=$passedToAJAX[$passedToAJAX.length-1];$passedToAJAX[$passedToAJAX.length-1]=$appToMove}}}}
function setMultipleIntrosCondensed($app){$returnString="";$testFuckingApp=$app;$intros=getNumIntros($choices);$commaStringSev="";$commaCountSev=0;$commaStringModSev="";$commaCountModSev=0;$commaStringModerate="";$commaCountModerate=0;$commaStringMildMod="";$commaCountMildMod=0;$commaStringMild="";$commaCountMild=0;$numMild=0;$numMildModerate=0;$numModerate=0;$numModerateSevere=0;$numSevere=0;$severeString="";$moderateSevereString="";$isLevelOverlap=!1;$connectorString="";$commasAppsSevere="";$commasAppsModSevere="";$commasAppsModerate="";$commasAppsMildMod="";$commasAppsMild="";$commasAppsThinking="";$commasAppsDysathria="";$choices.forEach(function(e){if(e.choice=="severe"&&e.recommended==$app||e.choice=="severe"&&e.secondary==$app||e.choice=="severe"&&e.noncore==$app){$numSevere++}
if(e.choice=="moderate-severe"&&e.recommended==$app||e.choice=="moderate-severe"&&e.secondary==$app||e.choice=="moderate-severe"&&e.noncore==$app){$numModerateSevere++}
if(e.choice=="moderate"&&e.recommended==$app||e.choice=="moderate"&&e.secondary==$app||e.choice=="moderate"&&e.noncore==$app){$numModerate++}
if(e.choice=="mild-moderate"&&e.recommended==$app||e.choice=="mild-moderate"&&e.secondary==$app||e.choice=="mild-moderate"&&e.noncore==$app){$numMildModerate++}
if(e.choice=="mild"&&e.recommended==$app||e.choice=="mild"&&e.secondary==$app||e.choice=="mild"&&e.noncore==$app){$numMild++}});if($numSevere>1||$numModerateSevere>1||$numModerate>1||$numMildModerate>1||$numMild>1){$isIntroOverlaps=!0}
$choices.forEach(function(e){if(e.recommended==$app||e.secondary==$app||e.noncore==$app){if($numSevere>1&&e.choice=="severe"){if($commaCountSev==0&&$numSevere!=2){$commaStringSev=", "}else if($numSevere==2&&$commaCountSev!=($numSevere-1)){$commaStringSev=" and "}else if($commaCountSev==($numSevere-2)){$commaStringSev=" and "}else if($commaCountSev==$numSevere){$commaStringSev=""}else if($commaCountSev==($numSevere-1)){$commaStringSev=""}
$commaCountSev++;$commasAppsSevere+=e.section+$commaStringSev}
if($numSevere==1&&e.choice=="severe"){$commasAppsSevere=e.section}
if($numSevere==0&&e.choice=="severe"){$commasAppsSevere=""}
if($numModerateSevere>1&&e.choice=="moderate-severe"){if($commaCountModSev==0&&$numModerateSevere!=2){$commaStringModSev=", "}else if($numModerateSevere==2&&$commaCountModSev!=($numModerateSevere-1)){$commaStringModSev=" and "}else if($commaCountModSev==($numModerateSevere-2)){$commaStringModSev=" and "}else if($commaCountModSev==$numModerateSevere){$commaStringModSev=""}else if($commaCountModSev==($numModerateSevere-1)){$commaStringModSev=""}
$commaCountModSev++;$commasAppsModSevere+=e.section+$commaStringModSev}
if($numModerateSevere==1&&e.choice=="moderate-severe"){$commasAppsModSevere=e.section}
if($numModerateSevere==0&&e.choice=="moderate-severe"){$commasAppsModSevere=""}
if($numModerate>1&&e.choice=="moderate"){if($commaCountModerate==0&&$numModerate!=2){$commaStringModerate=", "}else if($numModerate==2&&$commaCountModerate!=($numModerate-1)){$commaStringModerate=" and "}else if($commaCountModerate==($numModerate-2)){$commaStringModerate=" and "}else if($commaCountModerate==$numModerate){$commaStringModerate=""}else if($commaCountModerate==($numModerate-1)){$commaStringModerate=""}
$commaCountModerate++;$commasAppsModerate+=e.section+$commaStringModerate}
if($numModerate==1&&e.choice=="moderate"){$commasAppsModerate=e.section+""}
if($numModerate==0&&e.choice=="moderate"){$commasAppsModerate=""}
if($numMildModerate>1&&e.choice=="mild-moderate"){if($commaCountMildMod==0&&$numMildModerate!=2){$commaStringMildMod=", "}else if($numMildModerate==2&&$commaCountMildMod!=($numMildModerate-1)){$commaStringMildMod=" and "}else if($commaCountMildMod==($numMildModerate-2)){$commaStringMildMod=" and "}else if($commaCountMildMod==$numMildModerate){$commaStringMildMod=""}else if($commaCountMildMod==($numMildModerate-1)){$commaStringMildMod=""}
$commaCountMildMod++;$commasAppsMildMod+=e.section+$commaStringMildMod}
if($numMildModerate==1&&e.choice=="mild-moderate"){$commasAppsMildMod=e.section}
if($numMildModerate==0&&e.choice=="mild-moderate"){$commasAppsMildMod=""}
if($numMild>1&&e.choice=="mild"){if($commaCountMild==0&&$numMild!=2){$commaStringMild=", "}else if($numMild==2&&$commaCountMild!=($numMild-1)){$commaStringMild=" and "}else if($commaCountMild==($numMild-2)){$commaStringMild=" and "}else if($commaCountMild==$numMild){$commaStringMild=""}else if($commaCountMild==($numMild-1)){$commaStringMild=""}
$commaCountMild++;$commasAppsMild+=e.section+$commaStringMild}
if($numMild==1&&e.choice=="mild"){$commasAppsMild=e.section}
if($numMild==0&&e.choice=="mild"){$commasAppsMild=""}
if(e.choice=="speed of processing"||e.choice=="thought organization"||e.choice=="attention"||e.choice=="memory"||e.choice=="reasoning"){$commasAppsThinking=e.intro}
if(e.choice=="supplementing"||e.choice=="improving"){$commasAppsDysathria=e.intro}}});if($commasAppsSevere!=""){$returnString=" a severe problem with "+$commasAppsSevere;$connectorString=", and "}
if($commasAppsModSevere!=""){$returnString+=$connectorString+" a moderate-severe problem with "+$commasAppsModSevere;$connectorString=", and "}
if($commasAppsModerate!=""){$returnString+=$connectorString+" a moderate problem with "+$commasAppsModerate;$connectorString=", and "}
if($commasAppsMildMod!=""){$returnString+=$connectorString+" a mild-moderate problem with "+$commasAppsMildMod;$connectorString=", and "}
if($commasAppsMild!=""){$returnString+=$connectorString+" a mild problem with "+$commasAppsMild}
if($commasAppsThinking!=""){$forString="";if($forString==""){$forString="for "}
$connectorString=", and ";$returnString+=$connectorString+$forString+$commasAppsThinking}
if($commasAppsDysathria!=""){$forString="";if($forString==""){$forString="for "}
$connectorString=", and ";$returnString+=$connectorString+$forString+$commasAppsDysathria}
$choices.forEach(function(e){if(e.recommended==$app){e.intro=$returnString}})}
function resortForListOrder(){$overlapTestAppOut="";$order=99;$passedToAJAX.forEach(function(app,index){if($introsAJAX[index].indexOf("talking")!=-1){$order=1}
if($introsAJAX[index].indexOf("writing")!=-1){$order=2}
if($introsAJAX[index].indexOf("understanding")!=-1){$order=3}
if($introsAJAX[index].indexOf("reading")!=-1){$order=4}
$listSortedApps.push({appName:app,appIntro:$introsAJAX[index],appOrder:$order});$overlapTestAppOut+=app+" : "+$introsAJAX[index]+" : "+$order+"<br />";$order=99});$listSortedApps.sort(function(app1,app2){return app1.appOrder-app2.appOrder});$listSortedAppsString="";$passedToAJAXList=[];$introsAJAXList=[];$listSortedApps.forEach(function(e){$passedToAJAXList.push(e.appName);$introsAJAXList.push(e.appIntro)});$passedToAJAX=$passedToAJAXList;$introsAJAX=$introsAJAXList}
function getQuestionIntros(){$returnString="";$intros="";$intros=getNumIntros($choices);$commaStringSev="";$commaCountSev=0;$commaStringModSev="";$commaCountModSev=0;$commaStringModerate="";$commaCountModerate=0;$commaStringMildMod="";$commaCountMildMod=0;$numMild=0;$numMildModerate=0;$numModerate=0;$numModerateSevere=0;$numSevere=0;$severeString="";$moderateSevereString="";$isLevelOverlap=!1;$connectorString="";$commasAppsSevere="";$commasAppsModSevere="";$commasAppsModerate="";$commasAppsMildMod="";$commasAppsMild="";var questionAppPackage=["Asking x","Answering x"];$choices.forEach(function(e){if(e.choice=="severe"&&questionAppPackage.indexOf(e.noncore)!=-1){$numSevere++}
if(e.choice=="moderate-severe"&&questionAppPackage.indexOf(e.noncore)!=-1){$numModerateSevere++}
if(e.choice=="moderate"&&questionAppPackage.indexOf(e.noncore)!=-1){$numModerate++}
if(e.choice=="mild-moderate"&&questionAppPackage.indexOf(e.noncore)!=-1){$numMildModerate++}
if(e.choice=="mild"&&questionAppPackage.indexOf(e.noncore)!=-1){$numMild++}});if($numMild>1||$numMildModerate>1||$numModerate>1||$numModerateSevere>1||$numSevere>1){$isLevelOverlap=!0}
$choices.forEach(function(e){if(e.noncore=="Asking x"||e.noncore=="Answering x"){$anotherWTF=!0;if($numSevere>1&&e.choice=="severe"){if($commaCountSev==0&&$numSevere!=2){$commaStringSev=", "}else if($numSevere==2&&$commaCountSev!=($numSevere-1)){$commaStringSev=" and "}else if($commaCountSev==($numSevere-2)){$commaStringSev=" and "}else if($commaCountSev==$numSevere){$commaStringSev=""}else if($commaCountSev==($numSevere-1)){$commaStringSev=""}
$commaCountSev++;$commasAppsSevere+=e.section+$commaStringSev}
if($numSevere==1&&e.choice=="severe"){$commasAppsSevere=e.section}
if($numSevere==0&&e.choice=="severe"){$commasAppsSevere=""}
if($numModerateSevere>1&&e.choice=="moderate-severe"){if($commaCountModSev==0&&$numModerateSevere!=2){$commaStringModSev=", "}else if($numModerateSevere==2&&$commaCountModSev!=($numModerateSevere-1)){$commaStringModSev=" and "}else if($commaCountModSev==($numModerateSevere-2)){$commaStringModSev=" and "}else if($commaCountModSev==$numModerateSevere){$commaStringModSev=""}else if($commaCountModSev==($numModerateSevere-1)){$commaStringModSev=""}
$commaCountModSev++;$commasAppsModSevere+=e.section+$commaStringModSev}
if($numModerateSevere==1&&e.choice=="moderate-severe"){$commasAppsModSevere=e.section}
if($numModerateSevere==0&&e.choice=="moderate-severe"){$commasAppsModSevere=""}
if($numModerate>1&&e.choice=="moderate"){if($commaCountModerate==0&&$numModerate!=2){$commaStringModerate=", "}else if($numModerate==2&&$commaCountModerate!=($numModerate-1)){$commaStringModerate=" and "}else if($commaCountModerate==($numModerate-2)){$commaStringModerate=" and "}else if($commaCountModerate==$numModerate){$commaStringModerate=""}else if($commaCountModerate==($numModerate-1)){$commaStringModerate=""}
$commaCountModerate++;$commasAppsModerate+=e.section+$commaStringModerate}
if($numModerate==1&&e.choice=="moderate"){$commasAppsModerate=e.section}
if($numModerate==0&&e.choice=="moderate"){$commasAppsModerate=""}
if($numMildModerate>1&&e.choice=="mild-moderate"){if($commaCountMildMod==0&&$numMildModerate!=2){$commaStringMildMod=", "}else if($numMildModerate==2&&$commaCountMildMod!=($numMildModerate-1)){$commaStringMildMod=" and "}else if($commaCountMildMod==($numMildModerate-2)){$commaStringMildMod=" and "}else if($commaCountMildMod==$numMildModerate){$commaStringMildMod=""}else if($commaCountMildMod==($numMildModerate-1)){$commaStringMildMod=""}
$commaCountMildMod++;$commasAppsMildMod+=e.section+$commaStringMildMod}
if($numMildModerate==1&&e.choice=="mild-moderate"){$commasAppsMildMod=e.section}
if($numMildModerate==0&&e.choice=="mild-moderate"){$commasAppsMildMod=""}
if($numMild>1&&e.choice=="mild"){if($commaCountMild==0&&$numMild!=2){$commaStringMild=", "}else if($numMild==2&&$commaCountMild!=($numMild-1)){$commaStringMild=" and "}else if($commaCountMild==($numMild-2)){$commaStringMild=" and "}else if($commaCountMild==$numMild){$commaStringMild=""}else if($commaCountMild==($numMild-1)){$commaStringMild=""}
$commaCountMild++;$commasAppsMild+=e.section+$commaStringMild}
if($numMild==1&&e.choice=="mild"){$commasAppsMild=e.section}
if($numMild==0&&e.choice=="mild"){$commasAppsMild=""}}});if($commasAppsSevere!=""){$returnString=" a severe problem with "+$commasAppsSevere;$connectorString=", and "}
if($commasAppsModSevere!=""){$returnString+=$connectorString+" a moderate-severe problem with "+$commasAppsModSevere;$connectorString=", and "}
if($commasAppsModerate!=""){$returnString+=$connectorString+" a moderate problem with "+$commasAppsModerate}
if($commasAppsMildMod!=""){$returnString+=$connectorString+" a mild-moderate problem with "+$commasAppsMildMod}
if($commasAppsMild!=""){$returnString+=$connectorString+" a mild problem with "+$commasAppsMild}
return $returnString}
function getLanguageIntros(){$returnString="";$intros=getNumIntros($choices);$commaStringSev="";$commaCountSev=0;$commaStringModSev="";$commaCountModSev=0;$commaStringModerate="";$commaCountModerate=0;$commaStringMildMod="";$commaCountMildMod=0;$numMild=0;$numMildModerate=0;$numModerate=0;$numModerateSevere=0;$numSevere=0;$severeString="";$moderateSevereString="";$isLevelOverlap=!1;$connectorString="";$commasAppsSevere="";$commasAppsModSevere="";$commasAppsModerate="";$commasAppsMildMod="";$commasAppsMild="";var languageAppPackage=["Comprehension x","Naming x","Reading x","Writing x"];$choices.forEach(function(e){if(e.choice=="severe"&&languageAppPackage.indexOf(e.recommended)!=-1||e.choice=="severe"&&languageAppPackage.indexOf(e.secondary)!=-1||e.choice=="severe"&&languageAppPackage.indexOf(e.noncore)!=-1){$numSevere++}
if(e.choice=="moderate-severe"&&languageAppPackage.indexOf(e.recommended)!=-1||e.choice=="moderate-severe"&&languageAppPackage.indexOf(e.secondary)!=-1||e.choice=="moderate-severe"&&languageAppPackage.indexOf(e.noncore)!=-1){$numModerateSevere++}
if(e.choice=="moderate"&&languageAppPackage.indexOf(e.recommended)!=-1||e.choice=="moderate"&&languageAppPackage.indexOf(e.secondary)!=-1||e.choice=="moderate"&&languageAppPackage.indexOf(e.noncore)!=-1){$numModerate++}
if(e.choice=="mild-moderate"&&languageAppPackage.indexOf(e.recommended)!=-1||e.choice=="mild-moderate"&&languageAppPackage.indexOf(e.secondary)!=-1||e.choice=="mild-moderate"&&languageAppPackage.indexOf(e.noncore)!=-1){$numMildModerate++}
if(e.choice=="mild"&&languageAppPackage.indexOf(e.recommended)!=-1||e.choice=="mild"&&languageAppPackage.indexOf(e.secondary)!=-1||e.choice=="mild"&&languageAppPackage.indexOf(e.noncore)!=-1){$numMild++}});if($numMild>1||$numMildModerate>1||$numModerate>1||$numModerateSevere>1||$numSevere>1){$isLevelOverlap=!0}
$choices.forEach(function(e){if(e.recommended=="Naming x"||e.recommended=="Reading x"||e.recommended=="Writing x"||e.recommended=="Comprehension x"||e.secondary=="Reading x"){if($numSevere>1&&e.choice=="severe"){if($commaCountSev==0&&$numSevere!=2){$commaStringSev=", "}else if($numSevere==2&&$commaCountSev!=($numSevere-1)){$commaStringSev=" and "}else if($commaCountSev==($numSevere-2)){$commaStringSev=" and "}else if($commaCountSev==$numSevere){$commaStringSev=""}else if($commaCountSev==($numSevere-1)){$commaStringSev=""}
$commaCountSev++;$commasAppsSevere+=e.section+$commaStringSev}
if($numSevere==1&&e.choice=="severe"){$commasAppsSevere=e.section}
if($numSevere==0&&e.choice=="severe"){$commasAppsSevere=""}
if($numModerateSevere>1&&e.choice=="moderate-severe"){if($commaCountModSev==0&&$numModerateSevere!=2){$commaStringModSev=", "}else if($numModerateSevere==2&&$commaCountModSev!=($numModerateSevere-1)){$commaStringModSev=" and "}else if($commaCountModSev==($numModerateSevere-2)){$commaStringModSev=" and "}else if($commaCountModSev==$numModerateSevere){$commaStringModSev=""}else if($commaCountModSev==($numModerateSevere-1)){$commaStringModSev=""}
$commaCountModSev++;$commasAppsModSevere+=e.section+$commaStringModSev}
if($numModerateSevere==1&&e.choice=="moderate-severe"){$commasAppsModSevere=e.section}
if($numModerateSevere==0&&e.choice=="moderate-severe"){$commasAppsModSevere=""}
if($numModerate>1&&e.choice=="moderate"){if($commaCountModerate==0&&$numModerate!=2){$commaStringModerate=", "}else if($numModerate==2&&$commaCountModerate!=($numModerate-1)){$commaStringModerate=" and "}else if($commaCountModerate==($numModerate-2)){$commaStringModerate=" and "}else if($commaCountModerate==$numModerate){$commaStringModerate=""}else if($commaCountModerate==($numModerate-1)){$commaStringModerate=""}
$commaCountModerate++;$commasAppsModerate+=e.section+$commaStringModerate}
if($numModerate==1&&e.choice=="moderate"){$commasAppsModerate=e.section}
if($numModerate==0&&e.choice=="moderate"){$commasAppsModerate=""}
if($numMildModerate>1&&e.choice=="mild-moderate"){if($commaCountMildMod==0&&$numMildModerate!=2){$commaStringMildMod=", "}else if($numMildModerate==2&&$commaCountMildMod!=($numMildModerate-1)){$commaStringMildMod=" and "}else if($commaCountMildMod==($numMildModerate-2)){$commaStringMildMod=" and "}else if($commaCountMildMod==$numMildModerate){$commaStringMildMod=""}else if($commaCountMildMod==($numMildModerate-1)){$commaStringMildMod=""}
$commaCountMildMod++;$commasAppsMildMod+=e.section+$commaStringMildMod}
if($numMildModerate==1&&e.choice=="mild-moderate"){$commasAppsMildMod=e.section}
if($numMildModerate==0&&e.choice=="mild-moderate"){$commasAppsMildMod=""}
if($numMild>1&&e.choice=="mild"){if($commaCountMild==0&&$numMild!=2){$commaStringMild=", "}else if($numMild==2&&$commaCountMild!=($numMild-1)){$commaStringMild=" and "}else if($commaCountMild==($numMild-2)){$commaStringMild=" and "}else if($commaCountMild==$numMild){$commaStringMild=""}else if($commaCountMild==($numMild-1)){$commaStringMild=""}
$commaCountMild++;$commasAppsMild+=e.section+$commaStringMild}
if($numMild==1&&e.choice=="mild"){$commasAppsMild=e.section}
if($numMild==0&&e.choice=="mild"){$commasAppsMild=""}}});if($commasAppsSevere!=""){$returnString=" a severe problem with "+$commasAppsSevere;$connectorString=", and "}
if($commasAppsModSevere!=""){$returnString+=$connectorString+" a moderate-severe problem with "+$commasAppsModSevere;$connectorString=", and "}
if($commasAppsModerate!=""){$returnString+=$connectorString+" a moderate problem with "+$commasAppsModerate;$connectorString=", and "}
if($commasAppsMildMod!=""){$returnString+=$connectorString+" a mild-moderate problem with "+$commasAppsMildMod;$connectorString=", and "}
if($commasAppsMild!=""){$returnString+=$connectorString+" a mild problem with "+$commasAppsMild}
return $returnString}
function log_old_results(){for(var f=0;f<=5;f++){var f_str=0;switch(f){case 1:f_str='thinking-reason';break;case 2:f_str='thinking-organize';break;case 3:f_str='thinking-memory';break;case 4:f_str='thinking-attention';break;case 5:f_str='thinking-speed';break}
for(var e=0;e<=2;e++){var e_str=0;switch(e){case 1:e_str='unclear-supplement';break;case 2:e_str='unclear-improve';break}
for(var d=0;d<=5;d++){for(var c=0;c<=5;c++){for(var b=0;b<=5;b++){for(var a=0;a<=5;a++){calc_apps(a,b,c,d,e_str,f_str)}}}}}}
console.log('done old results')}