﻿function fnCookieValue(name, valueToGet){
    var returnValue = "";
    var value = fnGetCookie(name);
    if(value){
        var arrValues = value.split("&");
        for(var i = 0;i < arrValues.length;i++){
            var arrCookies = arrValues[i].split("=");
            if(arrCookies[0] == valueToGet){
                returnValue = arrCookies[1];
                break;
            }
        }
    }
    return returnValue;
}

function fnSetCookie(name, value, expires, path, domain, secure, theWindow) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
      theWindow = (theWindow)? theWindow : window; 
 
  theWindow.document.cookie = curCookie;
}
function fnGetCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}