﻿var legoGAUtils = {
   
   init : function() {
       
      
        
   },
     GaTagging: function() {
        
                 var vGA_OutgoingTaggedName =   'outgoing-link';        //Define this to control how the tracking will be shown in GA fx. /outgoing-link/ 
				 var vGA_SpotTaggedName     =   'spot';                 //Define this to control how the tracking will be shown in GA fx. /spot-link/ 
				 var vGA_ThisURL            =   window.location.href;   //Gets the current URL 
				 vGA_ThisURL                =   vGA_ThisURL.replace(/[hf]tt?ps?:\/\/[^\/]+\//, ""); //strips URL for domain name
				 
				 //Checks for external links in normal content
				$("#wrapper a[href^='http://']").bind("click", function(){
				    var outgoingLink =  $(this).attr('href');
                    pageTracker._trackPageview('/tagged/'+ vGA_OutgoingTaggedName +'/LINK:'+ outgoingLink +'PAGE:'+vGA_ThisURL+'');
                });

                //Finds all spots and tags them
                $("#wrapper .spot div[class*='href']").bind("click", function(){
                    var spotTitle =  $("h3", this).text();
                    pageTracker._trackPageview('/tagged/'+vGA_SpotTaggedName+'/TITLE:'+spotTitle+'/PAGE:/'+vGA_ThisURL+'');
                });
                
                //Finds all tabular spots and tags them
                $("#wrapper #content #tabularspotcontainer td[class*='href']").bind("click", function(){
                    var spotTitle =  $("h3", this).text();
                    pageTracker._trackPageview('/tagged/'+vGA_SpotTaggedName+'/TITLE:'+spotTitle+'/PAGE:/'+vGA_ThisURL+'');
                });
                
      }
    
};
$(document).ready(function() {
    if($("#siteconsole").length == 0){
     //alert('tacking')
     legoGAUtils.GaTagging();
    }
});