// FUNCTIONALITY
$(function(){
	// tooltips
	$("#cloud span").each(function(i){
		$(this).tooltip({
			bodyHandler: function() {
				var rel = $(this).attr('id').split('-');
				var this_item = defs[rel[0]][rel[1]];
				var occurs;
				switch(this_item.count) {
					case 1: 
						occurs = "once";
						break;
					case 2:
						occurs = "twice";
						break;
					default:
						occurs = this_item.count+" times";
				}
				var html = "<h3>"+this_item.term+"</h3>"+
					    "<p>Type: "+ this_item.type +"<br />"+
						"Occurs: "+ occurs +"</p>"+
						"<ul>";
				for(i in this_item.files) {						
					html += "<li>"+ i + ", " + (this_item.files[i].length > 1 ? "lines: " : "line: ") +
							this_item.files[i].join(", ") +"</li>";
				}
				html += "</ul>";
				return html;
			},
			delay: 0,
			track: true
		});
	});
	// navigation
	$("#show_version").click(function(){
		$(this).attr("disabled","disabled");
		window.location.replace(window.location.href.replace(/(\?v=)?([0-9]\.[0-9])?$/m,"?v=") + $("#version").val());
		return false;
	});
});
