﻿// JScript File

        var expandedIndex = [];
        var allcpe = [];
        function pageLoad() {
            allBehaviors = Sys.Application.getComponents();
            for (var loopIndex = 0; loopIndex < allBehaviors.length; loopIndex++) {
                currentBehavior = allBehaviors[loopIndex];
                if (currentBehavior._name && currentBehavior.get_name() == "CollapsiblePanelBehavior") {
                    allcpe.push(currentBehavior);
                }
            }

            if (getCookie()) {
                expandedIndex = getCookie().split(','); ;
                for (var cpeIndex = 0; cpeIndex < expandedIndex.length; cpeIndex++) {
                    expandedcpe = expandedIndex[cpeIndex];
                    $find(expandedcpe).set_Collapsed(false);
                }
            }
        }

        function pageUnload() {
            expandedIndex = null;
            expandedIndex = [];
            for (var cpeIndex = 0; cpeIndex < allcpe.length; cpeIndex++) {
                currentcpe = allcpe[cpeIndex];
                if (!currentcpe.get_Collapsed()) {
                    //save the expanded cpe's index
                    expandedIndex.push(currentcpe.get_id());
                }
            }
            setCookie(expandedIndex);
        }

        function setCookie(cookieValue) {
            sVar = "cookiename";
            theCookie = sVar + '=' + cookieValue + '; expires=Fri, 1 Jul 2009 11:11:11 UTC';
            document.cookie = theCookie;
        }

        function getCookie() {
            sVar = "cookiename";
            cookies = document.cookie.split('; ');
            for (var i = 1; i <= cookies.length; i++) {
                if (cookies[i - 1].split('=')[0] == sVar) {
                    return cookies[i - 1].split('=')[1];
                }
            }
        }

