﻿$(document).ready(function(){

  	var timer = setInterval( showDiv, 5000); // Speed of animation
  	var quoteTimer = setInterval( rotateQuotes, 5000); // Speed of animation

	var pause = 0;

	$('.headChild').hide(); 

	$('.head').toggle(function(){
		$(this).addClass('active');
		pause = 1;
		}, function () {
		$(this).removeClass('active');
		pause = 1;
	});

	$('.head').click(function(){
		$(this).next('.headChild').slideToggle('slow');
	});

	var counter = 0;

 	function showDiv() {
		if (!pause && $('div').hasClass('contItem')) {
			$('.head').removeClass('active');
			$('.headChild').hide("slow");
			$('.head').removeClass('active')
			.filter(function (index) { return index == counter % $('.head').size(); })
			.addClass('active');

			$('.headChild').hide("slow")
			.filter(function (index) { return index == counter % $('.head').size(); })
			.slideToggle('slow');

			counter == $('.head').size() ? counter = 0 : counter++; 
		}
  	};

	var quoteCounter = 0;
	$('.quote').hide();
	rotateQuotes();
 	function rotateQuotes() {
		$('.quote').fadeOut("slow")
		.hide()
		.filter(function (index) { return index == quoteCounter % $('.quote').size(); })
		.fadeIn('slow');

		quoteCounter == $('.quote').size() ? quoteCounter = 0 : quoteCounter++; 
  	};
	


});



