function autoPlay(){
    
    var slideNumber = $('#main-slideshow .slide').length;
    $('#slide' + currentSlide).css('z-index', '99');
	    var oldSlide = currentSlide;
	    currentSlide++;
	    if(currentSlide > slideNumber) currentSlide = 1;
	    // change caption
	    $('#slideshow-info-home .main').html($('#slide' + currentSlide + ' img').attr('title'));
	    $('#slide' + currentSlide).css('z-index', '100').stop(true, true).fadeIn('slow', function(){
	        $('#slide' + oldSlide).stop(true, true).fadeOut('fast');
	    });
}

function autoPlayStory(){
    var oldSlide = currentFeatured;
    var featuredNumber = $('#box-featured .box-center div').length;
    
    currentFeatured++;
    if(currentFeatured > featuredNumber) currentFeatured = 1;
    $('#featured-item' + oldSlide).css('display', 'none');
    $('#featured-item' + currentFeatured).css('display', 'block');
}
    
$(document).ready(function() {
    //rotate hero images
    slideInterval = setInterval("autoPlay()", heroInterval);
    
    //rotate stories images
    storyInterval = setInterval("autoPlayStory()", sInterval);
	
	//replace bottom boxes for non flash devices.
	var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	if (!hasRequestedVersion) { 
		$('#box-poll').html('<a href="feedback"><img src="global/img/poll-replace.jpg" alt="Send us your feedback"/></a>');
		$('#box-facts').html('<a href="downloads"><img src="global/img/promo-replace.jpg" alt="Download the full report"/></a>');
	} else {
	    var so = new SWFObject(siteUrl + "/global/flash/CORPCITZ.swf", "box-poll", "238", "273", "10", "#FFFFFF", true);
		so.addParam('wmode', 'transparent');
		so.addParam('menu', 'false');
		so.addParam("scale", "noscale");
		var flashcontent = so.write("box-poll");
	}
});

