$(document).ready(function() {
	
	// Home
	if ($('body').hasClass('home')) {		
		if ($('.features .feature').length > 1) {
			$('.features').each(function(){
				$(this).cycle({
					fx: 'fade',
					timeout:  10000,
					speed:  2500 
				});
			})
		}
	// Projects
	} else if ($('body').hasClass('project-landing') || $('body').hasClass('project-category') || $('body').hasClass('project')) {
		if ($('.banners').length > 0) {
			$('.banners').each(function(){
				if ($(this).find('div.banner').length > 1) {
					$(this).cycle({
						fx: 'fade',
						speed:  2500,
						timeout: 2500,
						pager: '.gallery', 
							pagerAnchorBuilder: function(idx, slide) { 
				 				// return selector string for existing anchor 
								return '.gallery li:eq(' + idx + ') a'; 
							}
					});
				}
			})
		}
	// Everything else
	} else {
		if ($('.banners').length > 0) {
			$('.banners').each(function(){
				if ($(this).find('div.banner').length > 1) {
					$(this).cycle({
						fx: 'fade',
						speed:  2500,
						timeout: 2500
					});
				}
			})
		}
	}
	
	if ($('ul.sub-pages-thumbnails-big-with-children').length > 0) {
		
		$('ul.sub-pages-thumbnails-big-with-children li ul.children').each(function(){
			$(this).css('opacity', 0);
		});
		
		$('ul.sub-pages-thumbnails-big-with-children li').each(function(){
			$(this).bind('mouseenter', function (event) {
				$(this).find('ul.children').animate({
					opacity: 1
					}, 300, function() {
				});
				$(this).find('span.img img').animate({
					opacity: 0.33
					}, 300, function() {
				});
			})
			.bind('mouseleave', function (event) {
				$(this).find('ul.children').animate({
					opacity: 0
					}, 300, function() {
				});
				$(this).find('span.img img').animate({
					opacity: 1
					}, 300, function() {
				});
			});
		});
	}
	
});