/**
 **  Copyright (c) 2008 Snapvine, LLC. All rights reserved.
 **
 ** THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Snapvine, LLC
 **    The copyright notice above does not evidence any
 **    actual or intended publication of such source code.
 **/


/** urchin tracking override
 **/

sv_log_urchin = function() {};
g_urchin_retry_delay = 250; // Retry failed urchin requests after 1/4 second

function safeUrchinTracker(loc, attempt)
{
    attempt = attempt || 1;
    full_loc = loc;

    if(full_loc != "" && full_loc != null)
    {
        if (typeof(analytics_query) != 'undefined')
        {
            if(full_loc.lastIndexOf("?") == -1)
            {
                full_loc = full_loc + "?" + analytics_query;
            }
            else
            {
                full_loc = full_loc + "&" + analytics_query;
            }
        }
    }

    udl = document.location;

    try {
        urchinTracker(full_loc);
        //console.log("urchin success, attempt #" + attempt);
    }
    catch(err) {
      if(attempt < 10) {
        setTimeout(function() {safeUrchinTracker(loc, attempt + 1); }, g_urchin_retry_delay);
        //console.log("urchin retry: " + err);
      }
    };

    sv_log_urchin(loc);
}
