function SlideBanners() {
	$('.banner_holder .banner.composite').each(function() {
		var active = $(this).find('.inner.active');
		if ($(active).length == 0)
			active = $(this).find('.inner:last');
		
		var next = $(active).next().length ? $(active).next() : $(this).find('.inner:first');
		$(active).removeClass('active');
		$(next).addClass('active');
		/*
		var active = $('.banner_holder .banner.composite .inner.active');
		if ($(active).length == 0)
			active = $('.banner_holder .banner.composite .inner:last');
		var next = $(active).next().length ? $(active).next() : $('.banner_holder .banner.composite .inner:first');
	
		$(active).removeClass('active');
		$(next).addClass('active');
		*/
	});
}

$(function() {
	// prettyPhoto
	$("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'light_rounded',
		overlay_gallery: false,
		allow_resize: false,
		window_padding: 10
	});
	$("a[rel^='prettyText']").prettyPhoto({
		theme: 'text',
		allow_resize: false
	});
	$("a[rel^='prettyForm']").prettyPhoto({
		default_width: 695,
		allow_resize: false,
		theme: 'form'
	});
	
	// External URL
	$('a[rel^="external"]').click(function() {
		window.open($(this).attr('href'));
		return false;
	});
	
	// swip inputs
	$('input.swip, textarea.swip').each(function() {
		if ($(this).val() == '') {
			$(this).val($(this).attr('title'));
			$(this).addClass('swipped');
		}
	});
	$('input.swip, textarea.swip').focus(function() {
		if ($(this).hasClass('swipped')) {
			$(this).val('');
			$(this).removeClass('swipped');
		}
	}).blur(function() {
		if ($(this).val() == '') {
			$(this).val($(this).attr('title'));
			$(this).addClass('swipped');
		}
	});
	$('form.swip').submit(function() {
		var that = this;
		$(this).find('input.swip, textarea.swip').each(function() {
			if ($(this).val() == $(this).attr('title'))
				$(this).val('');
		});
		
		if ($(that).hasClass('search_form')) {
			if ($(that).find('input#search_text').val() == '') {
				$(that).find('input#search_text').val($(that).find('input#search_text').attr('title'));
				return false;
			}
		}
	});
	
	// banners
	$('.banner_holder .banner.composite').each(function() {
		$(this).find('.inner:first').addClass('active');
	});
	
	setInterval('SlideBanners()', 4000);
});
