jQuery( document ).ready( function () {
	jQuery( '#scroll-up' ).hide();
	jQuery( function () {
		jQuery( window ).scroll( function () {
			if ( jQuery( this ).scrollTop() > 1000 ) {
				jQuery( '#scroll-up').fadeIn();
			} else {
				jQuery( '#scroll-up' ).fadeOut();
			}
		});
		jQuery( 'a#scroll-up' ).click( function () {
			jQuery( 'body, html' ).animate({
				scrollTop: 0
			}, 800 );
			return false;
		});
	});

	/**
	 * Responsive menu with toggle
	 */
	 jQuery('.better-responsive-menu .menu-primary-container .menu-item-has-children').
	 append('<span class="sub-toggle"> <span class="fa fa-caret-right"></span> </span>');

	 jQuery('.better-responsive-menu .menu-primary-container .sub-toggle').click(function() {
		jQuery(this).parent('.menu-item-has-children').children('ul.sub-menu').first().slideToggle('1000');
		jQuery(this).children('.sub-toggle .fa').first().toggleClass('fa-caret-down fa-caret-right');
	});
});

/**
 * Slider Setting
 *
 * Contains all the slider settings for the featured post/page slider.
 */
jQuery(window).on('load',function() {
	if ( typeof jQuery.fn.cycle !== 'undefined' ) {
		jQuery( '.slider-cycle' ).cycle( {
			fx               : 'fade',
			timeout          : 4000,
			speed            : 1000,
			slides           : '> div',
			pager            : '> #controllers',
			pagerActiveClass : 'active',
			pagerTemplate    : '<a></a>',
			pauseOnHover     : true,
			autoHeight       : 'container',
			swipe            : true,
			swipeFx          : 'scrollHorz',
			log              : false
		} );
	}
});

