(function(b){function a(){this.query=b('#faq-search input[type="text"]');this.submit=b('#faq-search input[type="submit"]');this.loader=b("#faq-search img");this.result=b("#faq");this.minLength=3;this.init=function(){var c=this;this.query.prop("autocomplete","off").on("keydown",function(d){switch(d.keyCode){case 13:d.preventDefault();break;default:clearTimeout(this.stack);this.stack=setTimeout(function(){c.search()},300);break}})};this.search=function(){var c=this;value=this.query.val();if(value.length>=this.minLength){this.loader.show();this.result.load(this.query.parents("form").prop("action"),{q:value,format:"html"},function(){c.loader.hide()})}}}b.fn.diaporama=function(c){var d={delay:3,speed:"normal"};var c=b.extend(d,c);this.each(function(){var g=b(this);if(b(g).find("img").length>1){b(g).find("img:first-child").addClass("active");var e=setInterval(function(){f(c)},(c.delay*1000));function f(h){b(g).find("img.active").fadeOut(h.speed);if(!b(g).find("img.active").is(":last-child")){b(g).find("img.active").next().addClass("active").prev().removeClass("active");b(g).find("img.active").fadeIn(h.speed)}else{b(g).find("img:first-child").addClass("active").fadeIn(h.speed);b(g).find("img:last-child").removeClass("active")}}}});return this};b(this).ready(function(){function c(h,g){for(var f=h.first;f<=h.last;f++){if(!h.has(f+1)&&f<h.options.size){b.getJSON("http://"+window.location.host+"/getCarouselStory/"+(f+1)+"/"+b("#ss-carousel-list").data("start"),function(i){var j=i.data;h.add(f,'<li class="ss-carousel-item"><div class="ss-carousel-before"><img class="ss-carousel-img" src="/images/pictures/'+j.fpictureid+'.jpg" width="99" height="160" alt="'+j.firstname+' before taking Phentermine"/><div class="ss-carousel-before-label"><span>Before</span><br/><span class="ss-carousel-weight">'+j.startweight+'</span><br/><span>pounds</span></div></div><div class="ss-carousel-info"><span class="ss-carousel-name">'+j.firstname+"</span><br/><span>"+j.city+'</span><br/><a href="/'+j.token+'.html">Read '+j.firstname+'\'s story!</a></div><div class="ss-carousel-after"><img class="ss-carousel-img" src="/images/pictures/'+j.spictureid+'.jpg" width="99" height="160" alt="'+j.firstname+' after taking Phentermine"/><div class="ss-carousel-after-label"><span>After</span><br/><span class="ss-carousel-weight">'+j.currentweight+"</span><br/><span>pounds</span></div></div></li>")})}}}function d(h,g,f){if(!f){b(g).hide()}else{b(g).show()}}if(b("#ss-carousel-list:visible").length){b("#ss-carousel-list").jcarousel({size:b("#ss-carousel-list").data("size"),scroll:1,itemLoadCallback:c,buttonNextCallback:d,buttonPrevCallback:d})}b("#access .resize").click(function(f){f.preventDefault();contentArea=b("#content-area");fontClass="";switch(contentArea.attr("class")){case"font-medium":fontClass="font-large";break;case"font-large":fontClass="font-small";break;default:fontClass="font-medium"}contentArea.attr("class",fontClass)});b(".tell").click(function(f){b(this).prop("href",b(this).prop("href")+"&title="+document.title)});b("#forum-list-header").toggle(function(){b(this).attr("class","forum-list-open");b("#forum-list-content").slideDown("slow")},function(){forumListHeader=b(this);b("#forum-list-content").slideUp("slow",function(){forumListHeader.attr("class","forum-list-close")})});faqSearch=new a();faqSearch.init();b(".success-story-pictures").diaporama({speed:"slow",delay:2});b("#upload-more-photo").toggle(function(){b(".success-story-form-extra-photo").show();b(this).text("Hide extra photos")},function(){b(".success-story-form-extra-photo").hide();b(this).text("Upload more photos")});if(typeof FB!="undefined"){FB.Event.subscribe("edge.create",function(f){_gaq.push(["_trackSocial","facebook","like",f])});FB.Event.subscribe("edge.remove",function(f){_gaq.push(["_trackSocial","facebook","unlike",f])});FB.Event.subscribe("message.send",function(f){_gaq.push(["_trackSocial","facebook","send",f])});FB.Event.subscribe("comment.create",function(f){_gaq.push(["_trackSocial","facebook","comment",f.href])});FB.Event.subscribe("comment.remove",function(f){_gaq.push(["_trackSocial","facebook","uncomment",f.href])})}function e(g,k){if(!g){return}var g=g.split("#")[0];var j=g.split("?");if(j.length==1){return}var h=decodeURI(j[1]);k+="=";var m=h.split("&");for(var f=0,l;l=m[f];++f){if(l.indexOf(k)===0){return unescape(l.split("=")[1])}}}if(typeof twttr!="undefined"){twttr.events.bind("tweet",function(f){if(f){var g;if(f.target&&f.target.nodeName=="IFRAME"){g=e(f.target.src,"url")}_gaq.push(["_trackSocial","twitter","tweet",g])}})}})})(jQuery);
