var omniture = {
  initialize: function() {
		//console.log('omniture loaded');
    omniture.initTrackDownload();
    omniture.initPrintPageClick();
  },
  
  initTrackDownload: function() {
	
    jq$("a").live("click",function(){
   
			var isAFile = "false";
			var isExternalLink = "false";
      var trackedDownloadExt = this.href.split(".").pop();
			var href = this.href;
    	var fileName = href.split("/").pop();
        
      if (trackedDownloadExt.match(/(pdf|exe|zip|doc|xls|ppt|mov|mpg|wmv)/)) {
        isAFile = "true";
				if (this.className.match(/external|third party/)) {
					isExternalLink = "true";
				};
      };
			
     	if (isAFile == "true" && isExternalLink == "false") {
						
				omniture.trackDownload(fileName);
					
			};
			         
    });
    
  },

  trackDownload: function(fileName) {
	
    s.linkTrackVars='events,prop11,eVar11,prop15,eVar15';
		s.linkTrackEvents='event7';
		s.prop15=s.eVar15=s.channel+':'+fileName;
		s.events='event7';
		s.tl(this,'d',s.pageName+'|'+fileName);
		s.linkTrackVars='prop35,prop36,prop37,prop38,eVar35,eVar36,eVar37,eVar38';
		s.linkTrackEvents='None';
		
		//alert(s.pageName+'|'+fileName);
            
  },
  
  initPrintPageClick: function() {
  
   $$('a.print-page').each(function(printPage) {
    
      printPage.observe('click', omniture.printPageClick);
    
   });
       
  },
  
  printPageClick: function() {
        
    s.linkTrackVars='events';
    s.linkTrackEvents='event10';
    s.events='event10';
    s.tl(this,'o',s.pageName+'|printpage');
    s.linkTrackVars='prop35,prop36,prop37,prop38,eVar35,eVar36,eVar37,eVar38';
    s.linkTrackEvents='None';

		//console.log(s.pageName+'|printpage');
        
  }, 
  
  emailPage: function() {
        
    s.linkTrackVars='events';
    s.linkTrackEvents='event11';
    s.events='event11';
    s.tl(this,'o',s.pageName+'|emailpage');

		//console.log(s.pageName+'|emailpage');
        
  },
  
  changeFontSize: function(fontSize,fontIndex) {

  /*
    In order for this to function the TextZoom.js file needs to be modified.
    There are three functions within the TextZoom.js file zoomOut, zoomIn and zoomDefault.
    Within each one of these functions you will need to add:
      fontSize = this.LEVELS[this.index];
      fontIndex = this.index;
      omniture.changeFontSize(fontSize,fontIndex); 
  */

      if (fontIndex == 0) {
        whatSize = "small";
      };
      
      if (fontIndex == 1) {
        whatSize = "medium-small";
      };
      
      if (fontIndex == 2) {
        whatSize = "medium-large";
      };
      
      if (fontIndex == 3) {
        whatSize = "large";
      };
      
      doTheTracking();
      
      function doTheTracking(){
                  
        s.linkTrackVars='events,eVar21';
        s.linkTrackEvents='event13';
        s.eVar21=whatSize;
        s.events='event13';
        s.tl(this,'o',s.pageName+'|'+whatSize);
        s.linkTrackVars='prop35,prop36,prop37,prop38,eVar35,eVar36,eVar37,eVar38';
        s.linkTrackEvents='None';
        
        //console.log(s.pageName+'|'+whatSize);
      
      }
          
  }, 
  
  slideDeckClick: function(mediaItemTitle) {
  
    var s=s_gi(s_account);
    s.pageName=globalPageName+'|'+mediaItemTitle;
    s.t();
      
  },
  
  //In both slideDeckStart and slideDeckEnd the slidedeck must have a title value in the json file
  
  slideDeckStart: function(_title) {
    s.linkTrackVars = 'prop17,eVar17,events';
    s.linkTrackEvents = 'event18';
    s.prop17=s.eVar17=s.channel+':'+_title;
    s.events= 'event18';
    s.tl(this,'o',s.pageName+'|'+_title);
    //console.log(this,'o',s.pageName+'|'+_title+'--start');
  },
  
  slideDeckEnd: function(_title) {
    s.linkTrackVars = 'prop17,eVar17,events';
    s.linkTrackEvents = 'event19';
    s.prop17=s.eVar17=s.channel+':'+_title;
    s.events= 'event19';
    s.tl(this,'o',s.pageName+'|'+_title);
    //console.log(this,'o',s.pageName+'|'+_title+'--end');
  } 
  
};

Event.observe(window, 'load', function() {
   omniture.initialize();
});