// Some JQuery to enhance the theme

var $j = jQuery.noConflict();

$j(document).ready(function() {
	
	$j('.nav>ul').after($j('<div class="clear"></div>'));
	
	$j('.widget_nav_menu>div>ul').after($j('<div class="clear"></div>'));
	
	$j('ul>li:first-child').addClass('first');
	
	$j('ul>li:last-child').addClass('last');
	
	$j('ul>li:last-child').addClass('last');

	$j('#footer div:first-child').addClass('first');
	
	$j('.half-column:last').addClass('last');
	
	$j('.half-column.last').after($j('<div class="clear"></div>'));
	
	$j('.third-column:last').addClass('last');
	
	$j('.third-column.last').after($j('<div class="clear"></div>'));
		
	$j('#banner-title').fadeIn(1000);
	
	$j('#property-thumbs-1').jcarousel({
		animation: 1200,
        wrap: 'circular'
    });
	
	$j('#property-thumbs-2').jcarousel({
		animation: 1200,
        wrap: 'circular'
    });
	
	$j('#property-thumbs-3').jcarousel({
		animation: 1200,
        wrap: 'circular'
    });
	
	$j('#property-thumbs-4').jcarousel({
		animation: 1200,
        wrap: 'circular'
    });
	
	$j('#property-thumbs-5').jcarousel({
		animation: 1200,
        wrap: 'circular'
    });
	
	$j('#property-thumbs-6').jcarousel({
		animation: 1200,
        wrap: 'circular'
    });
		
	$j('#meteor-buttonscommunity-gallery').each(function (i) {
	
		$j(this).html($j(this).html().replace('<!-- start .meteor-thumbs -->','<div class="meteor-thumbs">'));

	});
	
	$j('#meteor-buttonscommunity-gallery').each(function (i) {
	
		$j(this).html($j(this).html().replace('<!-- .meteor-thumb-3 -->','<!-- .meteor-thumb-3 --></div><div class="meteor-thumbs">'));

	});
	
	$j('#meteor-buttonscommunity-gallery').each(function (i) {
	
		$j(this).html($j(this).html().replace('<!-- end .meteor-thumbs -->','</div>'));

	});
	
    $j('#community-gallery').cycle({
	
		height: 460,
		width: 899,
		fit: 1,
		fx: 'fade',
		speed: 2000,
		timeout: 8000,
		pause: 1,
		pager: '#meteor-buttonscommunity-gallery',
		pagerEvent: 'click',
		cleartypeNoBg: 'true',
		slideExpr: '.mslide',
		pagerAnchorBuilder: function(idx, slide) { 
		
			return '#meteor-buttonscommunity-gallery .meteor-thumb:eq(' + idx + ') a'; 
			
		} 
		
	});
	
	$j('#meteor-buttonscommunity-gallery').cycle({
	
		height: 460,
		width: 296,
		fit: 1,
		fx: 'scrollVert',
		speed: 2000,
		timeout: 0,
		pause: 1,
		prev: '#meteor-prevcommunity-gallery',
		next: '#meteor-nextcommunity-gallery',
		pagerEvent: 'click',
		cleartypeNoBg: 'true',
		slideExpr: '.meteor-thumbs'
		
	});
	
	$j('.page-template-page_community-php .third-column ul').after($j('<a href="#" class="button">More</a>'));
	
    $j('.page-template-page_community-php .button').toggle(function () {
		$j(this).parent().addClass('open');
    }, function () {
		$j(this).parent().removeClass('open');
    });

});
