/********************************** Dynamic Pages Script **********************/
function getSelected(objControl,objHiddenControl)
{
       document.getElementById(objHiddenControl).value=document.getElementById(objControl).value;
}
/************************* hiding the div 'How long have you been taking LIPITOR' based on PrescriptionMedecine******************************/
function LipitorSel(objControl)
{
    if(document.getElementById("divHowLong")!=null)
      {
            if(document.getElementById('Q10705').value=="A11478|LIPITOR")
             {
                document.getElementById("divHowLong").className="displayblock";
             }
             else
             {
                document.getElementById("divHowLong").className="displaynone";
             }
      }
}
/*******************  ************************************/
function autoTab(input, e, len, next_field) 
{
   var isNN = (navigator.appName.indexOf("Netscape") != -1); 
   var keyCode = (isNN) ? e.which : e.keyCode; 
   var filter = (isNN) ? [0, 8, 9] : [0, 8, 9, 16, 17, 18, 37, 38, 39, 40, 46]; 
   if(input.value.length >= len && !containsElement(filter, keyCode))
    {
      next_field.focus(); 
    }
}
function containsElement(arr, ele)
{
   var found = false, index = 0; 
   while(!found && index < arr.length) if(arr[index] == ele) found = true; 
   else index++; 
   return found; 
}

function concatenatePhoneNumber()
{
   document.getElementById("Q10012|A10012").value = document.getElementById("txtPhone0").value + document.getElementById("txtPhone1").value + document.getElementById("txtPhone2").value; 
}

function concatenateDOB()
{
	var month =  document.getElementById("txtDOB1").value;
	var year = document.getElementById("txtDOB2").value;
	if(month=="")
	{
	   document.getElementById("txtDOB1").value= month ="00";
	}
	if(year==null)
	{
	  document.getElementById("txtDOB2").value=year="0000";
	}
	document.getElementById("Q10010|A10010").value = month + "01" + year;

	if(document.getElementById("txtDOBMMDDYYYY"))
	{
		document.getElementById("txtDOBMMDDYYYY").value="Q10010|A10010|" + year + month + "01";
	}
	if(document.getElementById("txtDOBYYYYMMDD"))
	{
		document.getElementById("txtDOBYYYYMMDD").value="Q10010|A10010|" + year + month + "01";
	}
     if(month=="" && year=="")
    {
       if(document.getElementById("txtDOBMMDDYYYY"))
       {
            document.getElementById("txtDOBMMDDYYYY").value="";
       }
       if(document.getElementById("txtDOBYYYYMMDD"))
       {
            document.getElementById("txtDOBYYYYMMDD").value="";
       }
    }
}
function concatenateDate(txtBox1,txtBox2,hdnContrl)
{
    var month =  document.getElementById(txtBox1).value;
    if(month.length==1)
       month = "0" + month
    var year = document.getElementById(txtBox2).value;
    document.getElementById(hdnContrl).value = month + "01" + year;
   
    if(month=="" && year=="")
    {
       document.getElementById(hdnContrl).value = "";
    }
}


/************ If DOB text is there in the form, If validation fails at the time of reloading the page,
 get the DOB value from hidden variable,split it and set the values textboxes   ************************/
if(document.getElementById("hdnQ10010|A10010")!=null)
{
    if(document.getElementById("hdnQ10010|A10010").value!="")
    {
       var DOB = document.getElementById("hdnQ10010|A10010").value.replace("Q10010|A10010|","");
       if(document.getElementById("txtDOB1")!=null)
            document.getElementById("txtDOB1").value=DOB.substring(0,2);
       if(document.getElementById("txtDOB2")!=null)
            document.getElementById("txtDOB2").value=DOB.substring(4,4);
    }
    else
    {
        document.getElementById("txtDOB1").value="00";
        document.getElementById("txtDOB2").value="2000";
    }
}
/******************** **************************/
function HideMailorEmail()
{
   if(document.getElementById('Q10556|A10163').value=="MAIL")
   {
        document.getElementById('Mail_Zip').style.display ='block';
        document.getElementById('Mail_State').style.display ='block';
        document.getElementById('Mail_City').style.display ='block';
        document.getElementById('Mail_Address1').style.display ='block';
        document.getElementById('Email_Zip').style.display ='none';
        document.getElementById('Email_State').style.display ='none';
        document.getElementById('Email_City').style.display ='none';
        document.getElementById('Email_Address1').style.display ='none';
   }
   else
   {
        document.getElementById('Mail_Zip').style.display ='none';
        document.getElementById('Mail_State').style.display ='none';
        document.getElementById('Mail_City').style.display ='none';
        document.getElementById('Mail_Address1').style.display ='none';
        document.getElementById('Email_Zip').style.display ='block';
        document.getElementById('Email_State').style.display ='block';
        document.getElementById('Email_City').style.display ='block';
        document.getElementById('Email_Address1').style.display ='block';
   } 
}


 function submitMyProgressForm(name,value)
 {
   if(document.getElementById("hdnTestOrChart"))
         document.getElementById("hdnTestOrChart").value=value;
   createCookiesFromControls(name);
   deleteCookie("submitedForm","/",null);
   deleteCookie("errorMessages","/",null);
   FormSubmit();
   document.forms[name].submit();
 }
 function submitFormtoServer(name)
 {
   if(name=="frmRegistration")
   {
        if(document.getElementById("txtRegSubmitted"))
            document.getElementById("txtRegSubmitted").value=true;
   }
   else if(name=="frmLogin")
   {
       if( document.getElementById("txtLogSubmitted"))
            document.getElementById("txtLogSubmitted").value=true;
   }
   
   if(name=="frm30DayTrial")
   {
		var couponGenerated = getCookie("CouponGenerated");
		if(couponGenerated=="CouponGenerated")
	    {
			//Error message in pop-up window when user attempts to request multiple trial cards in single session.
			openTrialCard("", 450, 100) 
			trialCard.document.write("We're sorry. Only 1 request per person can be accepted for this offer."); 
			trialCard.document.close();
			trialCard.focus;
	    }
	    else{
			createCookiesFromControls(name);
		    deleteCookie("submitedForm","/",null);
		    deleteCookie("errorMessages","/",null);
		    FormSubmit();
	    }
   }
   else{
			createCookiesFromControls(name);
		    deleteCookie("submitedForm","/",null);
		    deleteCookie("errorMessages","/",null);
		    FormSubmit();
	}

 }
 
/************ BEGIN Pop-up Windows Script ************/
var trialCard = null    // use this when referring to pop-up window
var winCount = 0
var winName = "trialcardpopup"
function openTrialCard(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
  var d_winLeft = (screen.width - winWidth) / 2; // default, pixels from screen left to window left
  var d_winTop = (screen.height - (winHeight + 90)) / 2;   // default, pixels from screen top to window top
  
  winName = "trialcardpopup" + winCount++ //unique name for each pop-up window
  closetrialCard()           // close any previously opened pop-up window
   
  trialCard  = window.open(winURL, winName, "width=" + winWidth 
           + ",height=" + winHeight + ", left=" + d_winLeft + ", top=" + d_winTop)
  }
  
function closetrialCard(){    // close pop-up window if it is open 
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(trialCard != null) if(!trialCard.closed) trialCard.close() 
  }
  
/************ END Pop-up Windows Script ************/ 

 // Fix for left green menu
 function classCheck()
 {

    var myEmts =document.getElementsByTagName("div");

        for(i=0; i< myEmts.length; i++){

            if (myEmts[i].className=="greensubnavofffirst") {

                myEmts[i].className="greensubnavofflast";

                break;

            }  

           if (myEmts[i].className=="greensubnavonfirst") {

                myEmts[i].className="greensubnavonlast";

                break;

            }             

        }
  }

/********** Script to acheive the hiding unrequired control and maintaining the view state fo the submitted page through the sessions *******************/

/* Add all the input control ids prefixing control type. For examppe prefix txt if it is text box rdo if it is radio button.
   If we are maining any hidden controls for any of the input controls then add hidden control id instead of actual control.
   For example like radio buttons or check boxes or multiple text boxes for fields like DOB and Phone Numbers.
 */
var cookieNames = new Array();
cookieNames[0]="txtQ10005|A10005"; //- First Name
cookieNames[1]="txtQ10007|A10007"; //Last Name
cookieNames[2]="txtQ10015|A10015"; //Email
cookieNames[3]="txtQ10017|A10017"; //Address Line 1
cookieNames[4]="txtQ10018|A10018"; //Address Line 2
cookieNames[5]="txtQ10019|A10019"; //City
cookieNames[6]="txtQ10020|A10020"; //State
cookieNames[7]="txtQ10021|A10021"; //Postal Code or Zip
cookieNames[8]="pnoQ10012|A10012"; //Phone Number
cookieNames[9]="txtQ12953|A17740"; //Tell Story
cookieNames[10]="rdohdnQ10011";     //Gender
cookieNames[11]="chkhdnQ10526|A11354"; //BroadConsent 
cookieNames[12]="rdohdnQ12232";   //Medicare
cookieNames[13]="rdohdnQ12868";  //Taking Lipitor
cookieNames[14]="dobQ10010|A10010"; //Date of Birth
cookieNames[15]="rdohdnQ13244";
cookieNames[16]="ddlQ10536"; //Taking_prescription
cookieNames[17]="ddlQ10708"; //taking_prescription_pastyear
cookieNames[18]="ddlQ10705"; //Prescription_medicine
cookieNames[19]="ddlQ10706"; //Years_lipitor
cookieNames[20]="txtQ10754|A11587"; //login id
cookieNames[21]="txtQ12951|A17738"; //password
cookieNames[22]="txttxtConfirm_Password";
cookieNames[23]="txtQ12952|A17739"; //password hint
cookieNames[24]="txttxtEmail_Address";
cookieNames[25]="txttxtUserID";
cookieNames[26]="txttxtPassword";

//Track tool my profile
cookieNames[27]="txttxtlipitorp2_profile_age";
cookieNames[28]="rdohdnlipitorp2_profile_gender";
cookieNames[29]="txttxtlipitorp2_profile_testDate";
cookieNames[30]="txttxtlipitorp2_profile_HDLcholesterol";
cookieNames[31]="txttxtlipitorp2_profile_LDLcholesterol";
cookieNames[32]="txttxtlipitorp2_profile_triglycerides";
cookieNames[33]="txttxtlipitorp2_profile_totalcholesterol";
cookieNames[34]="rdohdnlipitorp2_profile_smoker";
cookieNames[35]="txttxtlipitorp2_profile_systolicbloodpressure";
cookieNames[36]="rdohdnlipitorp2_myProfile_currHBPmed";

// Track tool Add/Edit test
cookieNames[37]="txttxttestDate";
cookieNames[38]="txttxtHDLcholesterol";
cookieNames[39]="txttxtLDLcholesterol";
cookieNames[40]="txttxttriglycerides";
cookieNames[41]="txttxttotalcholesterol";

//Unsubscribe me
cookieNames[42]="chkhdnQ13720|A20135";

cookieNames[43]="ddlQ13732"; //TreatingCholesterol
cookieNames[44]="rdohdnQ13733";   //PreferEmail
cookieNames[45]="ddlQ13840"; //Howdidyouhear

function createCookiesFromControls(formName)
{
      //Iterate through each element in the array if the element exists set itx value to cookie
    for(count=0;count < cookieNames.length;count++)
    {
        cookieFromControl(cookieNames[count]);
    }
}


function cookieFromControl(name)
{

  //check if the control exist in the form
  if(document.getElementById(name.substring(3)))
  {
    //set the cookie value - Name,Value,Expiration date,Path,Domain,Secure 
    setCookie(name,document.getElementById(name.substring(3)).value,null,"/",null,null);
  }
}

/* this method is called from each dynamic form in the site.
First based on the errorGenericValidationMsg display property, it checks if the request is post back request or not.
If it is post back request simply hide the unrequired control.
If it is not a postback request fetches all the values from cookies and set the them to controls
and hides un required divs. */

function readValuesFromCookies(formName)
{
    formName=fixloginForm(formName);
   //Check if page is submitted or not
   //if the request is not prost back retrieve the values from cookies set them cotnrol hide unrequired controls
   if(document.getElementById("errorGenericValidationMsg").style.display=="none")
   {  
         //Delete track tool test cookies
         deleteCookies();
         setValuesFromCookies();
         //Hide the how long are you taking lipitor dropdwon from offer forms.
         if(document.getElementById("divHowLong"))
            {
                if(document.getElementById('Q10705').value=="A11478|LIPITOR")
                 {
                    document.getElementById("divHowLong").className="displayblock";
                 }
                 else
                 {
                    document.getElementById("divHowLong").className="displaynone";
                 }
            }  

             var sumbitedForm = getCookie("submitedForm");
        //If the Last submited request maps with the current form hide unrequired divs
            if(sumbitedForm==formName)
            {  
                setErrorsFromCookies();
                HideUnrequiredDivs(formName);            
            }
        
        // Fixes to UI before submitting the page
        fixBeforeSubmit();
   }
   else
   {   
   
        //Hide the how long are you taking lipitor dropdwon from offer forms.
        if(document.getElementById("divHowLong"))
        {
            if(document.getElementById('Q10705').value=="A11478|LIPITOR")
             {
                document.getElementById("divHowLong").className="displayblock";
             }
             else
             {
                document.getElementById("divHowLong").className="displaynone";
             }
        }
     // If request is postback, hide the unrequired controls based on error message population   
        HideUnrequiredDivs(formName);
   } 
}

function setValuesFromCookies()
{
        for(count=0;count < cookieNames.length;count++)
        { 
           var cookieValue = getCookie(cookieNames[count]);
           var ctrlName = cookieNames[count].substring(3);
           var controlType = cookieNames[count].substring(0,3);
           if(controlType!=null && cookieValue !=null)
           { 
                switch(controlType)
                {
                    case "txt":
                      setTextBox(ctrlName,cookieValue);
                      break;    
                    case "rdo":
                      setRadioButton(ctrlName,cookieValue);
                      break;
                   case "chk":
                      setCheckBox(ctrlName,cookieValue);
                      break;    
                   case "ddl":
                      setDropdown(ctrlName,cookieValue);
                      break;
                   case "dob":
                      setDOB(ctrlName,cookieValue);
                      break;    
                   case "pno":
                      setPhoneNumber(ctrlName,cookieValue);
                      break;  
               }
           }
        }
}
//login.aspx page has two generic errormessages this just to hide the appropriate error div
//based on the form submitted
function fixGenErrorMsg(formName)
{  
    if(formName=="frmLogin")
    {
        if(document.getElementById("errorGenericValidationMsg1"))
            document.getElementById("errorGenericValidationMsg1").style.display="block";
        if(document.getElementById("errorGenericValidationMsg"))
            document.getElementById("errorGenericValidationMsg").style.display="none";
    }
}

//This function is to defferenciate registration and login forms
function fixloginForm(formName)
{

   if(formName=="frmLogReg")
   {
        
        if(document.getElementById("txtLogSubmitted") && document.getElementById("txtLogSubmitted").value=="true")
        {
                formName ="frmLogin";
        }
        else if(document.getElementById("txtRegSubmitted") && document.getElementById("txtRegSubmitted").value=="true")
        {
             formName = "frmRegistration";
        }
        else
        {
             var sumbitedForm = getCookie("submitedForm");
             if(sumbitedForm=="frmLogin" || sumbitedForm=="frmRegistration")
              {
                    formName=sumbitedForm;
              }
        }
   }

   return formName 
}


//Set value for text box controls
function setTextBox(ctrlName,value)
{
    
    if(document.getElementById(ctrlName))
    {
        document.getElementById(ctrlName).value=value;
    }
}
function setRadioButton(ctrlName,value)
{
  //Set value for check box related hidden varaible
    if(document.getElementById(ctrlName))
    {
        document.getElementById(ctrlName).value=value;
    }
    //Set value for check box
    if(ctrlName.indexOf("hdn")>-1)
    {
      if(document.getElementById(ctrlName.substring(3)+ "|" + value.substring(0,value.indexOf("|"))))
      {
         document.getElementById(ctrlName.substring(3)+ "|" + value.substring(0,value.indexOf("|"))).checked=true;
      }
    }
}
//Set check box value from cookie
function setCheckBox(ctrlName,value)
{
    //Set value for check box related hidden varaible
    if(document.getElementById(ctrlName))
    {
        document.getElementById(ctrlName).value=value;
    }
    //Set value for check box
    if(ctrlName.indexOf("hdn")>-1)
    {
      if(document.getElementById(ctrlName.substring(3)))
      {
         document.getElementById(ctrlName.substring(3)).checked=true;
      }
    }
}

function setDropdown(ctrlName,value)
{
    //Set value for check box related hidden varaible
    if(document.getElementById(ctrlName))
    {
        document.getElementById(ctrlName).value=value;
    }
}

function setDOB(ctrlName,value)
{
    //Set value for check box related hidden varaible
    if(document.getElementById(ctrlName))
    {
        document.getElementById(ctrlName).value=value;
    }
    if(document.getElementById("txtDOB1"))
    {
     document.getElementById("txtDOB1").value= value.substring(0,2);
    }
    if(document.getElementById("txtDOB2"))
    {
     document.getElementById("txtDOB2").value= value.substring(4,8);
    }
}

function setPhoneNumber(ctrlName,value)
{
    //Set value for check box related hidden varaible
    if(document.getElementById(ctrlName))
    {
        document.getElementById(ctrlName).value=value;
    }
    if(document.getElementById("txtPhone0"))
    {
     document.getElementById("txtPhone0").value= value.substring(0,3);
    }
    if(document.getElementById("txtPhone1"))
    {
     document.getElementById("txtPhone1").value= value.substring(3,6);
    }
    if(document.getElementById("txtPhone2"))
    {
     document.getElementById("txtPhone2").value= value.substring(6,10);
    }
    
}
function setErrorsFromCookies()
{
      var errorMessages = getCookie("errorMessages");
      if(errorMessages!=null)
      {
        var errorMsgArray= errorMessages.split("$");
        for(var count=0; count < errorMsgArray.length; count++)
        {
           var IdMsg =  errorMsgArray[count].split("=");
           if(IdMsg!=null && IdMsg.length==2)
           {
                if(document.getElementById(IdMsg[0]))
                {
                    document.getElementById(IdMsg[0]).innerHTML=IdMsg[1];
                    if(IdMsg[0]=="errorGenericValidationMsg")
                    {
                        document.getElementById(IdMsg[0]).style.display="block";
                    }
                    if(document.getElementById(IdMsg[0]).innerHTML=="Username already exists")
                    {
                        document.getElementById("errorGenericValidationMsg").style.display="none";
                    }
                }
           }
        }
      }
}

function HideUnrequiredDivs(formName)
{
  var  errorMessages ="";
  
  // get all errrordivs based on class name 'error'
  var className="error";

  if(formName=="frmLogin")
  {
      className = "errorLogin";
  }

  var ErrorDivs = getElementsByClass(className,null,'div')
 
  //Loop through all errordivs check if the they are required fields are not based on the error message populted
   for(var count=0; count<ErrorDivs.length; count++)
   {
          // if it is generric error message div leave that
            if(ErrorDivs[count].id!="errorGenericValidationMsg" && ErrorDivs[count].id!="errorGenericValidationMsg1")
            {
                //Check if error message is not populted.
                if(ErrorDivs[count].innerHTML.length <1)
                {  
                   // get the div id that nneds to be hide by replacing the error prefix with div
                   HideControlID = ErrorDivs[count].id.replace('error','div');
                   if(document.getElementById(HideControlID))
                   {
                        document.getElementById(HideControlID).className = "displaynone";
                   }
                }
                else
                {   
                    if(ErrorDivs[count].innerHTML=="Username already exists.")
                    {
                        document.getElementById("errorGenericValidationMsg").style.display="none";
                    }
                   //collect all error messages
                    if(errorMessages=="")
                    {
                        errorMessages += ErrorDivs[count].id + "=" + ErrorDivs[count].innerHTML;
                    }
                    else
                    {
                         errorMessages += "$" + ErrorDivs[count].id + "=" + ErrorDivs[count].innerHTML;
                    }
                    //Fix for the error divs after submitting the form
                    // Tell Your Storty form has the different alignment for error tag 
                    if(location.pathname.indexOf("/track-cholesterol-progress-a.aspx") > -1 || location.pathname.indexOf("/track-cholesterol-progress-d.aspx") > -1 || location.pathname.indexOf("/track-cholesterol-progress-f.aspx") > -1)
                    {
                         ErrorDivs[count].style.marginTop = "0px";
		                 ErrorDivs[count].style.paddingTop = "0";
			             ErrorDivs[count].style.marginBottom = "14px";
		                 ErrorDivs[count].style.paddingBottom = "0";
                    }
                    else if(formName=="frmLogin" || formName=="frmRegistration" || formName=="forgotPasswordForm")
                    {
                          ErrorDivs[count].style.paddingBottom ="4";
                         if(document.getElementById("divInstructions"))
                              document.getElementById("divInstructions").style.display="none";  
                    }
                    else if(location.pathname.indexOf("/about-lipitor/")>1) 
		            {
		                 ErrorDivs[count].style.paddingBottom ="0";
		                 
		            }
                    else 
                    {
                         ErrorDivs[count].style.marginTop = "20px";
		                 ErrorDivs[count].style.paddingTop = "0";
			             ErrorDivs[count].style.marginBottom = "-10px";
		                 ErrorDivs[count].style.paddingBottom = "0";
		             }
		           
                }
            }
            fixGenErrorMsg(formName);    
   }
   //Set collected error message string into cookie
   if(errorMessages!=null && errorMessages!="")
   {   
         //set the form name into cookie. 
         if(formName!="myProgressEditForm")
         {
             setCookie("submitedForm",formName,null,"/",null,null);
             setCookie("errorMessages",errorMessages,null,"/",null,null);
         }
   }
   // UI fixes after sumitting the form.
   fixAfterSubmit();
}

//Function to return all elements based on class
function getElementsByClass(searchClass,node,tag)
{
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
} 

function deleteCookies()
{
    
    if(getCookie("submitedForm")!="myProgressAddForm")
    {
        deleteCookie('txttxttestDate','/',null);
        deleteCookie('txttxtHDLcholesterol','/',null);
        deleteCookie('txttxtLDLcholesterol','/',null);
        deleteCookie('txttxttriglycerides','/',null);
        deleteCookie('txttxttotalcholesterol','/',null);
    }
    if(getCookie("submitedForm")!="MyProfileForm")
    {
        deleteCookie('txttxtlipitorp2_profile_age','/',null);
        deleteCookie('rdohdnlipitorp2_profile_gender','/',null);
        deleteCookie('txttxtlipitorp2_profile_testDate','/',null);
        deleteCookie('txttxtlipitorp2_profile_HDLcholesterol','/',null);
        deleteCookie('txttxtlipitorp2_profile_LDLcholesterol','/',null);
        deleteCookie('txttxtlipitorp2_profile_triglycerides','/',null);
        deleteCookie('txttxtlipitorp2_profile_totalcholesterol','/',null);
        deleteCookie('rdohdnlipitorp2_profile_smoker','/',null);
        deleteCookie('txttxtlipitorp2_profile_systolicbloodpressure','/',null);
        deleteCookie('rdohdnlipitorp2_myProfile_currHBPmed','/',null);
    }
    
}

function setLoginIdCookie()
{
  var cookieValue = getCookie("txtQ10754|A11587");
  if(cookieValue!=null)
  {
    setCookie("txttxtUserID",cookieValue,null,"/",null,null);
  }
}

/******************** Tell Your Story **********************/
function chkSelected(objControl,objHiddenControl)
{
   if(document.getElementById(objControl).checked)
   {
        document.getElementById(objHiddenControl).value=document.getElementById(objControl).value;
   }
   else
   {
        document.getElementById(objHiddenControl).value="";
   }
}
function ShowTab_TYS(tabName,value)
{
    HideAllTabs_TYS();
    document.getElementById(tabName).className="displayblock";
    document.getElementById("hdnActiveSection").value=value
    ChangePlusMinus(value);
}
function ChangePlusMinus(value)
{
    if(value==1)
    {
       if(document.getElementById("myStory"))
       {
            document.getElementById("myStory").src="../images/minus.gif";
       }
    }
    else
    {
     if(document.getElementById("moreAbout"))
            document.getElementById("moreAbout").src="../images/minus.gif";
    }
}
function readValuesFromCookiesTYS(formName)
{
    HideAllTabs_TYS();
    showcurrectTYSDiv();
    ChangePlusMinus(document.getElementById("hdnActiveSection").value);
    //If External Id is not available in Querry string redirect user to tell-your-story.aspx.
    if(document.getElementById("Q10003|A10003"))
    {
        if(document.getElementById("Q10003|A10003").value=="")
           document.location="tell-your-story.aspx";
    }
}

function getSelectedTYS(objControl,objHiddenControl,hdnStoppedLIPITORYes)
{
  document.getElementById(objHiddenControl).value=document.getElementById(objControl).value;
  var value=document.getElementById(objHiddenControl).value;
  if(value.indexOf("Yes")>-1)
  {
     document.getElementById(hdnStoppedLIPITORYes).value="Yes";
  }
  else
  {
    document.getElementById(hdnStoppedLIPITORYes).value="";
  }
}
function ExpandCollapse(currentTab)
{
  
   if(currentTab=="myStory")
   {
        
       ShowTab_TYS("divTYSPage1","1");
   }
   else
   {  
      submitTYSForm("tell_your_story");
   }
}
function HideAllTabs_TYS()
{ 
   if(document.getElementById("divTYSPage1"))
        document.getElementById("divTYSPage1").className="displaynone";
   if(document.getElementById("divTYSPage2"))
        document.getElementById("divTYSPage2").className="displaynone";
   if(document.getElementById("divTYSPage3"))
        document.getElementById("divTYSPage3").className="displaynone";
   if(document.getElementById("divTYSPage4"))
        document.getElementById("divTYSPage4").className="displaynone";
   if(document.getElementById("myStory"))
        document.getElementById("myStory").src="../images/plus.gif";
  if(document.getElementById("moreAbout"))
        document.getElementById("moreAbout").src="../images/plus.gif";
}
 function submitTYSForm(name)
 {
   FormSubmit();
   document.forms[name].submit();
 }
/************************* End of Tell Your Story ***************************/ 

/************************** Asses your risk **********************************/
function AssesYourRisk_A()
{
    var Gender = GetSessionValue("lipp2_myProfile_gender");
    var smoker=GetSessionValue("lipp2_myProfile_smoker");
    var currHBPmed=GetSessionValue("lipp2_myProfile_currHBPmed");
    var age =GetSessionValue("lipp2_myProfile_age");
    var testdate=GetSessionValue("lipp2_myProfile_testDt");
    var HDL=GetSessionValue("lipp2_myProfile_HDLchol");
    var LDL=GetSessionValue("lipp2_myProfile_LDLchol");
    var trigly=GetSessionValue("lipp2_myProfile_trigly");
    var total =GetSessionValue("lipp2_myProfile_totchol");
    var SBP=GetSessionValue("lipp2_myProfile_systolicbp");

    if (getCookie("submitedForm")!=null &&  getCookie("submitedForm") == "MyProfileForm")
    {
          if (getCookie("txttxtlipitorp2_profile_age") != null)
            age = getCookie("txttxtlipitorp2_profile_age");
          else
           age="";
          if(getCookie("txttxtlipitorp2_profile_testDate")!=null)
            testdate = getCookie("txttxtlipitorp2_profile_testDate");
          else
            testdate="";
          if(getCookie("txttxtlipitorp2_profile_HDLcholesterol")!=null)
             HDL = getCookie("txttxtlipitorp2_profile_HDLcholesterol");
          else
             HDL="";
          if(getCookie("txttxtlipitorp2_profile_LDLcholesterol")!=null)
             LDL = getCookie("txttxtlipitorp2_profile_LDLcholesterol");
          else
             LDL="";
          if(getCookie("txttxtlipitorp2_profile_triglycerides")!=null)
             trigly = getCookie("txttxtlipitorp2_profile_triglycerides");
          else
            trigly="";
          if(getCookie("txttxtlipitorp2_profile_totalcholesterol")!=null)
             total = getCookie("txttxtlipitorp2_profile_totalcholesterol");
          else
            total="";
          if(getCookie("txttxtlipitorp2_profile_systolicbloodpressure") != null)
             SBP = getCookie("txttxtlipitorp2_profile_systolicbloodpressure");
          else
            SBP ="";
          Gender= getCookie("rdohdnrdolipp2_myProfile_gender");
          smoker= getCookie("rdohdnrdolipp2_myProfile_smoker");
          currHBPmed=getCookie("rdohdnrdolipp2_myProfile_currHBPmed");
    }

   var numTests = GetSessionValue("num_tests");
   if(numTests!=null)
        document.getElementById("hdnnumtests").value=GetSessionValue("num_tests");
   document.getElementById("txtlipitorp2_profile_age").value=age;
      
   if(Gender!=null && Gender!="")
   {
      if (Gender == "Male")
      {
         document.getElementById('rdolipitorp2_profile_gender_Male').checked=true;
         document.getElementById('hdnlipitorp2_profile_gender').value='Male';
      }
      else if(Gender == "Female")
      {
         document.getElementById('rdolipitorp2_profile_gender_Female').checked=true;
         document.getElementById('hdnlipitorp2_profile_gender').value='Female';
      }
   }
   document.getElementById("txtlipitorp2_profile_testDate").value=testdate;
   document.getElementById("txtlipitorp2_profile_HDLcholesterol").value=HDL;
   document.getElementById("txtlipitorp2_profile_LDLcholesterol").value=LDL;
   document.getElementById("txtlipitorp2_profile_triglycerides").value=trigly;
   
   document.getElementById("txtlipitorp2_profile_totalcholesterol").value=total;

   if(smoker != null && smoker!="")
    {
        if (smoker == "Yes")
        {
           document.getElementById('rdolipitorp2_profile_smoker_Yes').checked=true;
           document.getElementById('hdnlipitorp2_profile_smoker').value='Yes';
        }
        else if (smoker == "No")
        {
           document.getElementById('rdolipitorp2_profile_smoker_No').checked=true;
           document.getElementById('hdnlipitorp2_profile_smoker').value='No';
        }
    }
   document.getElementById("txtlipitorp2_profile_systolicbloodpressure").value=SBP;
   
    if (currHBPmed != null && currHBPmed != "")
    {
            if (currHBPmed == "Yes")
            {
                document.getElementById('rdolipitorp2_myProfile_currHBPmed_Yes').checked=true;
                document.getElementById('hdnlipitorp2_myProfile_currHBPmed').value='Yes';
            }
            else if (currHBPmed == "No")
            {
                document.getElementById('rdolipitorp2_myProfile_currHBPmed_No').checked=true;
                 document.getElementById('hdnlipitorp2_myProfile_currHBPmed').value='No';
            }
    }

}
/**************************** end of Asses Your Risk *************************/         
/**************************** start of MyHeartWise  *************************/ 
function deleteCookiesFromMHW()
{			
	var cookieList = new Array();
	cookieList[0]="txtQ10005|A10005"; //- First Name
	cookieList[1]="txtQ10007|A10007"; //Last Name
	cookieList[2]="txtQ10015|A10015"; //Email
	cookieList[3]="txtQ10017|A10017"; //Address Line 1
	cookieList[4]="txtQ10018|A10018"; //Address Line 2
	cookieList[5]="txtQ10019|A10019"; //City
	cookieList[6]="txtQ10020|A10020"; //State
	cookieList[7]="txtQ10021|A10021"; //Postal Code or Zip
	cookieList[8]="chkhdnQ10526|A11354"; //BroadConsent 
	cookieList[9]="rdohdnQ12232";   //Medicare
	cookieList[10]="ddlQ13732"; //TreatingCholesterol
	cookieList[11]="rdohdnQ13733";   //PreferEmail
	cookieList[12]="ddlQ13840"; //Howdidyouhear

	for(count=0;count < cookieList.length;count++)
	{ 
		var cookieValue = getCookie(cookieList[count]);
		deleteCookie(cookieList[count],'/',null);
	}
}

/**************************** end of MyHeartWise *************************/ 