 document.write("<script type=\"text/javascript\" language=\"javascript\" src=\"../js/common.js\"></script>");

/**********************\
|*  Cookies
\**********************/

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
 /** This script is used by Visistor ID ****/
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
function getCookieforDisplayValueinTemp(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }

    var end = document.cookie.indexOf(";", begin);

    if (end == -1)
    {
        end = dc.length;
    }
    cookieSet(name);
    return unescape(dc.substring(begin + prefix.length, end));
}

// For store the cookies into temporary folder.
function cookieSet(name)
{
    var cookieValue = getCookie(name); 
    if (document.cookie != document.cookie) 
    {
        index = document.cookie.indexOf(cookieValue);
    } 
    else
    {
        index = -1;
    }
    if (index == -1) 
    {
        document.cookie= name + " = " + cookieValue+ ";expires=''";
    }
} 

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

/**
 * Determine whether a variable is considered to be empty based on its type
 * types = number, string, boolean, object, function, undefined
 * 
 *	@varable	A variable
 *
 *	Returns FALSE if var has a non-empty and non-zero value:
 *	"" (an empty string)
 *	null (an empty string)
 *	0 (an empty number)
 *	false (an empty boolean)
 *	0 (an empty value length of an object)
 *	null (an empty value of an object)
 *	undefined (an empty object type)
 */
 
function empty(variable)
{
	if(typeof variable == "number"){
		if (variable == 0){
			return true;
		}
	}
	else if (typeof variable == "string"){
		if(variable == null || variable == "" || variable.length <= 0){
			return true;
		}
	}
	else if (typeof variable == "boolean"){
		if (variable == false){
			return true;
		}
	}
	else if (typeof variable == "object"){
		if (variable.value.length == 0 || variable.value == null){
			return true;
		}
		else if(variable.type == "select-one")
		{
			if(variable.value.toLowerCase().indexOf('--') > 0)
			{
				return true;
			}
			if(variable.value.toLowerCase().indexOf("please select") > 0)
			{
				return true;
			}
			if(variable.value.toLowerCase().indexOf("select one") > 0)
			{
				return true;
			}
		}	
	}
	else if (typeof variable == "function"){
		return false;
	}
	else if (typeof variable == "undefined"){
		return true;
	}
	else if (typeof variable == "null"){
		return true;
	}
	return false;
}
/**
 * Determine whether a radio button is checked
 * 
 *	@radioGroupname		The name of the radio group that will be tested
 *
 *	Returns FALSE if a radio button is not checked.
 *	Returns TRUE if a radio button is checked.
 */
function testRadio(radioGroupName)
{
	var test = false;
	//Get Radio Buttons in Group
	
	var radioGroup = document.getElementsByName(radioGroupName);
	//Loop Through Each Button and Test if Checked
	for (i=0; i < radioGroup.length; i++)
	{
		if(radioGroup[i].checked)
		{
			test = true;
		}
	}
	return test;
}

/**
 * Validates Checkbox/Radio is checked
 * 
 *	@element	checkbox/Radio object
 */
function isChecked(element){
	if(element.checked){
		return true;
	}else{
		return false;
	}
}


/**
 * Show an HTML element 
 * 
 *	@elemID  The ID of the html element that will be displayed
 */
function showElement(elemID)
{
	if(document.getElementById(elemID))
	{
		document.getElementById(elemID).style.display="block";
	}
}

/**
 * Hide an HTML element 
 * 
 *	@elemID		The ID of the html element that will be hidden
 */
function hideElement(elemID)
{
	if(document.getElementById(elemID))
	{
		document.getElementById(elemID).style.display="none";
	}    
}

/**
 * Clear Default text in textbox 
 * 
 *	@elem		The element text box that will be cleared.
 *
 *	Writen by:	Bryce Acer
 *	Date:		6/1/2006
 */
function clearDefault(elem)
{
	if (elem.defaultValue==elem.value) elem.value = ""
} 


if ((location.pathname.indexOf("/onlylipitor") > -1)||(location.pathname.indexOf("/onlyLIPITOR") > -1))
{

	document.write("<!--[if IE 6]><style>.sidebar_onlyLip {margin-right: -10px;}</style><![endif]-->");
}

 
// The following code from global.js

function addScript(jsPath) {
	var js = document.createElement("script");
	js.setAttribute("type", "text/javascript");
	js.setAttribute("language", "javascript");
	js.setAttribute("src", jsPath);
	document.getElementsByTagName("body")[0].appendChild(js);
}

function pageInit() {
	
}
function addToPageInit() {
	var initialContents = pageInit;
	var functionList = new String;
	functionList[0] = initialContents;
	for (var i=1;i<=arguments.length;i++) {
		functionList[i] += arguments[i];
	}
	pageInit = functionList;
}

function setOnClickEvent(obj, eventFunction) {
	obj.onclick=Function(eventFunction);
}

function removeHref(obj) {
	obj.removeAttribute("href");
}

function OnOK(URL)
{
     if(document.location.href!=null && document.location.href.indexOf('link') > -1)
      {
          var link = document.location.href.substring(document.location.href.indexOf('link')+ 5,document.location.href.length);
          window.open(unescape(link));
	      self.window.close();	
      }
}
	 
function OnCancel()
{
	self.window.close();
}
  
function interstitialPopup(pInterstitial, pURL) { 
    var vURL = "../components/" + pInterstitial + "?redirect=" + escape(pURL);
    window.open(vURL, 'interstitial', 'scrollbars=yes,resizable=no,menubar=no,status=no,toolbar=no,width=800,height=400');
}

function exitPopup(pURL) { 
    var vURL = "../components/exit.aspx?link=" + escape(pURL);
    window.open(vURL, 'exit', 'scrollbars=yes,resizable=no,menubar=no,status=no,toolbar=no,width=800,height=400');
}

function fixBeforeSubmit()
{
        var s = "";

	    if (document.getElementById("divTakingLipitor"))
	     {
	        s = document.getElementById("divTakingLipitor").getElementsByTagName("br")[1]; 
		    s.style.display = "none";
		    s = document.getElementById("divTakingLipitor");
		    s.style.marginTop = "0";
		    s.style.paddingTop = "10px";
		    s.style.marginBottom = "-20px";
		    s.style.paddingBottom = "0";
		    s = document.getElementById("divTakingLipitor").getElementsByTagName("p")[1].getElementsByTagName("span"); 
		    s[0].style.display = "block";
		    s[0].style.marginTop = "-30px";
		    s[0].style.marginLeft = "25px";
		    s[1].style.display = "block";
		    s[1].style.marginTop = "-20px";
		    s[1].style.marginLeft = "25px";
			s = document.getElementById("divTakingLipitor").getElementsByTagName("p")[1].getElementsByTagName("br"); 
			s[0].style.display = "none";
			s[1].style.display = "none";
	 	}
		   if (document.getElementById("divMedicare"))
		   {
		    s = document.getElementById("divMedicare").getElementsByTagName("table");
		    s[0].style.styleFloat = "left";
		    s[0].style.textAlign = "left";
		    s[0].style.marginLeft = "-10px";
		    s[0].style.marginTop = "-15px";
		    s[0].style.marginBottom = "15px";
		    s[0].style.width = "100%";
		    s = document.getElementById("divMedicare").getElementsByTagName("table")[0].getElementsByTagName("td");
		    s[0].style.width = "50px";
		    s = document.getElementById("divMedicare").getElementsByTagName("p"); 
	        s[0].style.marginTop = "30px";
	        s[0].style.marginBottom = "-25px";
	        s = document.getElementById("divMedicare").getElementsByTagName("table"); 
	        s[0].style.marginTop = "5px";
    	  } 
    	  
	
	    if (document.getElementById("divNarrowConsent"))
	    { 
	       s = document.getElementById("divNarrowConsent").getElementsByTagName("input"); 
	       s[0].style.marginTop = "0"; 
	    } 
        if (document.getElementById("divBroadConsent"))
        {    
           s = document.getElementById("divBroadConsent").getElementsByTagName("input"); 
           s[0].style.marginTop = "0";
        }
         if ((location.pathname.indexOf("/request-more-information.aspx") > -1)||(location.pathname.indexOf("/join-my-heartwise.aspx") > -1))
        { 
                if(document.getElementById("divTakingLipitor"))
				{
					s = document.getElementById("divTakingLipitor").getElementsByTagName("p");
					s[1].style.paddingTop = "1pt";
		        }
		        
		        if (document.getElementById("divPrivacyLink")) 
    	          {
		            s = document.getElementById("divPrivacyLink");
		            s.style.marginTop = "25px";
		            s.style.marginLeft = "0";
		            s.style.paddingLeft = "0";
		            s.style.marginBottom = "0";		
	             }
        }
}

function fixAfterSubmit()
{
   if ((location.pathname.indexOf("/request-more-information.aspx") > -1)||(location.pathname.indexOf("/join-my-heartwise.aspx") > -1))
   {      
	    if(document.getElementById("divTakingLipitor"))
        {
            s = document.getElementById("divTakingLipitor").getElementsByTagName("p")[1].getElementsByTagName("span"); 
	        s[0].style.display = "block";
	        s[0].style.marginTop = "-20px";
	        s[0].style.marginLeft = "25px";
	        s[1].style.display = "block";
	        s[1].style.marginTop = "-20px";
	        s[1].style.marginLeft = "25px";
	        if (location.pathname.indexOf("/join-my-heartwise.aspx") > -1)
	        {
		        s = document.getElementById("divTakingLipitor").getElementsByTagName("p");
		        s[0].style.marginTop = "0";
		        s[0].style.paddingTop = "0";
		        s[0].style.marginBottom = "0";
		        s[0].style.paddingBottom = "0";
        		
		        s[1].style.marginTop = "10px";
		        s[1].style.paddingTop = "0";
		        s[1].style.marginBottom = "0";
		        s[1].style.paddingBottom = "0";
        		s = document.getElementById("divTakingLipitor");
        		s.style.marginBottom="-20px";
        		s.style.paddingTop="10px";
		        s = document.getElementById("divTakingLipitor").getElementsByTagName("p")[1].getElementsByTagName("br"); 
		        s[1].style.display = "block";
	        }
	        if(location.pathname.indexOf("/request-more-information.aspx") > -1)
	        {
                if(document.getElementById("divTakingLipitor"))
                {
                    s = document.getElementById("divTakingLipitor").getElementsByTagName("p");
		            s[1].style.paddingTop = "0px";
		        }
		        if( document.getElementById("divMedicare"))
                {
		           
		            document.getElementById("divMedicare")
		            s = document.getElementById("divMedicare").getElementsByTagName("p");
		            s[0].style.marginTop = "20px";
	                s[0].style.marginBottom = "-10px"; 
	                s[1].style.display="none";
	                s = document.getElementById("divMedicare").getElementsByTagName("table"); 
	                s[0].style.marginBottm = "-5px";
	            }
	            if(document.getElementById("errorTakingLipitor"))
	            {
                    document.getElementById("errorTakingLipitor").style.marginTop="-4px";
                }
                if(document.getElementById("errorCity"))
                {
                    document.getElementById("errorCity").style.marginTop="10px";
                }
                if(document.getElementById("errorState"))
                {
                    document.getElementById("errorState").style.marginTop="10px";
                }
                if(document.getElementById("errorZip"))
                {
                    document.getElementById("errorZip").style.marginTop="10px";
                }
                if(document.getElementById("errorDOB"))
                {
                    document.getElementById("errorDOB").style.marginTop="10px";
                }
                if(document.getElementById("errorMedicare"))
                {
                    document.getElementById("errorMedicare").style.marginBottom="-10px";
                    document.getElementById("errorMedicare").style.marginTop="30px";
                }
	        }
	    }
	}
	else if(location.pathname.indexOf("/offers/30-day_trial.aspx") > -1 || location.pathname.indexOf("/offers/co-pay_card.aspx") > -1 )
	{
	 document.getElementById("errorMACoverage").style.marginBottom="10px";
	}
}
function initToggle() {
//alert("1");
	var pos = document.getElementById('contentContainer');
	var containers = getElementsByClassName('QAnswer', 'div', document);
    window.onload = function() {	
	for (var i=0; i<containers.length; i++) 
	{//alert("2");
		containers[i].style.display = 'none';
		containers[i].parentNode.getElementsByTagName("h2")[0].onclick= function() {
	        if (this.parentNode.getElementsByTagName("div")[0].style.display == 'none') {
			    this.parentNode.getElementsByTagName("div")[0].style.display = 'block';//alert("3");
			} else {
	            this.parentNode.getElementsByTagName("div")[0].style.display = 'none';//alert("4");
	        }
		}
	}
  }
}
function glossaryToggle() {
	
	var containers = getElementsByClassName('letter', 'div', document);
	var questionClass = getElementsByClassName('FAQuestion', 'div', document);
	var letterClass = ""; 
	window.onload = function() {	
		for (var i=0; i<containers.length; i++) {
		    letterClass = containers[i].className.substring(containers[i].className.length-1); 
			
			if (document.getElementById(letterClass)) {
			    questionClass[i].style.display = 'none';  


		// OnClick		
                containers[i].onclick= function() { 

				    var blah = this.className.substring(this.className.length-1);
//			        questionClass = getElementsByClassName('FAQuestion', 'div', document);
					var myNewObj = document.getElementById(blah);
					
					if (myNewObj.style.display == 'none') {
					    myNewObj.style.display = 'block';
						myNewObj.getElementsByTagName("div")[0].style.display = 'block'; 
//							myNewObj.style.fontFamily = letterClass + containers.length + questionClass.length;
					} else {
					    myNewObj.style.display = 'none';
//							myNewObj.style.fontFamily = letterClass + containers.length + questionClass.length;
					}
					document.getElementById('FAQuestions').style.display = 'block'; 
				} 
			}  
		}
	}  
}
function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}
function FAQuestionsHide() {
  document.getElementById('FAQuestions').style.display = 'none'; 
}

function fixSearchResult()
{
   var SearchDiv = getElementsByClass("SearchDesp",null,"div") 
   var divSearchResult = getElementsByClass("SearchResultCount",null,"div")
   if(divSearchResult.length<1)
   {
      if(SearchDiv.length>0)
       {
            if(SearchDiv[0].childNodes[0] && SearchDiv[0].childNodes[1])
            {
                var replaceString = "<div class='SearchNoResults'>" + SearchDiv[0].childNodes[0].outerHTML + SearchDiv[0].childNodes[1].outerHTML + ".<span style='margin-left:3px;'>&nbsp;</span></div>";
                var findString = SearchDiv[0].childNodes[0].outerHTML + SearchDiv[0].childNodes[1].outerHTML + ".";
                SearchDiv[0].innerHTML = SearchDiv[0].innerHTML.replace(findString,replaceString);
                SearchDiv[0].removeChild(SearchDiv[0].childNodes[1]);
                SearchDiv[0].className="SearchDispNoResults";
            }
       }
   }
}
document.write("<script type=\"text/javascript\" language=\"javascript\" src=\"../js/AC_RunActiveContent.js\"></script>");
