// JavaScript Document

videoTimer = {}
	    videoTimer.startCount = 4357000;
		videoTimer.startTimestamp = Date.parse("Jun 14, 2011");
		videoTimer.msPerVideo = 22541; // based on 3833 videos per day
		
		videoTimer.updateVideos = function() {
			var tsDiff = new Date().getTime() - this.startTimestamp
			
			var videos = parseInt(this.startCount + tsDiff / this.msPerVideo)
			
			// insert number formatting code
			
			$('#video-counter').text( this.formatCounter(videos) );
		};
		
		//
		videoTimer.formatCounter = function(nStr)
		{
			nStr += '';
			x = nStr.split('.');
			x1 = x[0];
			x2 = x.length > 1 ? '.' + x[1] : '';
			var rgx = /(\d+)(\d{3})/;
			while (rgx.test(x1)) {
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
			}
			return x1 + x2;
		}
				
	
		$('document').ready( function() {
			videoTimer.updateVideos();
			setInterval('videoTimer.updateVideos();', 5000)
		})

