$(document).ready(function() {
	
	var pageUri = window.location;
	
	
	if( pageUri.pathname.indexOf('why-freysmiles') != -1 ){
		// video overlay
		var videolink = $('a[rel]');
		var target = videolink.attr('rel');
		$(target).remove().appendTo('body');
		videolink .overlay({
			mask: {
				color: '#000',
				loadSpeed: 'slow',
				opacity: 0.8,
				zIndex: 10000
			}
		});
		
		// equalizing height of why-freysmile reasons
		$('.reasons li').equalHeights();
		
		// youtube playlist
		$('#playlist').ytplaylist({
			holderId:		'video',
			playerHeight:	300,
			playerWidth:	500,
			addThumbs:		true,
			showRelated:	false,
			autoPlay:		false
		});		
	}
	
	if( pageUri.pathname.indexOf('meet-us') != -1 ){	
				
		// photo swap	
		$('#content').delegate('ul.swap-photos a','click', function(){
			var target = $(this).attr('rel'), $photos = $('#team').find('img.photo');			
			
			$photos.each(function(){
				var $this = $(this), $altPhoto = $this.next().find('li.'+target+' a');			
				
				//if we found this alternate
				if($altPhoto.length > 0){					
					$this.attr('src', $altPhoto.attr('href')).attr('alt', $altPhoto.attr('title'));
				}
				//if not available, use the default
				else{
					$this.attr('src', '/images/p_employee-blank.jpg').attr('alt', 'No photo available');
				}
			});		
			return false;
		});	
	}
	
	if( pageUri.pathname.indexOf('meet-us') || ('locations') != -1 ){
		// team member slider
		$('.member').hover(function(){
			$(".photo", this).stop().animate({top:'-130px'},{queue:false,duration:300});
		}, function() {
			$(".photo", this).stop().animate({top:'0'},{queue:false,duration:300});
		});
	}
});
