/*=============================================================================================
--       SITE/SYSTEM : Brand Platform v2
--       DESCRIPTION : Global JavaScript File
--  REVISION HISTORY : Date      Version   Name             Description
--                     09/27/05  1.0.0.0   Joe Gallagher    Initial version
--                     09/27/05  1.0.0.1   Paul Mealy	    Added 'all' media style for print page
--                     11/02/05  1.0.0.2   Joe Gallagher    Added showGlossary function
--                     11/08/05  1.0.0.3   Paul Mealy       Added Macromedia popup function
=============================================================================================*/
var expandAll = false;
/*===================================
-- Begin image rollover functions
====================================*/
//Preload specified images on the page
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//Restore the specified image to its original state
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//Find image objects with specified IDs
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//Swap oringal image with specifed image
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/*===================================
-- End image rollover functions
====================================*/
/*===================================
--begin window popup function
=====================================*/
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function popPrivacy(){
	popupWin = window.open("http://www.lillyhub.com/legal/consumer/privacy.html","ViewPop","status=0,height=590,width=600,scrollbars=1,resizable=yes,toolbar=0")
}
function popTerms(){
	popupWin = window.open("http://www.lillyhub.com/legal/consumer/termsofuse.html","ViewPop","status=0,height=590,width=600,scrollbars=1,resizable=yes,toolbar=0")
}
function popCopy(){
	popupWin = window.open("http://www.lillyhub.com/legal/consumer/copyright.html","ViewPop","status=0,height=590,width=600,scrollbars=1,resizable=yes,toolbar=0")
}
/*===================================
--end window popup function
=====================================*/

/*===================================
-- Begin text sizing functions
====================================*/
//Resets all the text-size images and sets the correct font
function styleSizer(whichStyle){
	//reset all the images
	MM_swapImage('smallTextButton','','/images/text_small.gif',1);
	MM_swapImage('mediumTextButton','','/images/text_medium.gif',1);
	MM_swapImage('largeTextButton','','/images/text_large.gif',1);
	//then set the correct font
	if(whichStyle=="smallFont"){
		setActiveStyleSheet('regularFont'); 
		MM_swapImage('smallTextButton','','/images/text_small_selected.gif',1);
	}else if(whichStyle=="mediumFont"){
		setActiveStyleSheet('largerFont');
		MM_swapImage('mediumTextButton','','/images/text_medium_selected.gif',1);
	}else if(whichStyle=="largeFont"){
		setActiveStyleSheet('largestFont');
		MM_swapImage('largeTextButton','','/images/text_large_selected.gif',1);
	}
}
//writeImages writes out what image should be live on page load
function writeImages(){
	 var cookie = readCookie("style");
 	 var title = cookie ? cookie : getPreferredStyleSheet();
	//regularFont, largerFont, largestFont
	if(title==null || title=='regularFont'){
		return('<a href="#" onClick="javascript:styleSizer(\'smallFont\');"><img src="/images/text_small_selected.gif" alt="Small text" name="smallTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'mediumFont\');"><img src="/images/text_medium.gif" alt="Medium text" name="mediumTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'largeFont\');"><img src="/images/text_large.gif" alt="Large text" name="largeTextButton" /></a>');
	}else if(title=='largerFont'){
		return('<a href="#" onClick="javascript:styleSizer(\'smallFont\');"><img src="/images/text_small.gif" alt="Small text" name="smallTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'mediumFont\');"><img src="/images/text_medium_selected.gif" alt="Medium text" name="mediumTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'largeFont\');"><img src="/images/text_large.gif" alt="Large text" name="largeTextButton" /></a>');
	}else if(title=='largestFont'){
		return('<a href="#" onClick="javascript:styleSizer(\'smallFont\');"><img src="/images/text_small.gif" alt="Small text" name="smallTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'mediumFont\');"><img src="/images/text_medium.gif" alt="Medium text" name="mediumTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'largeFont\');"><img src="/images/text_large_selected.gif" alt="Large text" name="largeTextButton" /></a>');
	}else{
		return('<a href="#" onClick="javascript:styleSizer(\'smallFont\');"><img src="/images/text_small_selected.gif" alt="Small text" name="smallTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'mediumFont\');"><img src="/images/text_medium.gif" alt="Medium text" name="mediumTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'largeFont\');"><img src="/images/text_large.gif" alt="Large text" name="largeTextButton" /></a>');
	}
}
// 1. Loop through every link element in the document.
// 2. Disable all preferred and alternate style sheets that we don’t want active.
// 3. Enable all preferred and alternate style sheets that we do want active.
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}
//Return the current style sheet
function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}
//Find out which style sheet is the preferred style sheet.
function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}
//Create a cookie to store the preferred style sheet.
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
//Read the cookie to return the prefered style sheet.
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
//On page load get the value of previous style sheeet or use preferred styles sheet.
window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}
//Save the cookie in the onunload event
window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
/*===================================
-- End text sizing functions
====================================*/

/*===================================
-- Begin Printer-Friendly Functions
====================================*/
//Change the status bar when user mouses over the Printer Friendly Version button.
function printOver() {
  window.status="Open a printer friendly version in a new window"
}
//Restore the status bar when user mouses over the Printer Friendly Version button.
function printOut() {
  window.status="";
}
//Get the URL of current page and append ?type=print to it. Open the new page.
function printPage() {
	var append = document.URL;
	if(append!=''){
		var finalURL = append + "?type=print";
	window.open(finalURL);

	}
}
//Get the URL of the current page. If the URL ends in type=print, attach print-friendly styles.
function pageType() {
  var str = document.URL
  point = str.lastIndexOf("?");
  var suffix = (str.substring(point+1,str.length));
  if (suffix == "type=print") {
	document.write("<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"/css/pfriendly.css\">");
//-------

	document.write("<script type=\"text/javascript\">window.print();</script>");
//----------
  }
}
/*===================================
-- End Printer-Friendly Functions
====================================*/

/*===================================
-- Begin Drop-down menu function
====================================*/
// 1. Apply the 'sfhover' class to li elements in the 'nav' id'd ul element when they are 'moused over'
// 2. Remove the 'sfhover' class from li elements in the 'nav' id'd ul element when 'moused out'
sfHover = function() {
	if(document.getElementById("nav")!=null){
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
/*===================================
-- Begin showGlossary Function
====================================*/
function showGlossary(fileName) { 
  var glossRoot = '/1_10_glossary'; 
  var glossWidth = 400; 
  var glossHeight = 150; 
  var glossWinName = 'glossaryWindow'; 
  var glossWinWidgets  = 'toolbars=no,scrollbars=yes,titlebar=no,location=no' + 
                             ',height=' + glossHeight + ',width=' + glossWidth; 
  var glossURL = (glossRoot != '') ? glossRoot + '/' + fileName : fileName; 
  newWin = window.open(glossURL, glossWinName, glossWinWidgets); 
  newWin.focus(); 
}
/*===================================
-- End showGlossary Function
====================================*/

/*===================================
-- Begin emailAFriend functionality
====================================*/
function emailafriend() 
{ 
	var currentSite = window.location.href; 
        var url = ""; 
        if (currentSite.indexOf("-d.xh1.lilly.com") >= 0) {
          url = "https://emailafriend-d.xh1.lilly.com/index.jsp?url=" + currentSite;
        } else if (currentSite.indexOf("-d6.xh1.lilly.com") >= 0) {
          url = "https://emailafriend-d6.xh1.lilly.com/index.jsp?url=" + currentSite;
        } else if (currentSite.indexOf("-qa.xh1.lilly.com") >= 0) {
          url = "https://emailafriend-qa.xh1.lilly.com/index.jsp?url=" + currentSite;
        } else {
          url = "https://emailafriend.lilly.com/index.jsp?url=" + currentSite;
        }

	window.open(url, 'EmailAFriend', 'height=500, resizable=yes, scrollbars=yes, width=650'); 
}
/*===================================
-- End emailAFriend functionality
====================================*/


/*===================================
-- Begin expanding div functionality
====================================*/
function showdetails(divid)
{
var id=divid;
    if(document.getElementById(id).style.display == 'none')
    {
        document.getElementById(id).style.display =  'block';
      
    }
    else
    {
        document.getElementById(id).style.display = 'none';
        
        
    }
    return 0;
    
}



/*===================================
-- End expanding div functionality
====================================*/




/*===================================
Expand-collapse  functionality
====================================*/
function expandcollapse(sectionname)
{

var sname=sectionname;
var tot=0;
if(sectionname=='adult')
{
// tot=16;
tot=15;
}
else
{
if(sectionname=='child')
{
tot=17;
}
}
expandAll = !expandAll;
	var blockToggle = 'none';

  if(expandAll) {
  	blockToggle = 'block';
  } else {
 	blockToggle = 'none';
  }

for(var i=1; i<=tot; i++)
{
var qid='question'+i.toString();


document.getElementById(qid).style.display = blockToggle;
}
}




/*===================================
-- End Expand-collapse  functionality
====================================*/


/*===================================
-- begin screener code
====================================*/


    // 20060308 Request page query object
    function PageQuery(q) {
        if(q.length > 1) {
            this.q = q.substring(1, q.length);
        } else {
            this.q = null;
        }
        this.keyValuePairs = new Array();
        if(q) {
            for(var i=0; i < this.q.split("&").length; i++) {
                this.keyValuePairs[i] = this.q.split("&")[i];
            }
        }
        this.getKeyValuePairs = function() { return this.keyValuePairs; }
        this.getValue = function(s) {
            for(var j=0; j < this.keyValuePairs.length; j++) {
                if(this.keyValuePairs[j].split("=")[0] == s) {
                    return this.keyValuePairs[j].split("=")[1];
                }
            }
            return false;
        }
        this.getParameters = function() {
            var a = new Array(this.getLength());
            for(var j=0; j < this.keyValuePairs.length; j++) {
                a[j] = this.keyValuePairs[j].split("=")[0];
            }
            return a;
        }
        this.getLength = function() { return this.keyValuePairs.length; }
    }

    // 20060308 page instance of page query object
    var pageQuery = new PageQuery(window.location.search);
    function displayQueryGET(key){ // returns value of get param -- requires page instance of page query object
        var getGETResult = pageQuery.getValue(key);
        if (getGETResult) {
            getGETResult = unescape(getGETResult);
        } else {
            getGETResult = "";
        }
        return getGETResult;
    }

    // 20060308 Image coordinate object and methods
    function objectCoordinates(objCoordX, objCoordY, objTrueX, objTrueY) {
        this.objCoordX = objCoordX;
        this.objCoordY = objCoordY;
        this.objTrueX = objTrueX;
        this.objTrueY = objTrueY;
    }

    function getImageCoordinates(imageObjId, xOffset, yOffset) {
        var theObject = document.images[imageObjId];
        if (theObject == null) {
            return null;
        }
        if (imageObjId.indexOf('_right') != -1) {
            xOffset = xOffset - theObject.width;
        }
        theObject.style.position = "absolute"

        var objX = 0;
        var objY = 0;
        var objTX = 0;
        var objTY = 0;
        if (document.layers) {
            objX=theObject.x;
            objY=theObject.y;
            objTX=objX - window.pageXOffset;
            objTY=objY - window.pageYOffset;
        } else if (document.all) {
            objX=theObject.offsetLeft;
            objY=theObject.offsetTop;
            objTX=objX - document.body.scrollLeft;
            objTY=objY - document.body.scrollTop;
        } else {
            objX=theObject.offsetLeft;
            objY=theObject.offsetTop;
            objTX=objX - document.body.scrollLeft;
            objTY=objY - document.body.scrollTop;
        }
        objX+=xOffset;
        objY+=yOffset;
        objTX+=xOffset;
        objTY+=yOffset;
        theObject.style.position = "static";
        return new objectCoordinates(objX, objY, objTX, objTY);
    }
    function toggleVisibility(visId) {
        var visObj = document.getElementById(visId);
        if (visObj.style.display=='none') {
            visObj.style.display = ''
        } else {
            visObj.style.display = 'none'
        }
    }

    // 20060308 final state constants
    var SCREENER_STATE_INITIAL = 1;
    var SCREENER_STATE_POSITIVE = 2;
    var SCREENER_STATE_NEGATIVE = 3;
    var SCREENER_STATE_INITIAL_LAYER = "screener_initial";
    var SCREENER_STATE_POSITIVE_LAYER = "screener_positive";
    var SCREENER_STATE_NEGATIVE_LAYER = "screener_negative";

    // Screener state object
    function ScreenerState() {
        this.state = SCREENER_STATE_INITIAL;
        this.printMode = false;
        // Screener state object method
        this.setState = function (tmpState) {
            if (tmpState && tmpState != null && tmpState != '' && (tmpState == SCREENER_STATE_POSITIVE || tmpState == SCREENER_STATE_NEGATIVE)) {
                this.state = tmpState;
            } else {
                this.state = SCREENER_STATE_INITIAL;
            }
        }
        this.setPrintMode = function (tmpMode) {
            if (tmpMode && tmpMode != null) {
                if (tmpMode != '' && (tmpMode.toUpperCase() == 'YES') || tmpMode.toUpperCase() == 'TRUE') {
                    this.printMode = true;
                } else {
                    this.printMode = false;
                }
            } else {
                this.printMode = false;
            }
        }
    }

    function ScreenerResultObject() {
        this.q0 = 0;
        this.q1 = 0;
        this.q2 = 0;
        this.q3 = 0;
        this.q4 = 0;
        this.q5 = 0;
        this.setQ = function(qIdx, qVal) {
            if (qIdx && qVal && qIdx != '' && qVal != '') {
                if (qIdx == 'q0') {
                    this.q0 = qVal - 0;
                } else if (qIdx == 'q1') {
                    this.q1 = parseInt(qVal);
                } else if (qIdx == 'q2') {
                    this.q2 = parseInt(qVal);
                } else if (qIdx == 'q3') {
                    this.q3 = parseInt(qVal);
                } else if (qIdx == 'q4') {
                    this.q4 = parseInt(qVal);
                } else if (qIdx == 'q5') {
                    this.q5 = parseInt(qVal);
                }
            }
        }
        this.getTotal = function() {
            var tmpTotal = this.q0 + this.q1 + this.q2 + this.q3 + this.q4 + this.q5;
            return tmpTotal;
        }
        this.evaluateStatus = function() {
            var total = 0;
            if (this.q0 >= 2) {
                total += 1;
            }
            if (this.q1 >= 2) {
                total += 1;
            }
            if (this.q2 >= 2) {
                total += 1;
            }
            if (this.q3 >= 3) {
                total += 1;
            }
            if (this.q4 >= 3) {
                total += 1;
            }
            if (this.q5 >= 3) {
                total += 1;
            }
            if (total >= 4) {
                return SCREENER_STATE_POSITIVE;
            } else {
                return SCREENER_STATE_NEGATIVE;
            }
        }
        this.getLabel = function(resKey) {
            if (resKey == 0) {
                return "Never";
            } else if (resKey == 1) {
                return "Rarely";
            } else if (resKey == 2) {
                return "Sometimes";
            } else if (resKey == 3) {
                return "Often";
            } else if (resKey == 4) {
                return "Very Often";
            }
        }
    }






    var totalNumberOfQuestions = 6; // total number of survey questions

    var screenerStateObj; // page scope screener state object to be initialized
    var screenerResultObj; // page scope screener result object to be initialized
    function initializeScreener() { // page initialization method -- first to be run
        screenerStateObj = new ScreenerState();
        screenerStateObj.setState(displayQueryGET('screenerStateGET'));
        screenerStateObj.setPrintMode(displayQueryGET('printMode'));
        screenerResultObj = new ScreenerResultObject();
        for (var i=0; i<totalNumberOfQuestions; i++) {
            var tmpGET = "q" + i;
            screenerResultObj.setQ(tmpGET, displayQueryGET(tmpGET));
        }
        if (screenerStateObj.printMode) {
            hidePrintButtons();
        }
        displayScreenerLayer();
	  var questionWrapHeight = getImageCoordinates("questionnaireTableBottomImg", 0, 0).objCoordY - getImageCoordinates("questionnaireTableTopImg", 0, 0).objCoordY;
	  document.getElementById("screenerBodyQuestionWrap").style.height=questionWrapHeight+10;
    }
    function hidePrintButtons() {
        document.getElementById("printerFriendlyButton1").style.display="none";
        document.getElementById("printerFriendlyButton2").style.display="none";
        document.getElementById("printerFriendlyButton3").style.display="none";
//        document.getElementById("printButton1").style.display="none";
//        document.getElementById("printButton2").style.display="none";
//        document.getElementById("printButton3").style.display="none";
//        document.getElementById("printButton4").style.display="none";
    }
    function displayScreenerLayer() {
        var screenerImgObj = getImageCoordinates("screenerLocationImg", -1, 6);
        var screener_initialObj = document.getElementById(SCREENER_STATE_INITIAL_LAYER);
        var screener_negativeObj = document.getElementById(SCREENER_STATE_NEGATIVE_LAYER);
        var screener_positiveObj = document.getElementById(SCREENER_STATE_POSITIVE_LAYER);
        screener_initialObj.style.left = screenerImgObj.objCoordX + 'px';
        screener_negativeObj.style.left = screenerImgObj.objCoordX + 'px';
        screener_positiveObj.style.left = screenerImgObj.objCoordX + 'px';
        screener_initialObj.style.top = screenerImgObj.objCoordY + 'px';
        screener_negativeObj.style.top = screenerImgObj.objCoordY + 'px';
        screener_positiveObj.style.top = screenerImgObj.objCoordY + 'px';

        if (screenerStateObj.state == SCREENER_STATE_POSITIVE || screenerStateObj.state == SCREENER_STATE_NEGATIVE) {
            if (screenerStateObj.state == SCREENER_STATE_POSITIVE) {
                toggleVisibility(SCREENER_STATE_POSITIVE_LAYER);
            } else if (screenerStateObj.state == SCREENER_STATE_NEGATIVE) {
                toggleVisibility(SCREENER_STATE_NEGATIVE_LAYER);
            }
            toggleVisibility("questionnaireResultBody");
            var questionnaireBodyTopImg = getImageCoordinates("resultTableTopImg", 0, 0);
            var questionnaireBodyBottomImg = getImageCoordinates("resultTableBottomImg", 0, 0);
            var questionnaireBodyHeight = questionnaireBodyBottomImg.objCoordY - questionnaireBodyTopImg.objCoordY;

            if (screenerStateObj.state == SCREENER_STATE_POSITIVE) {
                document.getElementById("screenerResultBodySpacePositive").style.height=questionnaireBodyHeight+'px';
            } else if (screenerStateObj.state == SCREENER_STATE_NEGATIVE) {
                document.getElementById("screenerResultBodySpaceNegative").style.height=questionnaireBodyHeight+'px';
            }

            for (var i=0; i<totalNumberOfQuestions; i++) {
                var tmpQVal = eval('screenerResultObj.q' + i);
                var tmpQTargetId = "questionnaireResult_" + i;
                document.getElementById(tmpQTargetId).innerHTML = screenerResultObj.getLabel(tmpQVal);
            }
        } else {
            toggleVisibility(SCREENER_STATE_INITIAL_LAYER);
            toggleVisibility('questionnaireBody');
            for (var i=0; i<totalNumberOfQuestions; i++) {
                var tmpQVal = eval('screenerResultObj.q' + i);
                if (tmpQVal > 0) {
                    var tmpQTargetId = "q" + i + tmpQVal;
                    document.getElementById(tmpQTargetId).checked = true;
                }
            }
        }
        var questionLocImgName = 'questionnaireLocationImg_' + screenerStateObj.state;
        var questionBodyObj = document.getElementById('questionnaireBody');
        var questionResultObj = document.getElementById('questionnaireResultBody');
        var tmpImgCoord = getImageCoordinates(questionLocImgName, 0,0);
        var questionLocObj = document.getElementById(questionLocImgName);
        questionBodyObj.style.left = tmpImgCoord.objCoordX + screenerImgObj.objCoordX + 'px';
        questionBodyObj.style.top = tmpImgCoord.objCoordY + screenerImgObj.objCoordY + 'px';
        questionResultObj.style.left = tmpImgCoord.objCoordX + screenerImgObj.objCoordX + 'px';
        questionResultObj.style.top = tmpImgCoord.objCoordY + screenerImgObj.objCoordY + 'px';
    }

	function evaluateScreener() {
		if (validateScreener() == true) {
            var screenerResultObj = new ScreenerResultObject();
            var scoreRange = 5;
            for (var xi=0; xi<totalNumberOfQuestions; xi++) {
                for (var i=0 ; i< scoreRange; i++) {
                    var tmpQuestionId = "q" + xi + i;
                    var tmpQuestionObj = document.getElementById(tmpQuestionId);
                    if (tmpQuestionObj.checked) {
                        var tmpIdx = "q" + xi;
						screenerResultObj.setQ(tmpIdx, tmpQuestionObj.value);
                    }
                }
            }
            document.getElementById('screenerStateGET').value = screenerResultObj.evaluateStatus();
            document.getElementById("screenerForm").submit();
        }
        return false;
	}
	function resetScreener() {
        var screenerFormObj = document.getElementById('screenerForm');
		screenerFormObj.reset();
	}
	function validateScreener() {
        var screenerFormObj = document.getElementById('screenerForm');
		for (var xi=0; xi<totalNumberOfQuestions; xi++) {
			var tmpQuestionObjectName = "q" + xi;
			var thisQuestionNumber = xi + 1;
			var thisQuestionIsAnswered = false;
			for (var i=0; i<screenerFormObj.elements.length; i++) {
				var tmpElementObj = screenerFormObj.elements[i];
				if (tmpElementObj.type == 'radio' && tmpElementObj.name == tmpQuestionObjectName) {
                    if (tmpElementObj.checked == true) {
						thisQuestionIsAnswered = true;
					}
				}
			}
			if (thisQuestionIsAnswered == false) {
				alert("Please complete question " + thisQuestionNumber);
				return false;
			}
		}
		return true;
	}

	
	/*    function to load questions in right tout */
	/* begin */
		
	function loadQuestion(category) {
	 var questions=new Array();
	 var qno=new Array();
	 
	 if ( category == 'adult' ) {
		 questions[0]="What kind of medicine is Strattera?";
		 questions[1]="In what ways can <br>Strattera help?";
		 questions[2]="Should my dose of<br> Strattera change over<br> time?";
		 questions[3]="How soon might Strattera start to work?";
		 questions[4]="What does gradual improvement mean?";

		 qno[0]="1";
		 qno[1]="8";
		 qno[2]="11";
		 qno[3]="12";
		 qno[4]="13";
	 }
	 else if (category == 'child' ) {
		 questions[0]="What kind of medicine is Strattera?";
		 questions[1]="How might Strattera help my child?";
		 questions[2]="Should my child's dose<br> of Strattera change<br> over time?";
		 questions[3]="How quickly might <br>Strattera start to work?";
		 questions[4]="What does gradual improvement mean?";
		 questions[5]="Can I open a Strattera capsule?";

		 qno[0]="1";
		 qno[1]="8";
		 qno[2]="11";
		 qno[3]="12";
		 qno[4]="13";
		 qno[5]="5";
		 
	 }

	 // random number
	 var rnum = Math.floor(Math.random()* qno.length) // generates number between 0-4 (adult) or 0-5 (child)

	 var olddiv = document.getElementById('question_container_curr_q'); 
	 
	 var container = document.getElementById("question_container");

	 /// delete the div that has a question
	 if ( olddiv != null ) container.removeChild( olddiv );
	 // create a new div to load the question
	 var newdiv = document.createElement("div");
	 newdiv.setAttribute('id', 'question_container_curr_q' );
	 
	 if ( detectBrowser() == "Netscape" ) {
			// for firefox add padding
			newdiv.setAttribute('style', 'padding-top:80px');
	 }
	 
	// set the link... if it is FAQ page then redirect back to faq page when the link is clicked.
	 if ( category == 'adult') {
		newdiv.innerHTML = "<a onmouseout='this.style.textDecoration=\"underline\";' onmouseover='this.style.textDecoration=\"none\";' style='text-decoration:underline; color:#005C98;' href='#' onclick=faq_redirect('/adult/frequently_asked_questions/frequently_asked_questions_adult.jsp#"+qno[rnum]+"');>"+questions[rnum]+"</a>";
	 }
	 else {
		newdiv.innerHTML = "<a onmouseout='this.style.textDecoration=\"underline\";' onmouseover='this.style.textDecoration=\"none\";' style='text-decoration:underline; color:#005C98;' class='mostAskedQuestion' href='#' onclick=faq_redirect('/child/frequently_asked_questions/frequently_asked_questions_child.jsp#"+qno[rnum]+"');>"+questions[rnum]+"</a>";
	 }
	 container.appendChild(newdiv);

		setTimeout ( "loadQuestion('"+ category +"')", 3000 ) ; // 3 second delay...
	}
	
	function faq_redirect(url) {
		document.location.href=url;
	}
		
		
    /* end */   
		
	/* functions for where i have been tout */
	
	function showWhereIHaveBeen( section ) {
		
	  var nameEQ = name + "=";
	  //alert(document.cookie);
	  var ca = document.cookie.split(';');

      var visited_pages = new Array() ;
	  var index = 0;
	  
	  for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			//alert('c = ' + c );
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			var da = c.split('=');
			//alert('da = ' + da );
				var k = da[0];
				var v = da[1];
				//alert('k = ' + k + ' v = ' + v );
				
				// if the value is one of the tagged page values then store it in an array
				if ( isCookiedPage(k) && v == '1') {
					visited_pages[index]=k;
					index++;
				}
				/*if( document.getElementById(k) != null ) {
					if ( v != '0' ) {
						//alert('setting display block' );
						document.getElementById(k).style.display='block';
					}
				}*/
		}
	  
		// now we should have the array of bookmarked pages.
	    // start from bottom of the array to list the links...
		var items = visited_pages.length;
		if ( items > 0 ) {

			var container = document.getElementById('whereihavebeen');
			
			for ( var i=items; i>0; i-- ) {
				var newdiv = document.createElement("div");
				newdiv.setAttribute('id', 'bn'+i );
				newdiv.innerHTML = getBookmarkLink( visited_pages[i-1], section ) ;
				container.appendChild(newdiv);
			}
			// there are no items ; so display the inactive one..
			document.getElementById('whereihavebeeninactive').style.display =  'none';
			document.getElementById('whereihavebeenactive').style.display =  'block';
			
		}
		else {
			// there are no items ; so display the inactive one..
			document.getElementById('whereihavebeeninactive').style.display =  'block';
			document.getElementById('whereihavebeenactive').style.display =  'none';
		}
	}
	
	/* delete cookies set for where i have been pages when a user switches from child to adult or vice versa */
	function clearWhereIHaveBeenCookies() {
		// set expiry date for cookies set for category ( adult or child )
			createCookie("bn-hsch", "0", -200);
			createCookie("bn-bos", "0", -200);
			createCookie("bn-tt", "0", -200);
			createCookie("bn-rs", "0", -200 );
			createCookie("bn-em", "0", -200 );
			createCookie("bn-cse", "0", -200 );
			createCookie("bn-gags", "0", -200);
			createCookie("bn-ts", "0", -200);
			createCookie("bn-typ", "0", -200);
			createCookie("bn-pt", "0", -200);
			createCookie("bn-isi", "0", -200 );
			createCookie("bn-di", "0" , -200 );
			createCookie("bn-faq", "0", -200 );
	}
	

	function getBookmarkLink( val, sec ) {
		var link ;
		
		switch(val) {
			case 'bn-hsch':
					link = '<a href="/' + sec + '/how_strattera_help/howstratterahelp_'+ sec + '.jsp">How Strattera Can Help</a>';
					break;
			case 'bn-bos':
					link = '<a href="/'+ sec + '/how_strattera_help/benefits_of_strattera_'+sec+'.jsp">Benefits of Strattera</a>';
					break;
			case 'bn-tt':
					link = '<a href="/' + sec + '/how_strattera_help/total_treatment_' + sec + '.jsp">Treatment Program</a>';
					break;
			case 'bn-rs':
					link = '<a href="/' + sec + '/how_strattera_help/real_stories_'+ sec + '.jsp">Real Stories</a>';
					break;
			case 'bn-em':
					link = '<a href="/'+ sec + '/how_strattera_help/educational_material_'+ sec + '.jsp">Resources</a>';
					break;
			case 'bn-cse':
                    link = '<a href="/' + sec + '/how_strattera_help/side_effects_'+ sec + '.jsp">Common Side Effects</a>';
					break;
			case 'bn-gags':
					link =  '<a href="/' + sec + '/get_good_start/get_good_start_' + sec + '.jsp">Get a Good Start</a>';
					break;
			case 'bn-ts':
					link =  '<a href="/' + sec + '/get_good_start/taking_strattera_' + sec + '.jsp">Taking Strattera</a>';
					break;
			case 'bn-typ':
					link =  '<a href="/' + sec + '/track_progress/track_progress_'+ sec + '.jsp">Tracking Progress</a>';
					break;
			case 'bn-pt':
					link = '<a href="/'+ sec + '/track_progress/tracker_' + sec + '.jsp">Progress Tracker</a>';
					break;
			case 'bn-isi':
					link = '<a href="/' + sec + '/important_safety_info/important_safety_info_' + sec + '.jsp">Important Safety<br> Information</a>';
					break;
			case 'bn-di':
					link = '<a href="/' + sec + '/important_safety_info/dosing_' + sec + '.jsp">Dosing Information</a>';
					break;
			case 'bn-faq':
                    link = '<a href="/' + sec + '/frequently_asked_questions/frequently_asked_questions_' + sec + '.jsp">Frequently Asked<br> Questions</a>';
					break;
		}
		return link ;
	}
	
	function isCookiedPage( val ) {
		
		var str = "bn-hsch,bn-bos,bn-tt,bn-rs,bn-em,bn-cse,bn-gags,bn-ts,bn-typ,bn-pt,bn-isi,bn-di,bn-faq";
		return str.indexOf( val ) >= 0;
	}
	
	/* detect browser */
	function detectBrowser() {
			return navigator.appName;
	}
	
	
	/* scroller */
	defaultStep=1
	step=defaultStep
	function scrollDivDown(id){
		document.getElementById(id).scrollTop+=step
		timerDown=setTimeout("scrollDivDown('"+id+"')",10)
	}

	function scrollDivUp(id){
		document.getElementById(id).scrollTop-=step
		timerUp=setTimeout("scrollDivUp('"+id+"')",10)
	}
	/* scroller end */