/*** cookie functions ***/
function createCookie(name,value,days) 
{
    if(value==null || value == "undefined")
        value = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = ""; // expire cookie on browser close
    document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) 
{
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
function eraseCookie(name) 
{
    createCookie(name,"",-1);
}

function getCookieKeyValueList(input, regex)
{
    var list = new Array();

    if(input == null || input == undefined || input.length == 0)
        return list;
        
    var s = input;
    var index = 0;
    var bContinue = true;
    while(bContinue) {
        var s = s.substring(index, s.length);
        var myregexp = regex;
        var match = myregexp.exec(s);
        if (match != null) {
            index = match.index+match[0].length;
            var key = decodeURIComponent(match[1]);
            var value = match[2];
            list[key]=value;
        } 
        else {
            bContinue = false;
        }
    }

    return list;
}
function getCookieList()
{
    return getCookieKeyValueList(document.cookie, /\s*([^;]*?)=([^;]*)/);
}
function getUtmZList(strUtmZ)
{
    return getCookieKeyValueList(strUtmZ, /\s*([^|.]*?)=([^|]*)/);
}
function getSubCookieList(strSubCookie)
{
    return getCookieKeyValueList(strSubCookie, /\s*([^&]*?)=([^&]*)/);
}