 				window.threeSixtyPlayer.handleClick {target: $('a.sm2_link')[0]}
 
 	getTrackInfo = ->
-		req_time = new Date/1000
 		$.getJSON "http://localhost:8889/status.json", (info) ->
-			#console.log("getTrackInfo")
-			resp_time = new Date/1000
-			# We started the request some time ago, and now it's completed. Assume that
-			# the server did its part of the work mid-way between those two time points,
-			# and assume further that the client clock and server clock tick at the same
-			# rate. This means assuming that there's no mess from clock drift, relativity,
-			# time offset changes (eg DST), or clock changes. If there are, stuff will go
-			# out of sync until the next status query, after which they'll be corrected.
-			window.ping = (resp_time + req_time) / 2 - info.ts
 			tag = 0
 			console.log("req " + req_time + " resp " + resp_time + " ts " + info.ts)
 			for track in info.tracks

				else
					break
	setTimeout getTrackInfo, 1000
	setInterval getTrackInfo, TIMING_INTERVAL

	getTrackDetails = ->
		s = io.connect ":8193/info.websocket"
		s.on 'message', (data) ->
			if typeof data is "string"
				data = JSON.parse(data)
				if data.segment.send_next_track
					#console.log("Send next track!")
					#console.log(Date())
					#console.log(data.segment.prev_track)
					#console.log(data.segment.next_track)
					# Temporarily tagging the artist so we know it came from send_next_track
					document.getElementById('artist').innerHTML = "[snt] " + data.segment.next_track.artist
					document.getElementById('artist_next').innerHTML = "Up next: (unknown)"
					length = data.segment.next_track.length
					minutes = Math.floor(length/60)
					seconds = Math.floor(length%60)
					if seconds < 10
						seconds = "0" + seconds
					document.getElementById('length').innerHTML = minutes + ":" + seconds
					return
				if data.segment.tracks[0].metadata.id != window._track_id
					window._track_id = data.segment.tracks[0].metadata.id
					# TODO Be safe against embedded HTML tags
					document.getElementById('artist').innerHTML = window._next_artist
					window._next_artist = data.segment.tracks[0].metadata.artist
					document.getElementById('artist_next').innerHTML = "Up next: " + window._next_artist
				#console.log("GetTrackDets Data " + window._count_TrackDeets + ": ")
				#console.log(data.segment.tracks[0].metadata.artist)
				#console.log(data.segment.tracks[0].metadata.id)
				window._count_TrackDeets++
			if data.listener_count?
				window._listeners = data.listener_count
		window._socket = s
	
	# setTimeout getTrackDetails, 1000 # Not in use currently
	window._count_getJSON = 1
	if not window._count_TrackDeets?
		window._count_TrackDeets = 1

# Is this needed?
soundManager.setup
	url: '/static/flash/'

$(document).ready ->
	
