﻿// this variable is used to disable behaviour that won't work in a development / test environment
var isDebugging = false;
// this code is required by google to keep the analytics tracking enabled.  Google interrogates the page for this 
if (!isDebugging) {
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
}

try {
    // this code is essential to establish a 'session' of sorts with google
    if (!isDebugging) {
        var pageTracker = _gat._getTracker("UA-10585663-2");
        pageTracker._setVar(getSilverlightVersion());
        pageTracker._trackPageview();
    }
} catch (err) { }

// This is the core code that tracks events from Silverlight.  Tracking pageviews only is not very meaningful as there is only one page.  
// Using events allows granular tracking of user actions
function trackPageEvent(category, action, label, value) {
    try {
        if (!isDebugging) {
            var pageTracker = _gat._getTracker("UA-10585663-2");
            // there seems to be a bug with _trackEvent, whereby it only works if trackPageview is called immediately prior as can be seen here
            pageTracker._trackPageview();
            pageTracker._trackEvent(category, action, label, value);
        }
    }
    catch (err) { }
}

var userLocation = "AU";
// The silverlight application relies on this method being available and calls it on startup
function getUserLocation() {
    try {
        return userLocation;
    }
    catch (err) { return ""; }
}
