﻿/* Copyright 2008, 2009 Cox Communications.  No part of this site may be used without explicit permission.  Created by John Hart. */

function bakeCookie(cookieName, cookieValue, daysToExpire) {
    var expiration = '';   
    if (daysToExpire) {
        var expirationDate = new Date();
        expirationDate.setTime(expirationDate.getTime() + (daysToExpire * 86400000));
        expiration = '; expires=' + expirationDate.toGMTString();
   }
   document.cookie = cookieName + '=' + cookieValue + expiration + '; path=/';
}


function nomNomCookie(cookieName) {
    if (document.cookie) {
        var nameToSearch = cookieName + '=';
        var arrayAllCookies = document.cookie.split(';');
        for (var i = 0; i < arrayAllCookies.length; i++) {
            var thisCookie = arrayAllCookies[i];
            while (thisCookie.substring(0,1) == ' ') {
                thisCookie = thisCookie.substring(1, thisCookie.length);
            }
            if (thisCookie.indexOf(nameToSearch) == 0) {
                return thisCookie.substring(nameToSearch.length, thisCookie.length);
            }
        }
    }
    return false;
}

function trashCookie(cookieName) {
    bakeCookie(cookieName, '', -1);
}
