TESTIMONIALS_CANVAS_ID = 'animationCanvasTestimonials'
CURRENT_TESTIMONIAL = 0
TESTIMONIAL_CHANGE_IN_SECS = 8 // how many seconds before the testimonials change
TICKER = null

var General = {
	
	jumpTo: function(anchor) {
		document.location.href = '#' + anchor
		new Effect.Highlight(anchor, {duration: 2, startcolor: '#a4dfff', endcolor: '#262a33'})
	},
	
	setCurrentPage: function(page) {
		$('internalLink_' + page).className = "currentPage"
	},
	
	showPassage: function(passageIndex) {
		General.showPartial('passage' + passageIndex)
	},
	
	showPartial: function(partialName, dir) {
		dir = (null == dir) ? "" : dir + '/'
		window.open(dir + '_' + partialName + '.shtml', '_blank', 'width=700,height=500,toolbar=yes,scrollbars=yes')
	},
	
	updateStats: function() {
		if ('function' == typeof(urchinTracker)) {
			// update tmedhurst.me.uk stats
			//_uacct = "UA-1554800-2"
			//urchinTracker()		
			// update barrys stats
			_uacct = "UA-1958620-1"
			urchinTracker()
		}
	},
	
	initAnimatedCanvas: function(canvas) {
		canvas = $(canvas)
		var i = 0
		$A(canvas.childNodes).each(function(element) {
			if (null != element.nodeName && 'DIV' == element.nodeName) {
				element.setAttribute('index', i.toString())
				var displayVal = (element.getAttribute('index') == CURRENT_TESTIMONIAL.toString())? 'block' : 'none'
				element.style.display = displayVal
				++i
			}
		})
		TICKER = new PeriodicalExecuter(General.animatedCanvasTick.bind(this), TESTIMONIAL_CHANGE_IN_SECS)
	},
	
	animatedCanvasTick: function() {
		try
		{
			var oldIndex = CURRENT_TESTIMONIAL
			var newIndex = (null != $('test'+(CURRENT_TESTIMONIAL+1)))? ++CURRENT_TESTIMONIAL : (CURRENT_TESTIMONIAL = 0)
			new Effect.Fade($('test'+oldIndex))
			new Effect.Appear($('test'+newIndex))
		}
		catch(e) {}
	},
	
	queryString: document.location.search.toQueryParams()
}