﻿// top banner
var homeTopBanner = {
	startIndex: Object,
	init: function() {
		this.startIndex = Math.ceil(Math.random() * $("#homePageBannerRotator div.Banner").size());

		$("#homePageBannerRotator").cycle({
			cleartype:false,
			fx: 'fade',
			speed: 'slow',
			startingSlide: homeTopBanner.startIndex,
			timeout: 10000,
			pager: '#bannerRotatorPager',
			pagerAnchorBuilder: function(idx, slide) {
				return '<li><a href="#">' + slide.title + '</a></li>';
			}
		});
	}
}

// content block rotator
var homeContentBlockRotator = {
	startIndex: Object,
	init: function() {
		this.startIndex = Math.ceil(Math.random() * $("#homePageContentBlockRotator div.HomePageContentBlock").size());
		
		$("#homePageContentBlockRotator").cycle({
			cleartype: false,
			fx: 'fade',
			speed: 'slow',
			startingSlide: homeContentBlockRotator.startIndex,
			timeout: 0,
			pager: '#homePageContentBlockPager',
			pagerAnchorBuilder: function(idx, slide) {
				return '<li><a href="#">' + idx + '</a></li>';
			}
		});
	}
}

function initializeHome() {
	homeTopBanner.init();
	homeContentBlockRotator.init();
}

$(function() {
	initializeHome();
});