var  CString;
var  CorgID= "", newCorgID="", CprofID="", newCprofID="", CcustID="", newCcustID="";
function getCookie (name) {
    var dcookie = document.cookie; 
    var cname = name + "=";
    var clen = dcookie.length;
    var cbegin = 0;
        while (cbegin < clen) {
        var vbegin = cbegin + cname.length;
            if (dcookie.substring(cbegin, vbegin) == cname) { 
            var vend = dcookie.indexOf (";", vbegin);
                if (vend == -1) vend = clen;
            return unescape(dcookie.substring(vbegin, vend));
            }
        cbegin = dcookie.indexOf(" ", cbegin) + 1;
            if (cbegin == 0) break;
        }
    return null;
    }

function setCookie (name, value, expires) {
    document.cookie = name + "=" + escape (value) +     
    "; expires=" + expires.toGMTString() +  "; path=/"; 
    }                                                       


function getAllIds() {
   CorgID  = getCookie("CorgID");
   CprofID = getCookie("CprofID");
   CcustID = getCookie("CcustID");
   var cpc = CorgID + ";" + CprofID + ";" + CcustID;
   if(cpc.length > 14){
   document.NewBar3.showStatus(cpc);}
}

function setCIDs(custStr) {
 CString = custStr; 
 var i = CString.indexOf(";");
 var j = CString.lastIndexOf(";");
 newCorgID = CString.substring(0,i); newCprofID = CString.substring(i+1,j);
 newCcustID = CString.substring(j+1);
 var expdate = new Date ();
    expdate.setTime (expdate.getTime() + (1000 * 60 * 60 * 24 * 186));
    if(CorgID != newCorgID) {
      setCookie ("CorgID", newCorgID, expdate);
    }
    if(CprofID != newCprofID) {
      setCookie ("CprofID", newCprofID, expdate);
    }
    if(CcustID != newCcustID) {
      setCookie ("CcustID", newCcustID, expdate);
    }
}

