var vid_count = 0;
function alertMsg(){
	vid_count++;
	if(vid_count == 1){
		//$("#div_1").css("display","none").fadeIn('slow');
		document.getElementById("div_1").style.display="none";
		$("#div_2").css("display","block").fadeIn('slow');

	}else{
		document.getElementById("div_2").style.display="none";
		//$("#div_2").css("display","none").fadeIn('slow');
		$("#div_1").css("display","block").fadeIn('slow');
		vid_count = vid_count-2;
	}
	setTimeout("alertMsg()",4000);
}

$(document).ready(function() {
	show_random_testimonial();
	//hide_video_buttons();

	// transitions to the next video button in the list of buttons
	button_switcher = {
		buttons:$('#index_random_video > a.video_link'),
		button_curr:0,
		button_next:1,
		change:function (obj) {
			if (obj.buttons.length <= 1) return;

			// hide button_curr and show button_next
			$(obj.buttons[obj.button_curr]).fadeOut(2000,function () {
				$(obj.buttons[obj.button_next]).show();
				obj.button_curr += 1;
				obj.button_next += 1;

				if (obj.button_curr >= obj.buttons.length) {
					obj.button_curr = 0;
				}
				if (obj.button_next >= obj.buttons.length) {
					obj.button_next = 0;
				}
			});
		}
	};
	setTimeout("alertMsg()",4000);
	//var t = setInterval(button_switcher.change, 8000, button_switcher);
});

// picks a random <p/> element under testimonial_img and shows it.
function show_random_testimonial() {
	var testimonials = $('#testimonial_img > p');
	var rand = Math.floor (Math.random() * testimonials.length);

	// hide all testimonials;
	for (var i = 0; i < testimonials.length; i++) {
		$(testimonials[i]).hide();
	}

	$(testimonials[rand]).show();
}

// hides all video buttons except for the first
function hide_video_buttons() {
	var video_buttons = $('#index_random_video > a.video_link');

	// hide all buttons
	for (var i = 0; i < video_buttons.length; i++) {
		$(video_buttons[i]).hide();
	}

	$(video_buttons[0]).show();
}

// picks a random video_link element under index_random_video and shows it.
function show_random_video_button() {
	var video_buttons = $('#index_random_video > a.video_link');
	var rand = Math.floor (Math.random() * video_buttons.length);

	// hide all buttons
	for (var i = 0; i < video_buttons.length; i++) {
		$(video_buttons[i]).hide();
	}

	$(video_buttons[rand]).show();
}

