/**
* Metrics class
* $Id$
*/

var Metrics = {
/**
* copy the s object over
*/
initialize: function() {
  if (Metrics.s) {
    this.active = true;
  } else if (s) {
    this.s = s;
    this.active = true;
  } else {
    this.s = '';
    this.active = false;
  }
},
TrackCustomLink: function(category,link) {
  this.s.linkTrackVars = "eVar12,events";
  this.s.linkTrackEvents = "event27";
  link = this.distillName(link);

  if(category != "") {
     this.s.eVar12 = category.toLowerCase() + "-" + link.toLowerCase();
  } else {
     this.s.eVar12 = link.toLowerCase();
  }

  this.s.events = "event27";
  this.s.tl(this,'o','gameday_custom_link')
  this.s.linkTrackVars = this.s.linkTrackEvents = this.s.eVar12 = this.s.events = "";
},
TrackVideoStart: function(category,title) {
  category = this.distillName(category);
  title = this.distillName(title);

  this.s.linkTrackVars = "eVar8,events";
  this.s.linkTrackEvents = "event7";

  if(category != "") {
    this.s.eVar8 = category.toLowerCase() + "-" + title.toLowerCase();
  } else {
    this.s.eVar8 = title.toLowerCase();
  }

  this.s.events = "event7";
  this.s.tl(this,'o','video_start')
  this.s.linkTrackVars = this.s.linkTrackEvents = this.s.eVar8 = this.s.events = "";
},
TrackVideoComplete: function(category,title) {
  this.s.linkTrackVars = "eVar8,events";
  this.s.linkTrackEvents = "event23";

  if(category != "") {
    this.s.eVar8 = category.toLowerCase() + "-" + title.toLowerCase();
  } else {
    this.s.eVar8 = title.toLowerCase();
  }

  this.s.events = "event23";
  this.s.tl(this,'o','video_complete')
  this.s.linkTrackVars = this.s.linkTrackEvents = this.s.eVar8 = this.s.events = "";
},
TrackTwitter: function(action_type,twitter_username) {
   this.s.linkTrackVars = "eVar13,events";
   if (typeof(twitter_username) != 'undefined') {
     this.s.eVar13 = twitter_username.toLowerCase();
   }

  if(action_type == "login")  { //track twitter login
    this.s.linkTrackEvents = "event24";
    this.s.events = "event24";
    this.s.tl(this,'o','twitter_login');
    this.TrackEvent('tweet','login');
  } else if(action_type == "tweet")  { //track tweet via page
    this.s.linkTrackEvents = "event25";
    this.s.events = "event25";
    this.s.tl(this,'o','twitter_tweet');
    this.TrackEvent('tweet','send',escape(twitter_username));
  } else if(action_type == "impress") { //track tweet impression
    this.s.linkTrackEvents = "event26";
    this.s.events = "event26";
    this.s.tl(this,'o','twitter_impress');
    this.TrackEvent('tweet','impression',escape(twitter_username));
  }

   s.linkTrackVars = s.linkTrackEvents = s.eVar13 = s.events = "";
},
TrackPage: function(pagename) {
    this.s.pageName = pagename;
    this.s.events = '';
    this.s.t();
},
TrackGooglePage: function(page_url) {
    pageTracker._trackPageview(page_url);
},
TrackEvent: function(category,action,label) {
    if (category && action && label) {
      pageTracker._trackEvent(category,action,label);
    }
    else if (category && action) {
      pageTracker._trackEvent(category,action);
    }
    else {
      pageTracker._trackEvent(category);
    }
},
distillName: function(string) {
  return string.replace(/[^a-zA-Z0-9]/g,'-');
},
zzz: function() { return false;}
};

