(function($) {

	var omniture = {
	  initialize: function() {
			omniture.initTrackDownload();
	    omniture.initPrintPageClick();
	  },
	  
	  initTrackDownload: function() {
		
	    $("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|pptx|pps)/)) {
	        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.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);
	      
	      }
	          
	  }, 
	 
		slideDeckTrack: function(_event,_title) {
			
			var _caption = "";
			
			switch(_event) {
				case ('event18'):
	        _caption = "slidedeck_start"
	        break;
				
				case ('event19'):
	        _caption = "slidedeck_complete"
	        break;
				
	      case ('event20'):
	        _caption = "25%_viewed"
	        break;
	
	      case ('event21'):
	        _caption = "50%_viewed"
	        break;
	
	      case ('event22'):
	         _caption = "75%_viewed"
	        break;
	
				case ('event23'):
	         _caption = "slidedeck_replay"
	        break;
	    }
			
			s.linkTrackVars='events,eVar17,prop17';
			s.linkTrackEvents=_event;
			s.prop17=s.eVar17=_title;
			s.events=_event;
			s.tl(this,'o',s.pageName+'|'+ _title + '|'+_caption);
			s.events='';
			s.linkTrackVars = 'prop35,prop36,prop37,prop38,eVar35,eVar36,eVar37,eVar38';
			s.linkTrackEvents = 'None';
			
		},
		
		trackVideo: function(_event,_title) {
					
			var _caption = "";
			
			switch(_event) {
				case ('event18'):
	        _caption = "video_start"
	        break;
				
				case ('event19'):
	        _caption = "video_complete"
	        break;
				
	      case ('event20'):
	        _caption = "25%_viewed"
	        break;
	
	      case ('event21'):
	        _caption = "50%_viewed"
	        break;
	
	      case ('event22'):
	         _caption = "75%_viewed"
	        break;
	
	      case ('event23'):
	         _caption = "video_replay"
	        break;
	    }
			
			s.linkTrackVars='events,eVar17,prop17';
			s.linkTrackEvents=_event;
			s.prop17=s.eVar17=_title;
			s.events=_event;
			s.tl(this,'o',s.pageName+'|'+ _title + '|'+_caption);
			s.events='';
			s.linkTrackVars = 'prop35,prop36,prop37,prop38,eVar35,eVar36,eVar37,eVar38';
			s.linkTrackEvents = 'None';
			
		}
		
	};
	
	$(window).load(function() {
	   omniture.initialize();
	});

})(jQuery);
