$(document).ready(function() {
    
    $('.slides').cycle({
   		speed:  1600, 
   		timeout: 9000,
   		pauseOnPagerHover: 'true',
   		pause: 'true',
        pager:  '.slide_nav',
        pagerAnchorBuilder: function(idx, slide) {
	            // return sel string for existing anchor
	            return '.slide_nav li:eq(' + (idx) + ') a';
	        }
    });
    
    $('.sample').cycle({
   		speed:  1600, 
   		timeout: 0,
   		pauseOnPagerHover: 'true',
   		pause: 'true',
        pager:  '.sample_nav',
        pagerAnchorBuilder: function(idx, slide) {
	            // return sel string for existing anchor
	            return '.sample_nav li:eq(' + (idx) + ') a';
	        }
    });
    
	 $('.april_animate').cycle({		
	        speed:  5000,
	        timeout: 1000,
	        pager:  '.carousel_buttons',
	        pagerAnchorBuilder: function(idx, slide) {
	            // return sel string for existing anchor
	            return '.carousel_buttons li:eq(' + (idx) + ') a';
	        }
	
		});		
    
    $.fn.UItoTop = function(options) {

 		var defaults = {
			text: 'To Top',
			min: 200,
			inDelay:600,
			outDelay:400,
  			containerID: 'toTop',
			containerHoverID: 'toTopHover',
			scrollSpeed: 1200,
			easingType: 'linear'
 		};

 		var settings = $.extend(defaults, options);
		var containerIDhash = '#' + settings.containerID;
		var containerHoverIDHash = '#'+settings.containerHoverID;
		
		$('body').append('<a href="#" id="'+settings.containerID+'">'+settings.text+'</a>');
		$(containerIDhash).hide().click(function(){
			$('html, body').animate({scrollTop:0}, settings.scrollSpeed, settings.easingType);
			$('#'+settings.containerHoverID, this).stop().animate({'opacity': 0 }, settings.inDelay, settings.easingType);
			return false;
		})
		.prepend('<span id="'+settings.containerHoverID+'"></span>')
		.hover(function() {
				$(containerHoverIDHash, this).stop().animate({
					'opacity': 1
				}, 600, 'linear');
			}, function() { 
				$(containerHoverIDHash, this).stop().animate({
					'opacity': 0
				}, 700, 'linear');
			});
					
		$(window).scroll(function() {
			var sd = $(window).scrollTop();
			if(typeof document.body.style.maxHeight === "undefined") {
				$(containerIDhash).css({
					'position': 'absolute',
					'top': $(window).scrollTop() + $(window).height() - 50
				});
			}
			if ( sd > settings.min ) 
				$(containerIDhash).fadeIn(settings.inDelay);
			else 
				$(containerIDhash).fadeOut(settings.Outdelay);
		});

};
    
    if($("#name").length) {
		if($("#name").val() == '') {
			$("#name").val('name');
		}
		$("#name").focus(function(){
			if (this.value == 'name') {
				this.value='';
			}
		});
		
		$("#name").blur(function(){
			if (this.value == '') {
				this.value='name';
			}
		});

	}
	
	if($("#email").length) {
		if($("#email").val() == '') {
			$("#email").val('email');
		}
		$("#email").focus(function(){
			if (this.value == 'email') {
				this.value='';
			}
		});
		
		$("#email").blur(function(){
			if (this.value == '') {
				this.value='email';
			}
		});

	}
	
	if($("#comments").length) {
		if($("#comments").val() == '') {
			$("#comments").val('question/comments');
		}
		$("#comments").focus(function(){
			if (this.value == 'question/comments') {
				this.value='';
			}
		});
		
		$("#comments").blur(function(){
			if (this.value == '') {
				this.value='question/comments';
			}
		});
	}
	
	if($("#comments_name").length) {
		if($("#comments_name").val() == '') {
			$("#comments_name").val('name');
		}
		$("#comments_name").focus(function(){
			if (this.value == 'name') {
				this.value='';
			}
		});
		
		$("#comments_name").blur(function(){
			if (this.value == '') {
				this.value='name';
			}
		});

	}
	
	if($("#comments_email").length) {
		if($("#comments_email").val() == '') {
			$("#comments_email").val('email');
		}
		$("#comments_email").focus(function(){
			if (this.value == 'email') {
				this.value='';
			}
		});
		
		$("#comments_email").blur(function(){
			if (this.value == '') {
				this.value='email';
			}
		});

	}
    
             $('.slide-out-div').tabSlideOut({
                 tabHandle: '.handle',                              //class of the element that will be your tab
                 tabLocation: 'top',                               //side of screen where tab lives, top, right, bottom, or left
                 speed: 500,										 //speed of animation
                 action: 'click',                                   //options: 'click' or 'hover', action to trigger animation
                 fixedPosition: false                               //options: true makes it stick(fixed position) on scroll
             });
             
$(document).ready(function() {
			/*
			var defaults = {
	  			containerID: 'moccaUItoTop', // fading element id
				containerHoverClass: 'moccaUIhover', // fading element hover class
				scrollSpeed: 1200,
				easingType: 'linear' 
	 		};
			*/
			
			$().UItoTop({ easingType: 'easeOutQuart' });
			
		});
    		    
})(jQuery);





