function toggleDisp() {
	for (var i=0;i<arguments.length;i++){
		var d = $(arguments[i]);
		if (d.style.display == 'none')
			d.style.display = 'block';
		else
			d.style.display = 'none';
	}
}
function toggleTab(num,numelems,opennum,animate) {
	if ($('tabContent'+num).style.display == 'none'){
		for (var i=1;i<=numelems;i++){
			if ((opennum == null) || (opennum != i)){
				var temph = 'tabHeader'+i;
				var h = $(temph);
				if (!h){
					var h = $('tabHeaderActive');
					h.id = temph;
				}
				var tempc = 'tabContent'+i;
				var c = $(tempc);
				if(c.style.display != 'none'){
					if (animate || typeof animate == 'undefined'){
						Effect.toggle(tempc,'appear',{duration:0.3, queue:{scope:'menus', limit: 3}});
					}else{
						toggleDisp(tempc);
					}
				}
			}
		}
		var h = $('tabHeader'+num);
		if (h)
			h.id = 'tabHeaderActive';
		h.blur();
		var c = $('tabContent'+num);
		if (animate || typeof animate == 'undefined'){
			Effect.toggle('tabContent'+num,'appear',{duration:0.3, queue:{scope:'menus', position:'end', limit: 3}})
		}else{
			toggleDisp('tabContent'+num);
		}
	}
}                       
function start_slideshow(start_frame, end_frame, delay) {
	setTimeout(switch_slides(start_frame,start_frame,end_frame, delay), delay);
}
function switch_slides(frame, start_frame, end_frame, delay) {
	return (function() {
	if (frame == end_frame) { 
		frame = start_frame;
		}else{ 
		frame = frame + 1; 
		}
	toggleTab(frame,end_frame);	
	id = setTimeout(switch_slides(frame, start_frame, end_frame, delay), 8000);
	})
}
function stop_slideshow() {
	clearTimeout(id);
}
//TODO make this dynamic
function testimonial_animation () {
	new Effect.Appear('testimonial_1', { duration: 2.0 });
	new Effect.Fade('testimonial_1', { duration: 2.0, delay: 8.0 });
	new Effect.Appear('testimonial_2', { duration: 2.0, delay: 10.0 });
	new Effect.Fade('testimonial_2', { duration: 2.0, delay: 21.0 });
	new Effect.Appear('testimonial_3', { duration: 2.0, delay: 23.0 });
	new Effect.Fade('testimonial_3', { duration: 2.0, delay: 28.0, afterFinish: testimonial_animation });
 }