// Urchin Constants
var gUrchinEnabled = true;
var gUrchProdTag = "UA-673624-2";
var gUrchInternalTag = "UA-673624-4";
var gUrchTestTag = "UA-673624-5";
var gUrchLocalTag = "UA-673624-0";
var gCG_debugMode = false;
var gUrchTag = "";

var pageTracker;

if (gUrchinEnabled && typeof (_gat) != "undefined") {
    SetSiteAddress();
    var pageTracker = _gat._getTracker(gUrchTag);
} 


function gaTrack(evt, TrackingCode) {
    var allowTracking;
    if (typeof (evt) == "string") {
        //only TrackingCode is passed as first and only argument
        allowTracking = true;
        TrackingCode = evt;
    }
    else if (typeof (evt) == "undefined") {
        //no parameters passed at all - default GA call
        allowTracking = true;
    }
    else {
        //the fuction is called from Javascript and click event is passed as first parameter
        srcElement = evt.target || window.event.srcElement;
        allowTracking = (
            srcElement.tagName == "IMG" ||
            srcElement.tagName == "A" ||
            (srcElement.tagName == "INPUT" && (srcElement.type.toUpperCase() == "IMAGE" || srcElement.type.toUpperCase() == "BUTTON")))
    }

    if (allowTracking) {
        if (gCG_debugMode) {
            alert("Tracking: " + TrackingCode);
        }
        if (typeof (TrackingCode) != "undefined") {
            pageTracker._trackPageview(TrackingCode);
        }
        else {
            pageTracker._trackPageview();
        }
    }
}




function SetSiteAddress() {
    var host = window.location.hostname.toLowerCase();
    if (host.indexOf("mythings.com") > -1) {
        var dirLen = host.indexOf(".");
        var dir = host.substring(0, dirLen);
        switch (dir) {
            case "www":
                gUrchTag = gUrchProdTag;
                break;
            case "internal":
                gUrchTag = gUrchInternalTag;
                break;
            case "test":
                gUrchTag = gUrchTestTag;
                break;
            default:
                gUrchTag = "";
                gUrchinEnabled = false;
                break;
        }
    }
    else
        if (host == "localhost")
        gUrchTag = gUrchLocalTag;
    else
        gUrchinEnabled = false;
}

function nuconomyHelper() { }
nuconomyHelper.Activity = function() {
    var PageView;
    this.PageView = 1;
};
nuconomyHelper.Activity.PageView = 1;

function nuconomyTrack(activityID, contentType, contentID, contentTitle) {
    //alert("Activity:"+activityID + " ContentType:" + contentType + " ContentID:" + contentID + " ContentTitle:" + contentTitle)
    NUCONOMY.ContentType = contentType; 
    NUCONOMY.ContentTitle = contentTitle;
    NUCONOMY.Logger.LogActivity(__USERID, __CONTENTOWNER, contentID, activityID);
}

