$_currentTab = 1;
$_tabCount = 3;
$_tabDelay = 15 * 1000;
$_Waiting = 0;
$_maxTestimonials = 9;
$_LastClick = 0;

function changeTab($newTab,$killInt){
	$currentTime = new Date().getTime();
	if($currentTime > ($_LastClick + $_tabDelay) || $killInt) {
		$('#tabContent'+$_currentTab).fadeOut("slow", function() {
		$('#tabContent'+$newTab).fadeIn("slow");});
		$_currentTab = $newTab;
		for($i=0;$i<=3;$i=$i+1) {
			$('#tab'+$i).css("color","#000");
		}
		$('#tab'+$newTab).css("color","#FFF");
		$_LastClick = $currentTime;
		return true;
	}
}

function autoTab(){
	if($_currentTab < $_tabCount) {
		changeTab($_currentTab+1);
		return true;
	}
	changeTab(1);
	return true;
}

function lastBlogPosts () {
	$("#displayBlogPosts").load("last5posts.php");
}

$(document).ready(function(){
	lastBlogPosts();
	rotateTestimonials();
	$autoBlogs = setInterval ( "lastBlogPosts()", $_tabDelay );
	$autoTestimonials = setInterval ( "rotateTestimonials()", $_tabDelay*0.5 );
	$autoscroll = setInterval ( "autoTab()", $_tabDelay*2 );
});

$currentTestimonial = 5;


function rotateTestimonials() {
	$testimonials = new Array("\"It is mentioned that you have been in business since 1986. I’m quite sure that is close to the time that I first started using Aardvark - many years ago. That was back when you had no signage on your van...\" - J.R.", "\"The phone representative was extremely helpful and my sales representative was very patient and explained everything to me.\" - ID.C.", "\"You saved our holiday weekend by coming on the same day we called. Thank You\" - P.H.", "\"I have used this dealer for all my AC/Heating needs for the past 15 years and have experienced excellent service every time! Relatives whom I have recommended him to have shared the same experience.\" -N.W.", "\"Jeff was SUPER and answered all my stupid questions. Job Well Done Jeff!\" -A. S.", "\"I was treated like a family member in need!\" - G. V.", "\"I just wanted to let you know how pleased I was with your guys. They were very professional and helpful. The job looks very professional and I intend to use you again if I need to...\"  - A. L.", "\"I appreciate everyone’s honesty and communication. Calling me to let me know what is happening.\" - J. P.", "\"We have been burned by several other A/C companies. We feel fortunate to finally find a good one!\" - L. H.");
	$('ul#indexTestimonials li:first').slideUp("slow",function(){
		$('ul#indexTestimonials li:first').remove();
	});
	$('ul#indexTestimonials').append("<li class=\"comment"+$currentTestimonial+"\">"+ $testimonials[$currentTestimonial] + "</li>");
	$(".comment"+$currentTestimonial).hide().fadeIn("slow");
	$currentTestimonial++;
	if($currentTestimonial>=$_maxTestimonials) {
		$currentTestimonial = 0;
	}

}
function clearDefTxt(e) {
	$dT = e.getAttribute('defaultTxt');
	if(e.value == $dT) {e.value = "";e.style.color = "#000";}
	else if(!e.value) {e.value = $dT;e.style.color = "#666";}
	return true;
}
