// JavaScript Document
$(document).ready(function(){
	
	//console.log("The document is ready.");
	
	var slideShowTimer = setInterval(function() {
		setShowNumber();
	}, 3600);
	
	var slideShowNumber = 1;
	
	function setShowNumber() {	
		slideShowNumber = slideShowNumber + 1;
		if (slideShowNumber == 4) {
			slideShowNumber = 1;
		}
		changeSlide(slideShowNumber);
		
	}
	
	function changeSlide(pointInShow) {
	
		if (pointInShow == 1) {
			//console.log("Next Slide: " + slideShowNumber);
			setSlideShow("humanResources");
			setButtonState("#humanResources");
		} else if (pointInShow == 2) {
			//console.log("Next Slide: " + slideShowNumber);
			setSlideShow("office");
			setButtonState("#office");
		} else if (pointInShow == 3){
			//console.log("Next Slide: " + slideShowNumber);
			setSlideShow("management");
			setButtonState("#management");
		}
		
	}
	
	//CREATES ACTIVE SLIDE VARIABLE TO USE LATER
	var activeSlideTitle;
	
	
	//NEXT THREE LINES SET FIRST SLIDE ITEMS
	//$("#mainFrameImage").css("background-image", "url(images/assets/mainFrameImage1.jpg)");
	$("#slideShowList li:nth-child(1)").attr("class", "firstActive");
	$("#mainFrameBottom").append("<p>Supplying your workforce with highly proficient organizational development and employee relations specialists</p>");
	
	//FUNCTION FOR CLICKING ON LIST ITEMS
	$("#slideShowList > li").click(function() {
		
		clearInterval(slideShowTimer);
		
		//console.log("CLICK!");
		//console.log($(this).attr("id"));
		//console.log("Active Slide Title: " + activeSlideTitle);
		activeSlideTitle = $(this).attr("id");
		$(this).siblings().removeAttr("class");
	
		if (activeSlideTitle == "humanResources") {
			//console.log("First!");
			$(this).attr("class", "firstActive");
		} else {
			//console.log("Not First!");
			$(this).attr("class", "active");
			$("#slideShowList li:nth-child(1)").attr("class", "first");
		}
		
		setSlideShow(activeSlideTitle);
		
	});
	
	function setButtonState(activeButton) {
		//console.log("This is the function setButtonState() speaking.");	
		
		$(activeButton).siblings().removeAttr("class");
	
		if (activeButton == "#humanResources") {
			//console.log("First!");
			$(activeButton).attr("class", "firstActive");
		} else {
			//console.log("Not First!");
			$(activeButton).attr("class", "active");
			$("#slideShowList li:nth-child(1)").attr("class", "first");
		}
		
	}
	
	function setSlideShow(slideToSet) {
		
		//console.log("This is the function setSlideShow() speaking.");
		
		if (slideToSet == "humanResources") {
			//$("#mainFrameImage").css("background-image", "url(images/assets/mainFrameImage1.jpg)");
			$("#mainFrameImage img:first-child").fadeTo(1200,1);
			$("#mainFrameImage img:nth-child(2)").fadeTo(1200,0);
			$("#mainFrameImage img:nth-child(3)").fadeTo(1200,0);
			$("#mainFrameBottom").empty();
			$("#mainFrameBottom").append("<p>Supplying your workforce with highly proficient organizational development and employee relations specialists</p>");
		} else if (slideToSet == "office") {
			//$("#mainFrameImage").css("background-image", "url(images/assets/mainFrameImage2_2.jpg)");
			$("#mainFrameImage img:first-child").fadeTo(1200,0);
			$("#mainFrameImage img:nth-child(2)").fadeTo(1200,1);
			$("#mainFrameImage img:nth-child(3)").fadeTo(1200,0);
			$("#mainFrameBottom").empty();
			$("#mainFrameBottom").append("<p>Bringing skilled professionals that streamline efficiency and effectively enhance daily office performance</p>");
		} else {
			//$("#mainFrameImage").css("background-image", "url(images/assets/mainFrameImage3.jpg)");
			$("#mainFrameImage img:first-child").fadeTo(1200,0);
			$("#mainFrameImage img:nth-child(2)").fadeTo(1200,0);
			$("#mainFrameImage img:nth-child(3)").fadeTo(1200,1);
			$("#mainFrameBottom").empty();
			$("#mainFrameBottom").append("<p>Providing top-tier executive leadership talent to dynamically spearhead the future of growing companies</p>");
		}
		
		
	}
	
	///////////////////////////
	//FORM ALERT
	//////////////////////////
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
});
