$(document).ready(function() {

	// Slideshows
	
	    $('#slideshow').cycle({
			fx: 'fade',
		    speed:  1000, 
		    pager:  '.btn-large-container',
		    timeout: 0,
		    pagerAnchorBuilder: function(idx, slide) { 
			        return '.btn-large-container a:eq(' + idx + ')'; // Pager
			}
		});
		
		$('#large-slideshow-slides img').hide();
	
		$('#large-slideshow-slides img:first').fadeIn(850, function() {
		
		    $('#slideshow').cycle({
			    fx:     'scrollHorz', 
			    speed:  1500, 
			    timeout: 4000,
		        prev:    '#slides-prev',
		        next:    '#slides-next',
			    pager:  '#nav-slideshow', 
			    pagerAnchorBuilder: function(idx, slide) { 
			        return '#nav-slideshow li:eq(' + idx + ') a'; // Pager
			    },
			    before: function () {
					$('#slideshow-name').html(this.alt);
					$('#slideshow-title').html(this.title);
					var slideshowlink = $(this).attr("rel");
					$('#slideshow-link').attr("href", slideshowlink);
		        }
			});
		
		});
	
	// Alert
	
		$("#notification").slideDown(400).delay(1500).slideUp(400);
	
	// Clear Form
	
		$('.clear').focus(function() {
			$(this).val("");
		});
		
		$('.clear').blur(function() {
			var clearTitle = $(this).attr("title");
			$(this).val(clearTitle);
		});
	
	// Validation
	
		$("#form").validate({
			rules: {
				email_address: {
					required: true,
					email: true
				},
				phone: {
					required: true,
					digits: true
				}
			}
		});
		
	// Hover (with Intent)
	
		$(".boxes li a").hoverIntent({
				interval: 40,
				over: makeTall, 
				out: makeShort
			});
		
		function makeTall() { $(".box-hover", this).fadeIn(400); }
		function makeShort() { $(".box-hover", this).fadeOut(400); }
	
	// Hover (without Intent)
	
		$(".boxes li a", this).hover(
			function () {
				$(".box-hover", this).fadeIn(400);
			}, function () {
				$(".box-hover", this).fadeOut(400);
		});
		
	// Scroll
	
		$(".scroll").click(function(event){
			event.preventDefault();
			var full_url = this.href;
			var parts = full_url.split("#");
			var trgt = parts[1];
			var target_offset = $("#"+trgt).offset();
			var target_top = target_offset.top;
			$('html, body').animate({scrollTop:target_top}, 900);
		});
	
	// Tooltip
	
      $('a.structure[title]').qtip({
      style: {
      classes: 'ui-tooltip-youtube ui-tooltip-shadow'
   },
   position: {
      my: 'left center',  // Position my top left...
      at: 'right center'
   }
      });	

	// Lightbox

			$(".lightbox").fancybox({
				'overlayColor'		: '#1b052b',
				'overlayOpacity'	: 0.8,
				'titlePosition'		: 'outside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});
	
});


