$(document).ready(function() { if(questionExists(51) == false) // set up the questions into cookies at first load. { loadQuestionsIntoCookie(); } initialQuestionLoad(); // preload the overlay. /* ********** Event Handlers ***************** */ $("div#questions_head, a[rel='edit_link'], p#learnMoreP").click(function(e) // handle click for the question box. { openMask(); }); $("#mask, img[rel='close_window']" ).click(function(e) // set mask fade out click. { $("#mask").fadeOut("fast"); $("#overlayContainer").fadeOut("fast"); $("#modalISIContainer").fadeOut("fast"); }); $("img[rel='print_window'], a[rel='print_link']").click(function(e) // add popup window action for the print button { window.open("landing_printQuestions.jsp", "printWindow", "width=765,height=500,scrollbars=1,resizable=0"); }); $(".questionLineContainer, .questionLineContainerAlt").click(function(e) // handle for click on each line item { var currNumber = $(this).attr("rel").substr(7); if (!$(".questionLineText", this).hasClass("isSelected")) { $(".questionLineText", this).css("font-weight", "bold").addClass("isSelected"); $("div.questionLineButton img", this).attr("src", "images/questions/questionline_button_on.gif"); writeClickCookie(currNumber); $("div#questions_body").show(); // explictly show the div just in case. $(".overview").append("

" + toolTipText[currNumber] + "

"); // also post to the sidebar // update the scrollbar if ($('#scrollbar1').tinyscrollbar()!= null) { $('#scrollbar1').tinyscrollbar().update(); } } else { $(".questionLineText", this).css("font-weight", "normal").removeClass("isSelected"); $("div.questionLineButton img", this).attr("src", "images/questions/questionline_button.png"); deleteCookie("qSelected",currNumber); $(".overview").children("p[name=qid" + currNumber + "]").remove(); // remove from the sidebar // update the scrollbar if ($('#scrollbar1').tinyscrollbar()!= null) { var oScrollbar = $('#scrollbar1').tinyscrollbar().update(); // update the scrollbar } if(document.cookie.indexOf("qSelected") < 0) // check to see if we collapse the sidebar { $("div#questions_body").hide(); } } }); /* ************************ Functions ************************ */ function openMask() // open the modal window { var maskWidth = $(window).width(); var maskHeight = $(document).height(); $("#mask").css( { "width": maskWidth, "height": maskHeight }).fadeIn(1000).fadeTo("slow", 0.8); if($(window).width() > $("#overlayContainer").width()) { $("#overlayContainer").css("left", ($(window).width()/2) - ($("#overlayContainer").width()/2)); } else { $("#overlayContainer").css("left", 0); } $("#overlayContainer").css("top", 110).fadeIn(2000); doColumnHeights(); // set the heights positionISI(); // position the ISI } // load the questions into the question container function initialQuestionLoad() { var currQuestion = ""; var alreadySelected = ""; var currQuestionText = ""; var cookieArray = document.cookie.split(";"); for(var iloop = 0; iloop <= cookieArray.length; iloop++) { if(cookieArray[iloop] != undefined) { var currentCookie = cookieArray[iloop]; currQuestion = cookieArray[iloop].replace(" ", ""); // if(currentCookie.length >0 && currQuestion.substring(0,9) == "qSelected")//deletes new site selected questions // { // currQuestion = currQuestion.substring( 9, currQuestion.indexOf("=")); // //alert(" qSelected =="+ currQuestion); // if(currQuestion < 50) // deleteCookie("qSelected",currQuestion); // } if(currentCookie.length >10 && currQuestion.substring(0,7) == "qCookie") { currQuestion = currQuestion.substring( 7, currQuestion.indexOf("=")); // if(currQuestion < 50)// deletes old site question list // { // //alert(" qCookie =="+ currQuestion); // deleteCookie("qCookie",currQuestion); // } if(currQuestion >50) { alreadySelected = document.cookie.indexOf("qSelected" + currQuestion + "="); // check if the line was already selected currQuestionText = cookieArray[iloop].replace(" ", ""); if(currQuestionText != "") { writeQuestionToPanel(currQuestionText, alreadySelected); } } } } } doAlternativeColorsQuestions(); // handle for the alternating backgrounds. } function positionISI() { var isiTop = $("#overlayContainer").offset().top + $("#questionsContainerTop").outerHeight() + $("#questionsContainerBottom").outerHeight() + $("#questionsMainCenter").outerHeight() + 20; $("#modalISIContainer").css("top", isiTop).show(); // display and position the ISI // set overlay if($(window).width() > $("#modalISIContainer").width()) { $("#modalISIContainer").css("left", ($(window).width()/2) - ($("#modalISIContainer").width()/2)); } else { $("#modalISIContainer").css("left", 0); } $("#mask").height($(document).height()); // reset the mask height } // write question in form of qCookieNN=QuestionText to the panel function writeQuestionToPanel(currentQuestion, alreadySelected) { var questionText = ""; var buttonText = ""; var questionArray = currentQuestion.split("="); (alreadySelected >= 0) ? questionText = "

" + questionArray[1] + "

" : questionText = "

" + questionArray[1] + "

"; (alreadySelected >= 0) ? buttonText = "
" : buttonText = "
"; $("div#questionsMainQuestions").append("
" + questionText + buttonText + "
"); } // run through the questions and alteranate the background colors dynamically. function doAlternativeColorsQuestions() { var alt = -1; $("#questionsMainQuestions > div").each( function(e) { alt = alt * -1; if(alt < 0) { $(this).addClass("questionLineContainerAlt").removeClass("questionLineContainer"); } }); } // set the modal window column heights based on the center column. function doColumnHeights() { var questionContentHeight = $("div#questionsMainCenter").height(); $("div#questionsMainLeft").height(questionContentHeight); $("div#questionsMainRight").height(questionContentHeight); $("div#questionsContainerBottom").css("top", questionContentHeight + $("div#questionsContainerTop").height()); } }); /* ***************** Shared Javascript Functions ******************** */ // load all of the questions into cookies. function loadQuestionsIntoCookie() { // document.cookie = "qCookie1=landing_modal_window.jsIf I have had a procedure like cardiac bypass surgery or angioplasty\, how does that affect my risk?"; // document.cookie = "qCookie2=I did not watch my diet or exercise when I was younger. Does that put me at high risk?"; // document.cookie = "qCookie3=What lifestyle changes should I make to reduce my risk?"; // document.cookie = "qCookie4=I\'m already taking other medicines\, can MICARDIS 80 mg do more to lower my risk?"; document.cookie = "qCookie51=If I have had a procedure like cardiac bypass surgery or angioplasty\, how does that affect my risk?"; document.cookie = "qCookie52=I did not watch my diet or exercise when I was younger. Does that put me at high risk?"; document.cookie = "qCookie53=What lifestyle changes should I make to reduce my risk?"; document.cookie = "qCookie54=I'm already taking other medicines\, can MICARDIS 80 mg do more to lower my risk?"; document.cookie = "qCookie55=If I had a heart attack\, stroke\, or mini stroke\, am I at high risk?"; document.cookie = "qCookie56=What is MICARDIS 80 mg and how can it help me? "; document.cookie = "qCookie57=With all the meds I'm taking\, will MICARDIS 80 mg cause a drug interaction?"; document.cookie = "qCookie58=What side effects does MICARDIS 80 mg cause?"; document.cookie = "qCookie59=I'm living with stable angina\, so is MICARDIS 80 mg a medicine I should take?"; document.cookie = "qCookie60=I've already had a heart attack. Can MICARDIS 80 mg reduce my risk of another?"; document.cookie = "qCookie61=With the history of stroke in my family\, should I begin taking MICARDIS 80 mg?"; } // find the current question in the cookie array function getCurrentQuestionFromArray(cookieArray, currQ) { var currQuestion = ""; for(k = 0; k < cookieArray.length; k++) { if(cookieArray[k].indexOf(currQ) >= 0) { return cookieArray[k].replace(" ", ""); // for some reason it adds whitespace, remove it } } return currQuestion; } function writeClickCookie(currNumber) { document.cookie = "qSelected" + currNumber + "=yes"; } function deleteCookie(name,currNumber) { document.cookie = name + currNumber + "=yes;expires=Thu, 01-Jan-1970 00:00:01 GMT"; }