function QAObject(ques, ans) {
	this.ques=ques;
	this.ans=ans;
}
var total = 0;
var QAs=[];
var quizAnswerImage="/images/img_str_orng.gif";
//create the anwers for each question
var arr = [

/* 1 */		   "<i>I need to go to the bathroom a lot&mdash;and suddenly. I've started wearing pads just in case.</i>",
/* 2 */		   "<i>I urinate frequently and sometimes without warning&mdash;I've even tried cutting back on fluids so I &ldquo;gotta go&rdquo; less often.</i>",
/* 3 */		   "<i>I &ldquo;have to go&rdquo; without warning, even at night. I've been doing it for a while, waking up suddenly. I'm exhausted.</i>",
/* 4 */		   "<i>Sometimes I don't make it to the bathroom in time.</i>",		   
/* 5 */		   "<i>I feel like I no longer have full control over my bladder&mdash;the need to go is urgent and urine sometimes leaks out.</i>",
/* 6 */		   "<i>I miss being active. I don't go places if it will be hard to find a bathroom. I haven't been [insert favorite activity here] in what feels like forever.</i>",
/* 7 */		   "<i>I feel like I spend most of my day either worrying about or holding my bladder control problem. It's too much.</i>",
/* 8 */		   "<i>I would like to learn more about Detrol LA.</i>"
		  ];
var arrMapping = [
		// 1	2		3		4		5	  6		7		8		9	  10	11
		[false, true , false, true , false, false, false, false, false, false, false],//1
		[true , true , false, false, true , false, false, false, false, false, false],//2
		[false, false, true , false, false, false, false, false, false, false, false],//3
		[false, true , false, false, false, false, false, false, false, true , false],//4
		[true , true , false, false, false, false, false, false, false, false, false],//5
		[false, false, false, false, false, true , true , true , false, true , false],//6
		[false, false, false, false, false, true , false, false, true , true , false],//7
		[false, false, false, false, false, false, false, false, false, false, true ] //8
];

function getQuestionId() {
    $('.GetTipContent').hide();
    $('#showGetTipsAnwsers').show();
    /* fire tab tracking*/
    s.pageName="DD_OAB Cheat Sheet Tab";
    s.channel="Detrol LA";
    var s_code=s.t();
    if(s_code)document.write(s_code);
    questionId = 0;

	var arrQuestionAdded = [false, false, false, false, false, false, false, false];
	
    $("ol.QTipsContent").each(function() {
        $("input[type='checkbox']:checked", this).each(function() {
            var questionId = ($(this).val());
            $('showGetTipsAnwsers').show();
           // alert('questionId'+questionId);
            for(i=0; i < arrMapping.length; i++){
				var arrShowPhrases = arrMapping[i];       
    			
				if(arrShowPhrases[questionId] && !arrQuestionAdded[i]){
					$("#showGetTipsAnwsers .showAQ").append("<ul>" + "<li>" + arr[i] + "</li>" + "</ul>");
					arrQuestionAdded[i] = true;					
				}
            }
        });
    });
}

/*Show content - > Symptom Quiz*/
function loadSymptomQuiz() {
    $("ul.tabs li a").removeClass("active"); /*remove tab active*/
    $("ul.tabs li a#QuizMenu").addClass("active").show(); /*Set the element active*/
    $("#symptomQuizTab").show(); /*show the DIV content -> Symptom Quiz */
    $("#welcomeTab").hide(); /*hide the first content - > welcome screen */
    $("#symptomQuizTab").css("display","block");
     $("#welcomeTab").css("display","none");
    /** fire page tracking*/
    s.pageName="DD_OAB Symptom Quiz Tab";
    s.channel="Detrol LA";
    var s_code=s.t();
    if(s_code)document.write(s_code);
 
}

/*Show content - > Get Tip for talking to your Doctor*/
function showGetTipContent() {
    $("ul.tabs li a").removeClass("active"); /*remove tab active*/
    $("ul.tabs li a#GetTipMenu").addClass("active").show(); /*Set the element active*/
    $("#GetTipTab").show(); /*Show the div content - > Get Tips*/
    $("#symptomQuizTab").hide(); /*Hide the div - Symptom Quiz*/
    $("#symptomQuizTab").css("display","none");
    $("#GetTipTab").css("display","block");
    $("#showResult").hide();
    window.scrollTo(0,0);
    //clear out checkboxesQuestionTips
    $("input[name='QuestionTips']:checked", this).each(function() {
        this.removeAttr("checked");
    });
     /** fire page tracking*/
    s.pageName="DD_Get Tips for Talking to Your Doctor Tab";
    s.channel="Detrol LA";
    var s_code=s.t();
    if(s_code)document.write(s_code);
    
}
/*Validate the radio buttom and get tha result of the quiz */
function getResult() {
    var submit = true;
    total = 0;
    QAs=[];
    //Get all value from each radio buttom 
    
    $("ul.group").each(function() {
    try{
                $("input[type='radio']:checked", this).each(function() {
                 //   alert($(this).attr('name'));
                   if($(this).attr('name')!=null && $(this).attr('name') !='QS0'){
                    var aid=$(this).attr('name');
                    Qno=aid.replace("QS","");
                    var qaObj=new QAObject($("#groupQ"+Qno).text(), $(this).val());
                    //alert('thisq'+$("#groupQ"+Qno).text());
                    QAs.push(qaObj);
                    }
              // alert('new object in QA Array>> Q'+ QAs[QAs.length -1].ques+" , A>>"+ QAs[QAs.length -1].ans);
                total += parseInt($(this).val());
          
                });
            }    catch(ee)
                {alert(ee.message);}
            
    });
    //set the error message when is not selected 
    $("ul.group").each(function() {
        if ($("input[type='radio']:checked", this).length == 0) {
            $("li.errorMsg", this).fadeIn("slow");
            submit = false;
        }
    });
    //show the result if the submit is true 
    if (submit == true) {
        $("#showResult #resultsQuiz").append("<h2>Your score is: " + total + "</h2>");
        $('.quizTabContent').fadeOut("fast");
        $('#showResult').fadeIn("slow");
        window.scrollTo(0,0);
         /** fire page tracking*/
        s.pageName="DD_OAB Symptom Quiz Results Tab";
        s.channel="Detrol LA";
        var s_code=s.t();
        if(s_code)document.write(s_code);
    }
}


function interstitial() {
    /*var valor = $(this).attr("href");*/
    var getUrls = "https://www.pfizerpro.com/sites/ppro/pages/products/detrol_la.aspx?tab=scientific_literature&intcmp=ProductNameDropDown-sci%20lit";    
    jQuery.cookie('ulrIntertitial', getUrls, { path: '/', expires: 3 });
    $(this).attr("href", '/interstitial-page.aspx');
     
 }


 $(document).ready(function() {
 //var url = jQuery.cookie('ulrIntertitial');
 var url = null;
 var pageName = url;
 if(url==null) url = "https://www.pfizerpro.com/sites/ppro/pages/products/detrol_la.aspx?tab=scientific_literature&intcmp=ProductNameDropDown-sci%20lit";
 if(pageName==null) pageName = "PfizerPro.com/DetrolLA";
 $(".subtiercopy .intestitalContent .urlElement").append("<p><a href='" + url + "'>" + pageName + "</a></p");
    //remove all the radio button checked
    $("ul.group").each(function() {
        $("input[type='radio']").removeAttr("checked");
    });
    
   
    //Set the firt element active  
    $(".tab_content").hide();
    $("ul.tabs li a:first").addClass("active").show();
    $(".tab_content:first").fadeIn("fast");




    $('a#btnTakeQuiz').click(loadSymptomQuiz)// call the Quiz content
    $('a#showGetTipsTab').click(showGetTipContent)// call the get tips Content
    $('#btnShowScore').click(getResult)//show the result of the total of the quiz
    $('#callout a').click(interstitial)

    $("#btnPrintOABAnswers").click(function(e) {
    $("#SCORE").val(total);
    $("ol.QTipsContent li").each(function() {
        $("input[type='checkbox']", this).each(function() {
            var talkingPointId = ($(this).val());
            var value = $(this).is(':checked')?"1":"0";
			$("#TP" + talkingPointId).val(value);         
        });
    });
    $('#quiz').submit();   
    
 }
    ); 

    $('#showAnswerTalking').click(getQuestionId)//show the result of the total of the quiz



    //remove the class from each question unchecked 
    $("ul.group input").click(function() {
        $("li.errorMsg", $(this).parent().parent()).fadeOut("slow");
    });

});
    