EVERYZING.snippetMod_initLoki = function(){
	/* 
	 * Helper Functions
	 */
	var switchTextHighlights = function(highlight){
	    var marker = jQuery(highlight);
	    var highlightText = jQuery(".wrapper div[@title="+marker.attr("title")+"]", marker.parent().parent());
	    
		marker.unbind("mouseover");
	    marker.siblings('.active-highlight').bind("mouseover", function(){switchTextHighlights(this);});
		
		marker.addClass('active-highlight');
	    marker.siblings('.active-highlight').removeClass('active-highlight');
	    
		highlightText.show();
		highlightText.siblings().hide();
	    highlightText.bind("click", function(){
		      location.href = jQuery(this).find(".spoken-at a").attr("href");
		  });
	}
	
	var getAbsolutePosition = function(relativePosition, timelineLength){
	    return relativePosition * parseInt(timelineLength);
	}
	
	// Calculate length from timestamp;  time format: [hh:][mm]:ss
	var getTimeInSeconds = function(time){
		var timeArray = time.split(":");
		
	    var timeLen = 0;
	    for (var i=0; i<timeArray.length; i+=1){
			timeLen += timeArray[i]* Math.pow(60, timeArray.length-1-i);
		}
		
	    return timeLen;
	}
	
	// @returns relative position in percentage [0..1]
    var getRelativePosition = function(timestamp, duration){ 
        return (getTimeInSeconds(timestamp) / getTimeInSeconds(duration));
    }
    
	
	
	/* 
	 * Initialize The Timelines
	 */
	jQuery(".ez-snippetMod-item .timeline").each(function(){
		var currentTimeline = jQuery(this);
		var timelineBar = jQuery('.timeline-bar', currentTimeline);
		var timelineBarOffsets = timelineBar.position();
		var timeStamps = jQuery('.timeline-marker', currentTimeline);
		var duration = jQuery('.duration', currentTimeline).text();
		
		timeStamps.each(function(){
			var stamp = jQuery(this);
			// Due to the fact that the title of this timestamp may contain text, want to
			// use the last word as the timestamp.
			var timeArray = stamp.attr("title").split(" ");
			var left = getAbsolutePosition(getRelativePosition(timeArray[timeArray.length-1], duration), timelineBar.css("width"))+100;
			stamp.css("left",  left);
			stamp.bind("mouseover", function(){
				switchTextHighlights(this);
			});
		});
		
		switchTextHighlights(timeStamps.slice(0,1));
	});
}
