/* $Id: depression-toc-interactive.js 7699 2011-09-27 15:24:43Z tkelly $ */
webmd.m.hc = webmd.m.hc || {};
webmd.m.hc.interactive = webmd.m.hc.interactive || {};
(function(o) {

    var $initialSections, $initialHeading, $this, answerCache, numChecked = 0, options, results, resultsHeight, submitProp;
	
	/*Detect which environment script is in*/
	var envUrl = window.location.href;
	var env = (envUrl.indexOf("www") == -1) ? '../../../' : 
	(envUrl.indexOf("preview") != -1) ? 'http://css.preview.webmd.com/dtmcms/preview/webmd/' : 
	(envUrl.indexOf("staging") != -1) ? 'http://img.staging.webmd.com/dtmcms/staging/webmd/' : 
	'http://css.webmd.com/dtmcms/live/webmd/';

    var defaults = {
        answers: '.answers',
        biPollIdentifier: 'dep121',
        biPrefix: 'prm-sgvr',
        heading: '.heading',
        omnitureExists: false,
        questions: '.questions',
        speed: 150,
		tabs: '.tabs ul',
        targetHeight: {'1a': 240, '1b': 261, '1c': 244, '1d': 244},
		adhocCallCount: 2
    };
	
	o.addLinkTracking = function(index){
            var self = this;
			 var $sec = $this.find(options.questions).children(':eq('+index+')');
       		 var $inputs = $sec.find('input');
			 
			$sec.find('.next.active').bind('click.int:dprtracking', function() {
				if(!$(this).hasClass('noAdHoc')){
					if($inputs.is(':checked')){
						var opts = {obj: this, type:'sl'};
						opts.tag = 'ac-next-'+(index+1);
						self.tag(opts);
						$(this).addClass('noAdHoc');
					}
				}
			});
			
			return this;
        };

    o.bindResults = function(){
        var self = this;

        $this.find('a.nav').bind('click.int:depression', function(){
            var $button = $(this);
            if($button.hasClass('start')){
                self.startOver();
            }
        });
    };

    o.bindSection = function(index){
        var self = this;
        var $sec = $this.find(options.questions).children(':eq('+index+')');
        var $inputs = $sec.find('input');
        $inputs.bind('click.int:depression', function(){
            var $input = $(this);
			$sec.find('a.nav.inactive').hide();
			$sec.find('a.nav.active').show();
            self.saveSelections(index);
            if($input.is(':checked')){
                if($input.val() == 'none'){
                    $inputs.not($input).attr('checked', false);
                } else {
                    $sec.find(':checked[value=none]').attr('checked', false);
                }
            }
        });
		
        $sec.find('a.nav.active').bind('click.int:depression', function(){
            var $button = $(this);
            if($sec.find(':checked').length){
                if($button.hasClass('next')){
                    self.fadeSection(index);
                    self.goToNext(index+1);
                } else if($button.hasClass('submit')){
                    self.setResultsHeight();
                    self.goToFinish(index+1);
                }
				else if($button.hasClass('previous')){
					self.fadeSection(index);
					self.goToPrevious(index-1);
				}
            }
			else if(!$sec.find(':checked').length){
				if($button.hasClass('previous')){
					self.fadeSection(index);
					self.goToPrevious(index-1);
				}
			}
        });
    };

    o.clearChecked = function(index){
        $this.find('.section:eq('+index+')').find(':checked').attr('checked', false);
    };

    o.enableUIBlock = function(index){
        $this.find(options.questions).children(':eq('+index+')').bind('click', function(e){
            e.preventDefault();
        });
    };

    o.evaluateResults = function(index){
        var data;
        if(index == 4){/* if a suicidal result */
            data = rs['suicidal'];
            answerCache = [];
        } else {/* else parse through choices */
            var sel0, sel2;
            sel0 = options.selections[0][0];
            switch(sel0) {
                case '1a': data = rs['4a']; break;
                case '1b': data = rs['4b']; break;
                case '1c': data = rs['4c']; break;
                case '1d': data = rs['4d']; break;
                default: data = null;
            }
            sel0 = options.selections[0][0];
            sel2 = options.selections[2];
            switch(sel0) {
                case '1a':
                    if($.inArray('none', sel2) != -1){
                        answerCache.push('4a.personalized2.b');
                    } else if (sel2.length){
                        answerCache.push('4a.personalized2.a');
                    }
                    break;
                case '1b':
                    if(($.inArray('3e', sel2) != -1)){
                        answerCache.push((sel2.length == 1) ? '4b.personalized2.c' : '4b.personalized2.b');
                    } else if(sel2.length){
                        answerCache.push('4b.personalized2.a');
                    }
                    break;
                case '1c':
                    if(($.inArray('none', sel2) != -1)){
                        answerCache.push('4c.personalized2.b');
                    } else if (sel2.length){
                        answerCache.push('4c.personalized2.a');
                    }
                    break;
                case '1d':
                    if($.inArray('3g', sel2) != -1){
                        answerCache.push('4d.suicidal');
                    }
                    answerCache.push(($.inArray('3h', sel2) == -1) ? '4d.personalized2.a' : '4d.personalized2.b');
                    break;
                default: data = null;
            }
        }
        return data;
    };

    o.evaluateSelections = function(index){
        var data, sel0, sel1, sel2;
        if(index == 1){
            sel0 = options.selections[index-1][0];
            switch(sel0) {
                case '1a': data = qs['2a']; break;
                case '1b': data = qs['2b']; break;
                case '1c': data = qs['2c']; break;
                case '1d': data = qs['2d']; break;
                default: data = null;
            }
        }
        if(index == 2){
            sel0 = options.selections[0][0];
            sel1 = options.selections[1];
            switch(sel0) {
                case '1a':
                    if($.inArray('2g', sel1) != -1){
                        answerCache.push('4a.suicidal');
                    }
                    answerCache.push((sel1.length >= 4) ? '4a.personalized1.a' : '4a.personalized1.b');
                    data = qs['3a'];
                    break;
                case '1b':
                    if(($.inArray('none', sel1) != -1)){
                        answerCache.push('4b.personalized1.b');
                    } else if (sel1.length){
                        answerCache.push('4b.personalized1.a');
                    }
                    data = qs['3b'];
                    break;
                case '1c':
                    if($.inArray('2g', sel1) != -1){
                        answerCache.push('4c.suicidal');
                    }
                    if(($.inArray('2h', sel1) != -1) && sel1.length == 1){
                        answerCache.push('4c.personalized1.b');
                    } else if(sel1.length){
                        answerCache.push('4c.personalized1.a');
                    }
                    data = qs['3c'];
                    break;
                case '1d':
                    answerCache.push(($.inArray('2d', sel1) == -1) ? '4d.personalized1.a' : '4d.personalized1.b');
                    data = qs['3d'];
                    break;
                default: data = null;
            }
        }
        return data;
    };

    o.fadeInterface = function(index, background, $headObj, $sectionObj){
        var self = this;
        var $head = $this.find(options.heading);
        var $questions = $this.find(options.questions);
        $this.animate({opacity: 0}, options.speed, function(){
            if(index == 0){
               $head.replaceWith($headObj);
           } else if(index == 4){
               $head.html($headObj);
           }
		   else {
			$questions.find('.first').css({display: 'none'})   
		   }
		   
            if(index == 0){/* on "start over" */
                $questions.html($sectionObj);
				$questions.find('.first').css({display: 'block'}) //For IE7&8
            } else if(index == 3 || index == 4){/* on results or suicidal results */
                $head.addClass('long').css({height: resultsHeight+'px'});
                $questions.empty();
            } else {
                $head.removeClass('long');
                $questions.find('.section:eq('+index+')').replaceWith($sectionObj);
            }
            if(background){
                $this.find('.wrap').css({background: 'transparent url('+background+') no-repeat'});
            }
			self.hideInterface(index-1);
            self.showInterface(index);
        });
    };

    o.fadeSection = function(index){
        var self = this;
        self.unbindSection(index);
    };

    /* Combine the image complete functions into helper function if possible, too many repeats */
    o.goToNext = function(index){
        var data, self = this;
        data = self.evaluateSelections(index);
        var complete = function(){
            if(($.inArray('4a.suicidal', answerCache) != -1 || $.inArray('4b.suicidal', answerCache) != -1) || $.inArray('4c.suicidal', answerCache) != -1 || $.inArray('4d.suicidal', answerCache) != -1){
                self.setResultsHeight();
                self.goToFinish(4);
            } else {
				
                self.fadeInterface(index, data.img, self.makeHeading(data, index), self.makeSection(data, index));
				self.goToTab(index);
            }
        };
        self.waitForImage(data.img, complete);
    };
	
	o.goToTab = function(index){
		$this.find(options.tabs).children('li').removeClass('active')
		$this.find(options.tabs).children(':eq('+index+')').addClass('active');
	};
	
    o.goToPrevious = function(index){
      	this.showPrevious(index);
		this.goToTab(index);
    };
    
    o.goToFinish = function(index){
        var self = this;
		var redirectUrl = '';
        self.saveOmnitureValues();
        self.removeUIBlock();
        index = (options.selections[2] == '3g') ? 4 : index;
       
	    results = self.evaluateResults(index);
		
		if(results.moduleSegment=='suicidal'){
			self.sendPageview();
			 var complete = function(){
            self.fadeInterface(index, results.img, self.makeResults(results, index), null);
       		 };
        	self.waitForImage(results.img, complete);	
		}
		
		/*Redirect user to segment article player instead of a resuts slide*/
		else{
		self.sendPageresults();
		switch(results.moduleSegment) {
                case 'undiagnosed': redirectUrl='/depression/article-player-undg-dep-symptoms'; break;
                case 'newly-diagnosed': redirectUrl='/depression/article-player-nw-diag'; break;
				case 'diagnosed-on-treatment': redirectUrl='/depression/article-player-dep-trt'; break;
				case 'diagnosed-stopped-treatment': redirectUrl='/depression/article-player-untrt-dep'; break;	
            }
		window.location=redirectUrl;
		}
    };
	
	o.hideInterface = function(index){
		$this.find(options.questions).children(':eq('+index+')').addClass('inactive');
	};
	
    o.init = function(id, opts){
        var self = this;
		
        $this = $('#'+id);
        if($this.length){
            options = $.extend(defaults, opts || {});
            options.selections = self.resetSelections();
            options.omnitureExists = (typeof wmdPageLink == 'function');
			
			//Initialize first question here
            self.clearChecked(0);
            self.saveInitialState();
            self.bindSection(0);
			self.addLinkTracking(0);
        }
    };

    o.makeHeading = function(data, index){/* builds and returns overall heading */
        var dom = (data.hText) ? '<h3>'+data.hText+'</h3>' : '';
        dom += (data.hCopy) ? data.hCopy : '';
        return dom;
    };

    o.makeResults = function(data, index){/* builds and returns results dom */
        var dom = '<a class="nav start" href="javascript://">&lt; Start Over</a>';
        if(index == 4){/* index 4 == suicidal results page */
            dom += (data.hText) ? '<h3>'+data.hText+'</h3>' : '';
            dom += data.common1;
            dom += data.common2;
            dom += '<a class="nav recognize" href="'+data.seamlessURL+'">'+data.seamlessText+'</a>';
        } else {/* else show the other results sets */
            var prefix;
            var sel0 = options.selections[0][0];
            switch(sel0) {
                case '1a': prefix = '4a.'; break;
                case '1b': prefix = '4b.'; break;
                case '1c': prefix = '4c.'; break;
                case '1d': prefix = '4d.'; break;
            }
            dom += (data.hText) ? '<h3>'+data.hText+'</h3>' : '';
            dom += ($.inArray(prefix+'suicidal', answerCache) == -1) ? '' : data['suicidal'];
            dom += ($.inArray(prefix+'personalized1.a', answerCache) == -1) ? '' : data['personalized1']['a'];
            dom += ($.inArray(prefix+'personalized1.b', answerCache) == -1) ? '' : data['personalized1']['b'];
            dom += data.common1;
            dom += ($.inArray(prefix+'personalized2.a', answerCache) == -1) ? '' : data['personalized2']['a'];
            dom += ($.inArray(prefix+'personalized2.b', answerCache) == -1) ? '' : data['personalized2']['b'];
            dom += ($.inArray(prefix+'personalized2.c', answerCache) == -1) ? '' : data['personalized2']['c'];
            dom += data.common2;
            dom += '<a class="nav seamless" href="'+data.seamlessURL+'">'+data.seamlessText+'</a>';
        }
        return dom;
    };

    o.makeSection = function(data, index){/* builds and returns column dom */
        var dom = '<div class="section'+(index == 2 ? ' last' : '')+'"><div class="inset">';
        var suffix = ['a','b','c','d','e','f','g','h','i','j','k','l','m'];
        if(data){
            dom += (data.qCopy) ? '<h4>'+data.qCopy+'</h4>' : '';
            var qOpts = data.qOpts;
            var length = qOpts.length;
            var tOpt, value;
            dom += '<ul>';
            for(var i=0; i<length; i++){
                tOpt = qOpts[i];
                value = (tOpt.indexOf('None') == -1) ? ((index+1)+(suffix[i])) : 'none';
                dom += '<li><label><input type="checkbox" value="'+value+'"/><span>'+tOpt+'</span></label></li>';
            }
			
			dom+='</ul><a class="nav previous active" href="#">&lt; Previous</a>';
			
            if(index == 2){
                dom += '<a class="nav submit inactive">Finish &gt;</a><a class="nav submit active" href="#">Finish &gt;</a>';
            } else {
                dom += '<a class="nav next inactive">Next &gt;</a><a class="nav next active" href="javascript://">Next &gt;</a>';
            }
        }
        dom += '</div></div>';
        return dom;
    };

    o.makeUserSegProp = function(){/* prop 40 */
        return 'seg_'+options.biPrefix+'-'+results.moduleId+'_'+results.moduleSegment;
    },

    o.removeUIBlock = function(){
        $this.find(options.questions).children().unbind('click');
    };

    o.resetSelections = function(){
        answerCache = [];
        return {0: [], 1: [], 2: []};
    };
	
	o.resetTabs = function(){
		$this.find(options.tabs).children('li').removeClass('active')
		$this.find(options.tabs).children(':eq(0)').addClass('active');
	}

    o.saveChecked = function(){
        numChecked = $this.find(options.questions).find(':checked').length;
    },

    o.saveInitialHeading = function(){
        $initialHeading = $this.find(options.heading).clone();
    };

    o.saveInitialSections = function(){
        $initialSections = $this.find(options.questions).clone().html();
    };

    o.saveInitialState = function(){/* saves initial interactive state, used for any "start over" clicks */
        var self = this;
        self.saveInitialHeading();
        self.saveInitialSections();
    };

    o.saveOmnitureValues = function(){/* saves numChecked and prop46 before content refresh */
        var self = this;
        self.saveChecked();
        self.saveProp46();
    },

    o.saveProp46 = function(){
        var concat = '', sub = '';
        var count, num;
        var initialChecked = false;
        var pollIdentifier = options.biPollIdentifier+'-';
        var prefix = options.biPrefix+'_';
        var $sections = $this.find(options.questions).children();
        var sectionLength = $sections.length;
        var sel0 = options.selections[0][0];
        switch(sel0) {
            case '1a': sub = 'a'; break;
            case '1b': sub = 'b'; break;
            case '1c': sub = 'c'; break;
            case '1d': sub = 'd'; break;
        }
        for(var i=0; i<sectionLength; i++){
            var $inputs = $($sections[i]).find('input');
            var inputLength = $inputs.length;
            for(var j=0; j<inputLength; j++){
                if($($inputs[j]).attr('checked')){
                    if(initialChecked){
                        concat += '|';
                    }
                    if(i == 0){
                        num = initial.qOptsBI[j];
                    } else {
                        count = i+1;
                        num = qs[count+sub]['qOptsBI'][j];
                    }
                    concat += prefix+pollIdentifier+num;
                    initialChecked = true;
                }

            }
        }
        submitProp = concat;
    },

    o.saveSelections = function(index){/* saves selections within one column */
        var $checked = $this.find(options.questions).find('.section:eq('+index+')').find(':checked');
        var length = $checked.length;
        options.selections[index] = [];
        for(var i=0; i<length; i++){
            options.selections[index].push($($checked[i]).val());
        }
    };

    o.sendPageview = function(){
        var self = this;
        var checked = $this.find(options.questions).find('input:checked').length;
        var prop40Value = self.makeUserSegProp();
        var prop46Value = submitProp;
        var wmdTrackValue = options.biPrefix+'_sub'+numChecked;
        if(options.omnitureExists && numChecked > 0 && (prop46Value.length || prop40Value.length)){
            s_md.prop40 = prop40Value;
            s_md.prop46 = prop46Value;
            wmdTrack(wmdTrackValue);
            wmdPageview();
        } else {
            webmd.debug('setting these values on prop40: "'+prop40Value+'"');
            webmd.debug('setting these values on prop46: "'+prop46Value+'"');
            webmd.debug('wmdTrack value: "'+wmdTrackValue+'"');
            webmd.debug('wmdPageview()');
        }
    },
	o.sendPageresults = function(){
		var self = this;
        var checked = $this.find(options.questions).find('input:checked').length;
		var prop40Cookie_name = 'prop40'; 
		var prop40Cookie_val= self.makeUserSegProp();
		var prop46Cookie_name = 'prop46';
		var prop46Cookie_val= submitProp;
		var propCookie_options = {domain: 'webmd.com'};
		var test = $this.find(options.questions).find('.submit.active').get(0);
        var wmdTrackValue = options.biPrefix+'_sub'+numChecked;
		var opts = {obj: test, type:'sl', tag: wmdTrackValue};

        if(options.omnitureExists && numChecked > 0 && (prop40Cookie_val.length || prop46Cookie_val.length)){
			if (!webmd.cookie.exists(prop40Cookie_name)) {
				webmd.cookie.set(prop40Cookie_name, prop40Cookie_val, propCookie_options);
			}
			if (!webmd.cookie.exists(prop46Cookie_name)) {
				webmd.cookie.set(prop46Cookie_name, prop46Cookie_val, propCookie_options);
			}
			wmdTrack(wmdTrackValue); 
			self.tag(opts);
        } else {
            webmd.debug('setting these values on prop40: "'+prop40Value+'"');
            webmd.debug('setting these values on prop46: "'+prop46Value+'"');
            webmd.debug('wmdTrack value: "'+wmdTrackValue+'"');
            webmd.debug('wmdPageview()');
        }
	}

    o.setInitialHeights = function(){
        var $sections = $this.find(options.questions).find('.section .inset');
        var height = $($sections[0]).height();
        $sections.css({height: height});
    };

    o.setResultsHeight = function(){
        resultsHeight = parseInt($this.find(options.heading).height()) + parseInt($this.find(options.questions).height());
    };

	o.showPrevious = function(index){
		$this.find('.wrap').animate({opacity: 0}, options.speed, function(){
			$this.find('.wrap').css({background: 'transparent url('+env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-'+(index+1)+'.jpg'+') no-repeat'});
		});
		$this.find('.wrap').css({opacity: '0'}).animate({opacity: 1}, options.speed, function(){$this.find('.wrap').css({opacity: ''});});	
		$this.find(options.questions).children('.section').addClass('inactive');
		
		if(index>0){
		$this.find(options.questions).children(':eq('+index+')').removeClass('inactive');
		}
		else {
		$this.find(options.questions).find('.first').css({display: 'block'}) 
		}
		
		this.removeUIBlock(index);
		this.unbindResults();
		this.bindSection(index);
		this.addLinkTracking(index);
	};
	
    o.showInterface = function(index){
        var h, sel0, self = this;
        self.clearChecked(index);
        $this.animate({opacity: 1}, options.speed, function(){
            var lastIndex = index-1;
            if(lastIndex >= 0){
                self.enableUIBlock(lastIndex);
            }
            if(index == 3 || index == 4){
                self.sendPageview();
                self.bindResults();
            } else {
                $this.find(options.questions).children(':eq('+index+')').find('input:first').focus();
                self.bindSection(index);
				self.addLinkTracking(index);
            }
        });
        sel0 = options.selections[0][0];
    };
	
    o.startOver = function(){
        this.unbindResults();
        options.selections = this.resetSelections();
        var $headObj = $initialHeading.clone();
        this.fadeInterface(0, env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-1.jpg', $headObj, $initialSections);
		//$this.find(options.questions).children(':eq(0)').removeClass('inactive');
        //$this.find(options.questions).children(':eq(0)').css({display,'inline-block'});
        $this.find(options.questions).children(':eq(0)').css({opacity: '1'});
        this.resetTabs();
    };

    o.tag = function(opts){
        if(options.omnitureExists && opts.tag && opts.type){
            switch(opts.type) {
                case 'sl': 
					sl(opts.obj, 'prm-svgr', opts.tag); 
					break;
                case 'wmdPageLink': 
					wmdPageLink(opts.tag); 
					break;
            }
        } else {
            webmd.debug('sending tag type of: "'+opts.type+'" with tag value: "'+opts.tag+'"');
        }
    };

    o.unbindResults = function(){
        $this.find('a.nav').unbind('click.int:depression');
    };

    o.unbindSection = function(index){
        var $sec = $this.find(options.questions).children(':eq('+index+')');
        $sec.css({border: 'none'});
        $sec.find('input').unbind('click.int:depression').end()
            .find('a').unbind('click.int:depression');
    };

    o.waitForImage = function(img, callback){
	    if(img){
            var $image = $(new Image()).attr('src', img);
            var loaded = false;
            var watch = function(){
                if($image[0].complete){
                    loaded = true;
                    clearInterval(loadWatch);
                    callback();
                }
            };
            if(!loaded){
                var loadWatch = setInterval(watch, 100);
            }
        } else {
            callback();
        }
    };

    var initial = { qOptsBI: [1,2,3,4] };/* values for the first questions hardcoded in the HTML file */
	
	//Header and body copy data not being used for questions 1 through 3. Copy is static in curret version. Copy data still in use for suicidal result segment.
    var qs = {
        '2a': {
            hText: 'Getting Help For Depression',
            hCopy: '<p>When you\'re feeling depressed, you may have symptoms that make it hard to work, sleep, eat, or enjoy your friends and family. Spotting the symptoms of depression is the first step to getting help and feeling better.</p>',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-2.jpg',
            qCopy: 'Are you:',
            qOpts: ['Feeling sad or guilty often','Not enjoying daily activities','Eating more, or less','Sleeping more, or less','Feeling irritable or tired','Having trouble with concentration or memory','Thinking about suicide'],
            qOptsBI: [5,6,7,8,9,10,11]
        },
        '2b': {
            hText: 'Getting Help For Depression',
            hCopy: '<p>If you\'re not sure how to start getting help for your depression, remember that it can be treated so you can start to feel better. The right treatment for you may include medication, therapy or counseling, and things you can do at home that may help.</p>',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-2.jpg',
            qCopy: 'To feel better, do you plan to:',
            qOpts: ['Exercise most days','Eat healthy foods','Try to reduce stress','Take medication for depression','Making an appointment with a therapist','None of these'],
            qOptsBI: [12,13,14,15,16,17]
        },
        '2c': {
            hText: 'Getting Help For Depression',
            hCopy: '<p>If your treatment is working, it\'s important to stick with it and not stop too soon. But if you\'re still having symptoms after a few weeks, talk to your doctor about other treatments. There are a number of ways to get help for depression. Don\'t give up -- keep working with your doctor to find one that\'s right for you.</p>',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-2.jpg',
            qCopy: 'Are you still:',
            qOpts: ['Feeling sad or guilty often','Not enjoying daily activities','Eating more, or less','Sleeping more, or less','Feeling irritable or tired','Having trouble with concentration or memory','Thinking about suicide','No, I\'m feeling better'],
            qOptsBI: [18,19,20,21,22,23,24,25]
        },
        '2d': {
            hText: 'Getting Help For Depression',
            hCopy: '<p>Getting treated for depression helps almost everyone feel better, but it can take a while. And the same treatment doesn\'t work for everybody. If you\'re still having symptoms, it\'s important to talk to your doctor and try another treatment.</p>',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-2.jpg',
            qCopy: 'Why did you stop?',
            qOpts: ['The treatment didn\'t work','The side effects bothered me','Insurance or money problems','I started to feel better'],
            qOptsBI: [26,27,28,29]
        },
        '3a': {
            hText: 'Getting Help For Depression',
            hCopy: '<p>Depression isn\'t your fault, and it isn\'t caused by a character flaw.  Depression is a medical condition, and it\'s important to talk to your doctor about it. There are effective ways to treat depression, including using therapy and medication. Adopting some healthy habits may help, too.</p>',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-3.jpg',
            qCopy: 'To feel better, have you:',
            qOpts: ['Taken an herb or supplement','Exercised','Eaten healthy foods','Tried to reduce stress','Made a doctor\'s appointment','Talked to someone about it','None of these'],
            qOptsBI: [30,31,32,33,34,35,36]
        },
        '3b': {
            hText: 'Getting Help For Depression',
            hCopy: '<p>When you\'re feeling depressed, you may have symptoms that make it hard to work, sleep, eat, or enjoy your friends and family. And these symptoms last for a while. Telling your doctor about your specific symptoms will help you both find the right treatment for you.</p>',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-3.jpg',
            qCopy: 'What\'s been holding you back?',
            qOpts: ['I don\'t want people to know I have depression','I should be able to get better on my own','I\'m not sure what treatment to choose','It all seems too overwhelming','I\'m worried about my insurance coverage'],
            qOptsBI: [37,38,39,40,41]
        },
        '3c': {
            hText: 'Getting Help For Depression',
            hCopy: '<p>While therapy and medicine are key to getting better, there are also things you can do on your own to help speed your recovery. Making changes in your diet, exercise, and lifestyle can help you move toward feeling good again.</p>',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-3.jpg',
            qCopy: 'To feel better, are you:',
            qOpts: ['Exercising most days','Eating healthy foods','Trying to reduce stress','Spending time with friends and family','Getting the right amount of sleep','None of these'],
            qOptsBI: [42,43,44,45,46,47]
        },
        '3d': {
            hText: 'Getting Help For Depression',
            hCopy: '<p>You know how depression symptoms can interfere with your life, making it hard to work, sleep, eat, or enjoy your friends and family.  Not everyone who is depressed has the same symptoms - and you may not always recognize some symptoms as depression.</p>',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-3.jpg',
            qCopy: 'Are you still:',
            qOpts: ['Feeling sad or guilty often','Not enjoying daily activities','Eating more, or less','Sleeping more, or less','Feeling irritable or tired','Having trouble with concentration or memory','Thinking about suicide','No, I\'m feeling better'],
            qOptsBI: [48,49,50,51,52,53,54,55]
        }
    };

    var rs = {
        '4a': {
            hText: 'I Feel Depressed, But Haven\'t Talked to My Doctor Yet',
            common1: '<p>Good news: If your doctor determines you do have depression, there are a number of effective ways to get help and feel better. Studies show that a combination of therapy and medication usually works better than using either one alone. And almost everyone who gets treated for depression says it helps.</p>',
            common2: '<p>You don\'t have to accept feelings of sadness, or hopelessness, or miss out on things you used to enjoy. Talk to your doctor about how you feel, and ask him to help.</p>',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-4.jpg',
            moduleId: '1455',
            moduleSegment: 'undiagnosed',
            personalized1: {
                a: '<p>Your answers suggest that depression symptoms may be taking a toll on you.</p>',
                b: '<p>Your answers suggest that some symptoms of depression are bothering you.</p>'
            },
            personalized2: {
                a: '<p>It\'s good that you\'re trying to adopt some healthy habits to help your depression.</p>',
                b: '<p>There are some healthy habits that may also help with your depression.</p>'
            },
            seamlessText: 'Next Steps',
            seamlessURL: 'http://'+document.domain+'/depression/article-player-undg-dep-symptoms'
        },
        '4b': {
            hText: 'I\'ve Been Diagnosed With Depression - What Do I Do?',
            common1: '<p>Depression isn\'t your fault - it\'s a medical condition. And it\'s treatable. The sooner you get help, the sooner you\'ll start to feel better.</p>',
            common2: '<p>Studies show that a combination of therapy and medication usually works better than either one alone. It can take a while to feel better, though, so it\'s important to start your treatment and stick with it. If you\'re not feeling better after several weeks, tell your doctor.</p>',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-4.jpg',
            moduleId: '1456',
            moduleSegment: 'newly-diagnosed',
            personalized1: {
                a: '<p>It\'s great that you\'re thinking about taking action.</p>',
                b: '<p>Talking to your doctor  was the first step in getting help. Now it\'s important to take action.</p>'
            },
            personalized2: {
                a: '<p>It\'s normal to have concerns about depression treatment. Just remember, you deserve to feel as good as you once did. Talk to your doctor about the right treatment for you.</p>',
                b: '<p>Talk to your doctor if you\'re worried about your insurance coverage. There are many options for treating depression.</p>',
                c: '<p>It\'s normal to have concerns about depression treatment. Just remember, you deserve to feel as good as you once did. Talk to your doctor about the right treatment for you, and ask for help with insurance coverage.</p>'
            },
            seamlessText: 'Next Steps',
            seamlessURL: 'http://'+document.domain+'/depression/article-player-nw-diag'
        },
        '4c': {
            hText: 'I\'m Getting Help For My Depression',
            common1: '',
            common2: '<p>Making some lifestyle changes, like reducing stress and exercising, may help your treatment work better.</p>',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-4.jpg',
            moduleId: '1457',
            moduleSegment: 'diagnosed-on-treatment',
            personalized1: {
                a: '<p>It can take a while for depression treatment to work. If your mood doesn\'t improve after several weeks, ask your doctor about other treatments. Don\'t give up - almost everyone who gets help for depression does feel better.</p><p>Therapy and medication are the most common treatments, and studies show a combination of the two usually works best. It\'s important to stick with your treatment and give it time to work.</p>',
                b: '<p>It\'s great that you\'re feeling better! It\'s important to stick with your treatment until your doctor says it\'s OK to stop. Stopping treatment too early can raise the risk that you might have depression again.</p><p>Some people have side effects from their depression medicine that bother them, even though they are feeling better. Talk to your doctor - there are many options for treating depression.</p>'
            },
            personalized2: {
                a: '<p>It\'s good that you\'re trying to adopt some healthy habits to help your depression.</p>',
                b: '<p>There are some healthy habits that may also help with your depression.</p>'
            },
            seamlessText: 'Next Steps',
            seamlessURL: 'http://'+document.domain+'/depression/article-player-dep-trt'
        },
        '4d': {
            hText: 'I\'ve Stopped Being Treated for Depression',
            common1: '',
            common2: '',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-4.jpg',
            moduleId: '1458',
            moduleSegment: 'diagnosed-stopped-treatment',
            personalized1: {
                a: '<p>The good news is there are a number of ways to get help for depression that work. But it can take time, and some trial and error.</p><p>Don\'t feel like you have to accept depression. Work with your doctor to find the treatment that is best for you. If money is an issue, ask your doctor about drug assistance programs or call your local mental health agency, which may offer counseling resources.</p>',
                b: '<p>It\'s great that you were feeling better. Just as treatment for depression is very individual, so is your recovery. Stopping treatment too early could raise your risk of relapse, or mean that your symptoms don\'t totally go away. Tell your doctor about any changes in your mood - good or bad.</p>'
            },
            personalized2: {
                a: '<p>Because you\'re still having symptoms that interfere with your life, ask your doctor about treatment options. A number of medications and types of therapy are available. Studies show that a combination of medication and therapy usually works best to improve your mood.</p>',
                b: '<p>Now that you\'ve been through depression, you know what to watch for. If any symptoms ever come back, you\'ll be ready to call your doctor and restart your treatment. There are many ways to keep your recovery going strong. Remember, you deserve to feel as good as you did before your depression.</p>'
            },
            seamlessText: 'Next Steps',
            seamlessURL: 'http://'+document.domain+'/depression/article-player-untrt-dep'
        },
        suicidal: {
            hText: 'How To Get Help',
            common1: '<p style="margin:25px 0 10px 0;" ><strong>If you are thinking about hurting yourself, tell someone and get help now. Call your doctor, therapist, or an emergency hotline like 1-800-273-TALK right away.</strong></p><a class="nav resources" href="http://www.webmd.com/help/crisis-resources">More Resources</a>',
            common2: '<p style="margin:10px 0;">Depression warps your sense of reality, making things seem much worse than they are. The thoughts that make someone consider suicide aren\'t a sign of clear thinking. They\'re a symptom of depression. With treatment, those feelings will go away. You will feel better again.</p>',
            img: env+'consumer_assets/site_images/modules/hc_redesign_2011/depression-toc-interactive/depression-int-bg-photo-suicidal.jpg',
            moduleId: '1459',
            moduleSegment: 'suicidal',
            seamlessText: 'Suicide: Recognizing the Warning Signs',
            seamlessURL: 'http://'+document.domain+'/depression/guide/depression-recognizing-signs-of-suicide'
        }
    }

})(webmd.m.hc.interactive.depression = webmd.m.hc.interactive.depression || {});
