$(document).ready(function() {
	
		var homepageText = ["California Indoor Comfort is your source for residential and commercial air conditioning needs.",
							"We offer a wide range of services which include: planned maintenance, repair, duct & dryer vent cleaning, installation, utility incentives & rebates...",
							"Call today and see how we can help you <br/><span>&bull;&nbsp;</span><a href='http://calindoorcomfort.com//schedule-request.html'>Schedule an Appointment</a>"
							];
	
	
	
	var slides = $("#slides li");
	var textHolder = $("#text-holder");
	var textBox = $("#text-holder p")
	var currentSlide = 0;
	var nextSlide = currentSlide + 1;
	
	
	var slideWidth = $("#main-slideshow").width();
	var textOutPos = slideWidth + textHolder.width();
	textHolder.css({ 'left' : textOutPos})

	shadowBox();
	
		function swapSlide() {
		
		if (currentSlide == (slides.length-1)) {
			
					
					$(slides[slides.length-1]).fadeOut();
					$(slides[0]).fadeIn();
					currentSlide = 0;
					nextSlide = currentSlide + 1
					shadowBox();
				
		
		} else {  
			
			
				$(slides[currentSlide]).fadeOut();
				$(slides[nextSlide]).fadeIn();
				currentSlide++;
				nextSlide = currentSlide + 1
				shadowBox();
			
			
		}
		
		
	
		
		}
	
	function shadowBox() {
		
		textBox.html(homepageText[currentSlide]);
		textHolder.delay(800).animate({'left' : '574px'}, 800).delay(5000).animate({'left' : textOutPos}, 800);
		textBox.delay(1500).fadeIn(1000).delay(3000).fadeOut(1000);
		setTimeout(function startTimer() {
			swapSlide();
		}, 7500)
	}
	

	

	
});


