 /*
    This set of functions are used to parse out a value from a base64 decoded cookie.
    decodeReadCookie - decodes and gets the cookie from base64.js and cookielib.js
    getNameValPrism/setArrayStrPrism/getArrayStr1 - parses out the value of our attribute called from the document.ready
    */
        function decodePrismCookie( mCookie, mAttribute) {
             
             var mSSoCookie;
             if (document.cookie.length > 0)
                {
                var mySplitResult = document.cookie.split(";");
                for (i=0;i<=mySplitResult.length-1;i++)
                {
                    var cookiename = mySplitResult[i].split('=')[0];
                    var cookievalue = mySplitResult[i].split('=')[1];
                    isSSoCookieFound = cookiename.indexOf(mCookie);
                    if (isSSoCookieFound != -1)
                    {
                    mSSoCookie = cookiename.replace(" ","");
                    break;
                    }
                }
                isCookie = document.cookie.indexOf(mSSoCookie+"=");
                if (isCookie != -1){
	                var readCookie = GetCookie(mSSoCookie);
                    var decoded = decode64(readCookie);
                    var returnVal = getNameValPrism(decoded, mAttribute);
                    return returnVal;
	             }
	          }
        }   
        
        function getNameValPrism(cookieName,valName) {
            var cookieString;
            var cookieArray;
            var nameValArray;
            var nameValStr;
            var nameValLength;
            var i;
              
            cookieString = cookieName;
            cookieString = cookieString.replace(/[\u0000-\u0001]+/g, "");
            if (cookieString == null)
            {
                //alert("Debugg -- Cookie " + cookieName + " does not exist");
                return false;
            }
            
            cookieArray = getStringArrPrism(cookieString,";");
            
            if (cookieArray.length == 0) 
            {
               // alert("Debugg -- Cookie does not contain values");
                return false;
            }
                
            nameValStr = setArrayStrPrism(cookieArray,"=");
            nameValArray = getStringArrPrism(nameValStr,"=");
            
            if (nameValArray == 0)
            {
                //alert("Debugg -- nameValArray == 0");
                return false;
            }
           
            nameValLength = nameValArray.length;
            
            for (i = 0; i < nameValLength;)
            {
                //alert(nameValArray[i].toLowerCase());
                if (nameValArray[i].toLowerCase() == valName.toLowerCase())
                {
                    //alert(nameValArray[i+1]);
                    //return stringReplace(nameValArray[i+1], "+", " ");
                    var value = nameValArray[i+1];
                    return unescape(nameValArray[i+1]);
                    
                
                }
              // alert(nameValArray[i].toLowerCase());
                i=i+1; //increment every other array member to just get the key values
            }
            //alert("no entry found in the " + cookieName + " for " + valName);
            
        }


        //Purpose of this function is to create a "symbol" delimited
        //string out of an array of values
        function setArrayStrPrism(strArray,sDelimiter)
        {
            var arrLength;
            var sReturn = ""; 
            var i; 
            arrLength = strArray.length;
            if (arrLength == 0)
            {
                //alert("Nothing to concatenate");
                return false;
            }
            else
            {
                for (i=0;i<arrLength;i++)
                {
                    sReturn = sReturn + strArray[i] + sDelimiter; 
                    
                }
            }
            return sReturn
        }   
            
            
            
        //Purpose of this function is to create a string array
        //out of a "symbol" delimited string
        function getStringArrPrism(strCookieVals,sDelimiter)
        {
            var sReturn
            sReturn = (sDelimiter.length > 0)? strCookieVals.split(sDelimiter) : false;
            if (! sReturn)
            {
                alert("Delimiter not specified")
                return false
            }
            else
            {   
                return sReturn
            }
        }
            