$(document).ready(function() {
	
	$('#blogbubble').css('display','none');
	
	//AND THE HOMEPAGE SETUP WITH A RANDOM STARTING SLIDE
	var randomStart = $('#homeSlide img').length + 1;
	var randomStarter = (Math.floor(Math.random()*randomStart));
	
	
	$('#homeSlide').nivoSlider({
		effect:'sliceDown', // Specify sets like: 'fold,fade,sliceDown'
        slices: 15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed: 600, // Slide transition speed
        pauseTime: 6000, // How long each slide will show
        startSlide: randomStarter, // Set starting Slide (0 index)
        directionNav: false, // Next & Prev navigation
        directionNavHide: true, // Only show on hover
        controlNav: false, // 1,2,3... navigation
        controlNavThumbs: false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel: false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav: true, // Use left & right arrows
        pauseOnHover: false, // Stop animation while hovering
        manualAdvance: false, // Force manual transitions
        captionOpacity: 0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });								

	
	//alert(randomStarter);
/*	$('#homeSlide').cycle({
		fx: 'turnLeft', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		//prev:'#prev',
		//next: '#next',
		easing:'easeInOutCirc',
		timeout:6000,
		speed:400,
		delay:-1000,
		cleartype:  false,
		before: onBefore,
	    after: onAfter,
		startingSlide:randomStarter
		//pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        //return '#portnav a:eq(' + idx + ')'; 
		//}
	});*/
	
	function onBefore(curr, next, opts) {
		//removes the activve class from all the nav slides
		$('#portnav a').removeClass('active');
	}
	
	function onAfter(curr, next, opts) {
		//This sets the current slide indicator in the header nav to be active based on what slide we're on...
		//alert(opts.currSlide);
		$('#portnav a:eq('+opts.currSlide+')').addClass('active');
	}
	
	$('.homenav').click (function(){
		$('.homenav').removeClass('active');
		$(this).addClass('active');
	});
	
	$('#blog_cycle').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		easing:'easeInOutCirc',
		timeout:6000,
		speed:400,
		sync:0,
		cleartype:  false
	});
	
	//random text for THINK text
	
	var textSelections=new Array("...Of the Possibilities","...Experience","...Customer Service","...Trade Show Programs","...You're Special?","...Creatively","...Rentals","...Green","...ROI","...Cost Containment","...Rebate","...Value","...Asset Management","...More for Less","...Online Programs","...Partnership","...Diversely","...Proactively","...Positively","...Relationship","...Safety","...Event Management","...Technology","...Virtual Reality")
	
	var selectionsLength = textSelections.length + 1;
	//alert(selectionsLength);
	var randomSelection = (Math.floor(Math.random()*selectionsLength));
	//alert (textSelections[randomSelection]);
	var thinkItem = (textSelections[randomSelection]);
	$('#takeaway_text').html(thinkItem);
	
	//blog only shows up on hover
	$('#rich').hover(
		 function () {
    		$('#blogbubble').stop(true, true).fadeIn('slow');
  		 },
  		function () {
            //nothing
  		}				 
	);
	
	$('#blogbubble').hover(
		 function () {
    		$('#blogbubble').stop(true, true).fadeIn('slow');
  		 },
  		function () {
            $('#blogbubble').stop(true, true).fadeOut('slow');
  		}				 
	);


});
