$(document).ready(function() { // first check if there are any selected items if (document.cookie.indexOf("qSelected") >= 0) { var showQbox = false; var cookieArray = document.cookie.split(";"); // iterate through the cookies, look for index items that have already been selected. for (i = 0; i < cookieArray.length; i++) { if (cookieArray[i].indexOf("qSelected") >= 0) { var cookieNumber = cookieArray[i].substring(10, cookieArray[i].indexOf("=")); // pull out the number from the qSelected variable. if(cookieNumber > 50) { showQbox = true; } } } if (showQbox == true) { $("div#questions_body").show(); populateSelectedQuestions(); // update the scroll bar on load var oScrollbar = $('#scrollbar1'); oScrollbar.tinyscrollbar(); oScrollbar.update(); } else { $("div#questions_body").hide(); } } else { $("div#questions_body").hide(); } function populateSelectedQuestions() { // iterate through the cookies, look for index items that have already been selected. for (i = 0; i < cookieArray.length; i++) { if (cookieArray[i].indexOf("qSelected") >= 0) { var cookieNumber = cookieArray[i].substring(10, cookieArray[i].indexOf("=")); // pull out the number from the qSelected variable. if(cookieNumber > 50) { addQuestionToList(cookieNumber); } } } } function addQuestionToList(questionNumber) { var questionIndex = "qCookie" + questionNumber + "="; for (j = 0; j < cookieArray.length; j++) { if (cookieArray[j].indexOf(questionIndex) >= 0) { var currentQuestion = cookieArray[j]; var tempArray = currentQuestion.split("="); writeQuestionToScreen(tempArray[1], questionNumber); } } } function writeQuestionToScreen( questionText, questionNumber ) { $(".overview").append("

" + questionText + "

"); } });