/*home slider DESKTOP VERSION*/
	if($('div.container.slideshow .leftcontainer').is(':visible') && $('div.container.slideshow .rightcontainer').is(':visible')){
		////--------------Random BG-----------------//
		function randomFromTo(from, to){
		   return Math.floor(Math.random() * (to - from + 1) + from);
		}
		var number = randomFromTo(1,3);
		$('.container.main').css('background','#666 url(../images/backgrounds/'+ number +'.jpg) no-repeat top center');
		///--------------END random BG------------//
		
		function hideUnderlings(){
			$($currentSlideLeft).siblings().hide();
			$($currentSlideRight).siblings().hide();
		}
		
		
		//globals
		
		//left
		$slideCountLeft = $('.leftcurtain.slide').length;
		$slidesLeft = $('.leftcurtain.slide');
		$currentSlideLeft = $slidesLeft.last();
		
		//origins
		$originOutLeft = {'left':'0%', 'z-index':'100'};
		$originOutRight = {'left':'0%', 'z-index':'100'};
		
		$originInLeft = {'left':'-100%', 'z-index':'100'};
		$originInRight = {'left':'100%', 'z-index':'100'};
		
		//under position
		$underPos = {'left':'0%', 'z-index':'99'};
		
		//right
		$slideCountRight = $('.rightcurtain').length;
		$slidesRight = $('.rightcurtain');
		$currentSlideRight = $slidesRight.last();
		
		hideUnderlings();
		
		
		 $('.control-right').click(function(){
			//helps with highligh issues
			$(this).blur();
			//UPDATE DOTS
			var forward = true;
			dotUpdate(forward);
			delete forward;
			/*-----------------------LEFT AND OUT --------------------*/
			//set current to top
			$($currentSlideLeft).css($originOutLeft);
			
			//grab a temp var of next slide and set to under the current but keep $currentSlideLeft as a global
			$selectUnderlayLeft = $currentSlideLeft.prev();
			if (!$selectUnderlayLeft.length) {
				$selectUnderlayLeft = $slidesLeft.last();
				//set the slide under and show
				$($selectUnderlayLeft).css($underPos);
				$($selectUnderlayLeft).show();
			} else {
				//set the slide under and show
				$($selectUnderlayLeft).css($underPos);
				$($selectUnderlayLeft).show();
			}
			
			
			//animate slide then hide unneeded
			$($currentSlideLeft).stop().animate({left:'-100%'},500, 'easeOutBounce', function(){
				hideUnderlings();
			});
			
			//+1 the global slide
			$currentSlideLeft = $currentSlideLeft.prev();
			if (!$currentSlideLeft.length) {
				$currentSlideLeft = $slidesLeft.last();
			}
			
			/*---------------------RIGHT AND OUT -----------------------*/
			//set current to top
			$($currentSlideRight).css($originOutRight);
			
			//grab a temp var of next slide and set to under the current but keep $currentSlideLeft as a global
			$selectUnderlayRight = $currentSlideRight.prev();
			if (!$selectUnderlayRight.length) {
				$selectUnderlayRight = $slidesRight.last();
				//set the slide under and show
				$($selectUnderlayRight).css($underPos);
				$($selectUnderlayRight).show();
			} else {
				//set the slide under and show
				$($selectUnderlayRight).css($underPos);
				$($selectUnderlayRight).show();
			}
			
			
			
			$($currentSlideRight).stop().animate({left:'100%'},500, 'easeOutBounce', function(){
				hideUnderlings();
			});
			
			$currentSlideRight = $currentSlideRight.prev();
			if (!$currentSlideRight.length) {
				$currentSlideRight = $slidesRight.last();
			}
		});
			
		$('.control-left').click(function(){
			//helps with highligh issues
			$(this).blur();
			//UPDATE DOTS
			var forward = false;
			dotUpdate(forward);
			delete forward;
			/*-----------------------------LEFT AND IN ---------------------*/
			//setup underslide
			$($currentSlideLeft).css($underPos);
			
			//+1 global slide and show
			$currentSlideLeft = $currentSlideLeft.next();
			if (!$currentSlideLeft.length) {
				$currentSlideLeft = $slidesLeft.first();
				//set position and show
				$($currentSlideLeft).css($originInLeft);
				$($currentSlideLeft).show();
			} else {
				//set position and show
				$($currentSlideLeft).css($originInLeft);
				$($currentSlideLeft).show();
			}
			
			//LEFT animate the darn thing (out)
			$($currentSlideLeft).stop().animate({left:'0%'},500, 'easeOutBounce', function(){
				hideUnderlings();
			});
			
			
			/*-----------------------------RIGHT AND IN-----------------------*/
			//setup underslide
			$($currentSlideRight).css($underPos);
			
			//+1 global slide and show
			$currentSlideRight = $currentSlideRight.next();
			if (!$currentSlideRight.length) {
				$currentSlideRight = $slidesRight.first();
				//set position and show
				$($currentSlideRight).css($originInRight);
				$($currentSlideRight).show();
			} else {			
				//set position and show
				$($currentSlideRight).css($originInRight);
				$($currentSlideRight).show();
			}
			
			//RIGHT animate the darn thing (out)
			$($currentSlideRight).stop().animate({left:'0%'},500, 'easeOutBounce', function(){
				hideUnderlings();
			});
		 });
		
		
		$currentDot = 1;
		$maxDots = 5;
		//DOTS TOC
		function dotUpdate(forward){
			$('ul.dots li.active').removeClass('active');
			if (forward == true) {
				//update counter++
				if ($currentDot == $maxDots){
					$currentDot = 1;
				} else {
					$currentDot++;
				}
			} else {
				//update counter--
				if ($currentDot == 1){
					$currentDot = $maxDots;
				} else {
					$currentDot--;
				}
			}
			$('ul.dots li:nth-child('+ $currentDot +')').addClass('active');
		}
		
	} else {
		/*----------------------------MOBILE SLIDES---------------------------------*/
		$('.container.slideshow').css('overflow','hidden');
		$('head').append('<link rel="stylesheet" href="css/flexslider.css")?>" media="screen" />');
		$('head').append('<script src="js/jquery.flexslider-min.js"></script>');
		$('.flexslider').flexslider({
			animation: "slide",
			slideDirection: "horizontal",							
			directionNav: false,
			controlNav: false
		});
	}
	
	/*--------------------------------------------------------RANDOM CLIENT TESTIMONIAL video & COLORBOX -------------------------------------------*/
	if ($('.feature.footer.colorbox').length>0){
		var videoObject = {	
							//nasp
							1:{imgSrc:'nasp.jpg', vidFilename: 'nasp'},
							//hhc
							2:{imgSrc:'hhc.jpg', vidFilename: 'hhc'}
		};
		////--------------Random BG-----------------//
		function randomFromTo(from, to){
		   return Math.floor(Math.random() * (to - from + 1) + from);
		}
		var number = randomFromTo(1,2);
		var selectedVid = videoObject[number];
		///disarm href for js enabled
		$('.feature.footer.colorbox a').attr('href', '#');
		$('.feature.footer.colorbox a img').attr('src', '/images/featured/'+ selectedVid.imgSrc);
		
		var vidHTML = '<video width="720" height="400" autoplay="autoplay" controls="controls" poster="/video/testimonials/'+ selectedVid.vidFilename +'_thumb.png"><source src="video/testimonials/'+ selectedVid.vidFilename +'.mp4" type="video/mp4"><source type="video/webm" src="video/testimonials/'+ selectedVid.vidFilename +'.webm"><source type="video/ogg" src="video/testimonials/'+ selectedVid.vidFilename +'.ogv"><object type="application/x-shockwave-flash" data="/video/videoPlayer.swf" width="720" height="400"><param name="allowfullscreen" value="true"><param name="allowscriptaccess" value="always"><param name="flashvars" value="AutoPlay=yes&VideoThumb=/video/testimonials/'+ selectedVid.vidFilename +'_thumb.png&VideoURL=/video/testimonials/'+ selectedVid.vidFilename +'.flv"><!--[if IE]><param name="movie" value="/video/videoPlayer.swf"><![endif]--></object></video>';
		
		$('.feature.footer.colorbox').colorbox({html: vidHTML, width:'762px', height:'522px'});
	}
