/*	PROFILE CAROUSEL	*/

	function slideSwitch2() {
		var $active = $('#home-carousel img.active');
		
		if ( $active.length == 0 ) $active = $('#home-carousel img:last');
		
		var $next =  $active.next().length ? $active.next()
			: $('#home-carousel img:first');
		
		$active.addClass('last-active');
		
		$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 2000, function()
		{
			$active.removeClass('active last-active');
		});
	}
	
	$(function() {
		setInterval( "slideSwitch2()", 6000 );
	});

	//Setting the function
	
	function slideSwitch() {
		
		if(!$(".stopRotating").length)
		{
			var $active = $('#inner-home-carousel img.active');
			
			if ( $active.length == 0 ) $active = $('#inner-home-carousel img:last');
			
			var $next =  $active.next().length ? $active.next()
				: $('#inner-home-carousel img:first');
			
			$active.addClass('last-active');
			
			$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 2000, function()
			{
				$active.removeClass('active last-active');
			});
		}
	}
	
	//	Setting the Cookie
	
		$(function()
		{
			setInterval( "slideSwitch()", 6000 );
		});
	
		function createCookie(name,value,days) {
			if (days) {
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		}
		
		
		function readCookie(name)
		{
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++)
			{
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			
			return null;
		}
		
		function eraseCookie(name) {
			createCookie(name,"",-1);
		}
	
	
	

$(document).ready(function(){
	
	/*	PROFILE CAROUSEL	*/
	
	//Carousel Next Button
	
	$("#next-button").click(function(e)
	{
		e.preventDefault();
		
		$("#inner-carousel-buttons").addClass("stopRotating");

			var $active = $('#inner-home-carousel img.active');
			
			if ( $active.length == 0 ) $active = $('#inner-home-carousel img:last');
			
			var $next =  $active.next().length ? $active.next()
				: $('#inner-home-carousel img:first');
			
			$active.addClass('last-active');
			
			$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 0, function()
			{
				$active.removeClass('active last-active');
			});

		$("#play-pause").addClass("paused");

	});
	
	//Carousel Play/Pause Button
	
	$("#play-pause").click(function(e)
	{
		e.preventDefault();
		$("#inner-carousel-buttons").toggleClass("stopRotating");
		$("#play-pause").toggleClass("paused");
	});

	//Info Button
	
	$("#info-button").click(function(e)
	{
		e.preventDefault();
		$("#inner-carousel-buttons").fadeOut();
		$("#profile-info").fadeIn();	
	});
	
	//Close info button
	
	$("#close-button").click(function(e)
	{
		e.preventDefault();
		$("#inner-carousel-buttons").fadeIn();		
		$("#profile-info").fadeOut();
	});
	
	//Carousel back Button
	
	$("#back-button").click(function(e)
	{
		e.preventDefault();
		
		$("#inner-carousel-buttons").addClass("stopRotating");
		
		var $active = $('#inner-home-carousel img.active');
		
		if ( $active.length == 0 ) $active = $('#inner-home-carousel img:last');
		
		var $next =  $active.prev().length ? $active.prev()
			: $('#inner-home-carousel img:first');
		
		$active.addClass('last-active');
		
		$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 0, function()
		{
			$active.removeClass('active last-active');
		});
		
		$("#inner-carousel-buttons").addClass("stopRotating");
	});

	
	/*	Home Page Overlay/Fade ()With Cookie	*/
	
	if(!readCookie('wroteIt')){
		$('#grey-overlay').show();
		$('#grey-overlay img').delay(800).fadeIn(1000);
		$('#grey-overlay').delay(3800).fadeOut(1000);
		createCookie('wroteIt', 'wroteIt', 1);  // 1 days persistence
	}
	
	/*	Drop down Accordion	*/
	
	$("#hotels-button").click(function(e)
	{
		e.preventDefault();
		$('#hotels-dropdown').slideToggle();
		$('#hotels-button').toggleClass("white");			
		$('#spas-button, #residential-button').removeClass("white");
		/*$('#spas-dropdown, #residential-dropdwon').slideUp();*/
	});
		
	$("#spas-button").click(function(e)
	{
		e.preventDefault();
		$('#spas-dropdown').slideToggle();
		$('#spas-button').toggleClass("white");
		$('#hotels-button, #residential-button').removeClass("white");
		/*$('#hotels-dropdown, #residential-dropdwon').slideUp();*/
	});
		
	$("#residential-button").click(function(e)
	{
		e.preventDefault();
		$('#residential-dropdwon').slideToggle();
		$('#residential-button').toggleClass("white");
		$('#hotels-button, #spas-button').removeClass("white");
		/*$('#hotels-dropdown, #spas-dropdown').slideUp();*/
	});
		
	/*	Company Senior Design Team click	*/
	
	$(".team-box").click(function(e)
	{	
		
		if($(this).hasClass("active"))
			{
				e.preventDefault();
				$('.image-box', this).slideToggle();
				$('.team-box-content', this).slideToggle();
				$(this).removeClass("active");
			}
			else
			{
				$('.team-box').removeClass("active");
				e.preventDefault();
				$('.image-box').slideDown();
				$('.team-box-content').slideUp();
				$('.image-box', this).slideToggle();
				$('.team-box-content', this).slideToggle();
				$(this).addClass("active");
			}
		
	});


});	



