if ($('.gallery').length > 0) {
	function slideSwitch() {
		var $active = $('.gallery img.active');
	
		if ( $active.length == 0 ) $active = $('.gallery img:last');
	
		var $next =  $active.next().length ? $active.next()
			: $('.gallery img:first');
	
		$active.addClass('last-active');
	
		$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
				$active.removeClass('active last-active');
			});
	}
	
	$(function() {
		setInterval( "slideSwitch()", 5000 );
	});

}

$(document).ready(function(){
	
	// Form element focus styles
	$('textarea').focus(function(){
		$(this).parent().parent().removeClass('idle').addClass('focus');
	});
	$('select').focus(function(){
		$(this).removeClass('idle').addClass('focus');
	});
	$('input[type="text"]').focus(function(){
		$(this).parent().parent().removeClass('idle').addClass('focus');
	});
	$('input[type="password"]').focus(function(){
		$(this).parent().parent().removeClass('idle').addClass('focus');
	});
	
	// Form element blur styles
	$('textarea').blur(function(){
		$(this).parent().parent().removeClass('focus').addClass('idle');
		if ($.trim(this.value == '')){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	$('select').blur(function(){
		$(this).removeClass('focus').addClass('idle');
	});
	$('input[type="text"]').blur(function(){
		$(this).parent().parent().removeClass('focus').addClass('idle');
		if ($.trim(this.value == '')){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	$('input[type="password"]').blur(function(){
		$(this).parent().parent().removeClass('focus').addClass('idle');
		if ($.trim(this.value == '')){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});

});
