
var bscImages=new Array;
var bscIndex=0;

function bsc_getExpirationDate(cookieName, cookieLifetime)
{
    // specify one of the following: days, hours or minutes

    var UTCstring;

    var expDate       = new Date();
    var nomilli       = Date.parse(expDate);

    var measure = cookieLifetime.charAt((cookieLifetime.length)-1);

    cookieLifetime  = cookieLifetime.slice(0,-1);

    if      (measure=="y")
    {
        expDate.setTime(nomilli+(cookieLifetime*365*24*60*60*1000));
    }
    else if (measure=="d")
    {
        expDate.setTime(nomilli+(cookieLifetime*24*60*60*1000));
    }    
    else if (measure=="h")
    {
        expDate.setTime(nomilli+(cookieLifetime*60*60*1000));
    }
    else if (measure=="m")
    {
        expDate.setTime(nomilli+(cookieLifetime*60*1000));
    }

    var UTCstring     = expDate.toUTCString();

    return UTCstring;
}

function bsc_setCookie (cookieName, cookieValue, expires, path, domain, secure)
{
    // NOTE: expires parm examples are "", "5y", "30d", "8h", "365d", etc.
   
    document.cookie = cookieName + "=" + escape (cookieValue)+
    ((expires == "") ? ""         : ("; expires = " + bsc_getExpirationDate(cookieName, expires))) +
    ((path    == "") ? ""         : ("; path=   "   + path))   +
    ((domain  == "") ? ""         : ("; domain=   " + domain)) +
    ((secure  == "true") ? "; secure" : "");
}

function bsc_getCookieValue(name)
{
    // name - name of the desired cookie
    // * return value of specified cookie or null if cookie does not exist

    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 = dc.indexOf(";", begin);

    if (end == -1)
    {
        end = dc.length;
    }

    return unescape(dc.substring(begin + prefix.length, end));
}

// name     - name of the cookie
// [path]   - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds

function bsc_deleteCookie(name, path, domain)
{
  if (bsc_getCookieValue(name))
  {
    document.cookie = name + "=" +
    ((path)     ? "; path="     + path      : "") +
    ((domain)   ? "; domain="   + domain    : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function bsc_cookieExists(cookieName)
{
    var temp = bsc_getCookieValue(cookieName);

    if (temp == null)
    {
        return false;
    }
    else
    {
        return true;
    }
}

function bsc_getID()
{
    var strId  = "";
    
    strId  = Math.random()+"";
    strId  = strId.slice((strId.length-2)* -1);

    return strId;
}

if (location.hostname.indexOf("taxcut.com")!= -1)
{
    // we are on an taxcut.com hosted page

    // SESSION //
    if (bsc_cookieExists("bsc_sessiontrack"))
    {   
    }
    else
    {
        var newId = bsc_getID();
        bsc_setCookie("bsc_sessiontrack", newId, "", "/", ".taxcut.com", "");
        
        if (document.images)
        {
            try
            {
                bscImages[bscIndex]=new Image;
                bscImages[bscIndex].src="http://www.hrblock.com/trak/beacon?name=bsc_sessiontrack&val="+newId+"&life=session&dom=.hrblock.com";
                bscIndex++;
            }
            catch(err)
            {
              // err would occur if image not returned
              //txt="There was an error on this page.\n\n"
              //txt+="Error description: " + err.description + "\n\n"
              //txt+="Click OK to continue.\n\n"
              //alert(txt)
            }
        }
    }

    // BROWSER //
    if (bsc_cookieExists("bsc_browserid"))
    {            
    }
    else
    {
        var newId = bsc_getID();
        bsc_setCookie("bsc_browserid", newId, "20y", "/", ".taxcut.com", "");
        
        if (document.images)
        {
            try
            {
                bscImages[bscIndex]=new Image;
                bscImages[bscIndex].src="http://www.hrblock.com/trak/beacon?name=bsc_browserid&val="+newId+"&life=20y&dom=.hrblock.com";
                bscIndex++;
            }
            catch(err)
            {
              // err would occur if image not returned
              //txt="There was an error on this page.\n\n"
              //txt+="Error description: " + err.description + "\n\n"
              //txt+="Click OK to continue.\n\n"
              //alert(txt)
            }
        }         
    }
}
else if (location.hostname.indexOf("hrblock.com")!= -1)
{
    // we are on a hrblock.com hosted page

    // SESSION //
    if (bsc_cookieExists("bsc_sessiontrack"))
    {       
    }
    else
    {   
        var newId = bsc_getID();
        bsc_setCookie("bsc_sessiontrack", newId, "", "/", ".hrblock.com", "");
        
        if (document.images)
        {
            try
            {   
                bscImages[bscIndex]=new Image;
                bscImages[bscIndex].src="http://www.taxcut.com/servlet/Beacon?name=bsc_sessiontrack&val="+newId+"&life=session&dom=.taxcut.com";
                bscIndex++;
            }
            catch(err)
            {
              // err would occur if image not returned
              //txt="There was an error on this page.\n\n"
              //txt+="Error description: " + err.description + "\n\n"
              //txt+="Click OK to continue.\n\n"
              //alert(txt)
            }
        }         
    }

    // BROWSER //
    if (bsc_cookieExists("bsc_browserid"))
    {      
    }
    else
    {
        var newId = bsc_getID();
        bsc_setCookie("bsc_browserid", newId, "20y", "/", ".hrblock.com", "");
        
        if (document.images)
        {
            try
            {    
                bscImages[bscIndex]=new Image;
                bscImages[bscIndex].src="http://www.taxcut.com/servlet/Beacon?name=bsc_browserid&val="+newId+"&life=20y&dom=.taxcut.com";
                bscIndex++;
            }
            catch(err)
            {
              // err would occur if image not returned
              //txt="There was an error on this page.\n\n"
              //txt+="Error description: " + err.description + "\n\n"
              //txt+="Click OK to continue.\n\n"
              //alert(txt)
            }
        }           
    }
}