<!--
//  Read the JavaScript cookies tutorial at:
//  http://www.netspade.com/articles/javascript/cookies.xml

//	Sets a Cookie with the given name and value.
//
//	name       Name of the cookie
//	value      Value of the cookie
//	[expires]  Expiration date of the cookie (default: end of current session)

function setCookie(name, value, expires)
{
    if(typeof(expires) == 'undefined')
    {
        expires = null;
    }
//    else if(expires == false)
//    {
//        expires = new Date();
//        expires.setFullYear(2077);
//    }
    document.cookie= name + '=' + escape(value) +
        ((expires) ? '; expires=' + expires.toGMTString() : '');
}

//	Gets the value of the specified cookie.
//
//	name  Name of the desired cookie.
//	        Returns a string containing value of specified cookie,
//  	    or null if cookie does not exist.

function getCookie(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));
}

function setCookieKeyValue(name, key, value)
{
    var cookieArr;
    var cookieArr = getCookieKeyValue(name);
    if(typeof cookieArr == 'undefined')
    {
        cookieArr = new Object();
    }
    cookieArr[key] = value;
    setCookie(name, JSON.stringify(cookieArr));
}

function getCookieKeyValue(name, key)
{
    var cookieKeyVal = '';
    var cookieVal = getCookie(name);
    if(cookieVal && cookieVal != '')
    {
        var cookieArr = JSON.parse(cookieVal);
        cookieKeyVal = cookieArr[key];
    }
    return cookieKeyVal;
}

function deleteCookie(name)
{
    if (getCookie(name))
    {
        document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT'; //Now().toGMTString()
    }
}

function deleteAllCollapsibleCookies()
{
    deleteCookie('collapsibles');
    deleteCookie('netequity_uriguid');
    deleteCookie('subject_uriguid');
    deleteCookie('preferences_uriguid');
    deleteCookie('emailreport_uriguid');
    deleteCookie('searchcriteria_express');
    deleteCookie('lisresultcompare_uriguid');
    deleteCookie('listingdetails_uriguid');
    deleteCookie('listingresultsstatistics_uriguid');
    deleteCookie('searchcriteria_uriguid');
    deleteCookie('searchresults_uriguid');
}
//-->
