browser.cookie.getElectos = function(sWebsite, sVar){
	var sResult = null, aCookies, aCookie, iCookies, iCookie, sCookie, aChocChips;
	
	if (document.cookie){
		// Open the box - get all cookies for this website
		aCookies = document.cookie.split(';');
		for (iCookies = 0; iCookies < aCookies.length && sResult == null; iCookies++){
		    // seperate cookies - break cookies up.
			aCookie = aCookies[iCookies].split('&');
			if(aCookie.length > 1){
			    // Find a cookie that starts with this website name
			    sCookie=aCookie.join();
			    if (sCookie.indexOf(sWebsite+"=")==0 || sCookie.indexOf(sWebsite+"=")==1){
			        // Remove the website name from the cookie
			        sCookie=sCookie.replace(sWebsite+"=","");
			        aCookie=sCookie.split(',');
    			    // crumble the cookie - break cookie array into another array
                    for(iCookie = 0; iCookie < aCookie.length && sResult == null; iCookie++){
            			aChocChips = aCookie[iCookie].split('=');
            			// lick each chocolate chip - check each array item to see if it is the data we are looking for.
        				if(browser.data.trim(aChocChips[0]) == browser.data.trim(sVar)){
        					return aChocChips[1];	
        				}
                    }
			    }
			}
		}
	}
	// unable to locate cookie value
	return null;
}

browser.cookie.setElectos = function(sWebsite, sVar, sVal){
	var sResult = null, aCookies, aCookie, iCookies, iCookie, sCookie, aChocChips;
	
	if (document.cookie){
		// Open the box - get all cookies for this website
		aCookies = document.cookie.split(';');
		for (iCookies = 0; iCookies < aCookies.length && sResult == null; iCookies++){
		    // seperate cookies - break cookies up.
			aCookie = aCookies[iCookies].split('&');
			if(aCookie.length > 1){
			    // Find a cookie that starts with this website name
			    sCookie=aCookie.join();
			    if (sCookie.indexOf(sWebsite+"=")==0 || sCookie.indexOf(sWebsite+"=")==1){
			        // Remove the website name from the cookie
			        sCookie=sCookie.replace(sWebsite+"=","");
			        aCookie=sCookie.split(',');
    			    // crumble the cookie - break cookie array into another array
                    for(iCookie = 0; iCookie < aCookie.length && sResult == null; iCookie++){
            			aChocChips = aCookie[iCookie].split('=');
            			// lick each chocolate chip - check each array item to see if it is the data we are looking for.
        				if(browser.data.trim(aChocChips[0]) == browser.data.trim(sVar)){
        					//sResult = aChocChips[1];	
        					aChocChips[1]=sVal;
        					sCookie=aChocChips.join("=");
        					aCookie[iCookie]=sCookie;
        					sCookie=aCookie.join("&");
        					sCookie=sWebsite+"="+sCookie;
        					browser.cookie.set(sWebsite, sCookie);
        					return;
        				}
                    } 
                    
                    aChocChips = new Array();
                    aChocChips[0] = sVar;
                    aChocChips[1] = sVal;
					sCookie=aChocChips.join("=");
					aCookie[iCookie]=sCookie;
					sCookie=aCookie.join("&");
					sCookie=sWebsite+"="+sCookie;
					browser.cookie.set(sWebsite, sCookie);
					return;
			    }
			}
		}
	}
}


VdfRemoteMethodInvocation.prototype.sendCall2 = function(){
    var iParam, oXmlRequest;
    var sXml = new JStringBuilder();
    
    sXml.append("<sWebObject>" + this.sWebObject + "</sWebObject>\n");
    sXml.append("<sSessionKey>" + browser.cookie.get("vdfSessionKey") + "</sSessionKey>\n");
    sXml.append("<sMethodName>" + this.sMethodName + "</sMethodName>\n");
    sXml.append("<asParams>\n");
    
    for(iParam = 0; iParam < this.asParams.length; iParam++){
        sXml.append("<string>" + browser.xml.encode(this.asParams[iParam]) + "</string>\n");
    }
    
    sXml.append("</asParams>\n");
    
    oXmlRequest = new comm.XmlRequest(this.bASynchronous, "CreateSession", "", this.handleCall, this, this.sRequestURL, this.sXmlNS);
    oXmlRequest.sXML = sXml.toString();
    
    oXmlRequest.request();
}
