//Global Javascript file for Enlight Biosciences Website

$(document).ready(function(){
	
	//Spam-Proofing of Email Addresses
	if ($('.email').length > 0){
		$.getScript('js/mailto.js',function(){ 
			// Execute this function once the plugin is loaded
			$('.email').mailto();
		});
	}
	//Dynamically clears out any text in the input fields
	if ($('.focus-blur').length > 0){
		$.getScript('js/jquery.valueFx.js',function(){ 
			// Execute this function once the plugin is loaded
			$('.focus-blur').valueFx();
		});
	}
		
	//Show-Hide General
	if ($('a.expand').length > 0){
		
			$('a.expand').click(function(){
			//$('span.bio-full').slideToggle('fast');
			$(this).next().slideToggle('fast');
			if($(this).hasClass('expanded')){
					$(this).removeClass('expanded');
			} else {
					$(this).addClass('expanded');
			}
			return false;
		});
	}

	//Add a class of last to each of the last LI items in ul#team-list
	$('ul#team-list').each(function(){
		$('li:last').addClass('last');
	});

	//Tabs Show-Hide Script for Who We Are Page
	$('a#tab1').click(function(){
		$('#tab-nav a').removeClass('active');
		$(this).addClass('active');
		$('div#tab-2-content, div#tab-3-content, div#tab-4-content').hide();
		$('div#tab-1-content').show();
		return false;
		});
	$('a#tab2').click(function(){
		$('#tab-nav a').removeClass('active');
		$(this).addClass('active');
		$('div#tab-1-content, div#tab-3-content, div#tab-4-content').hide();
		$('#tab-2-content').show();
		$('div.gallery-fullsize', $('body#contact #tab-2-content')).html('<iframe width="380" height="225" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?hl=en&amp;q=500+Boylston+StreetS+Suite+1600+Boston,+MA+02116&amp;ie=UTF8&amp;hq=&amp;hnear=500+Boylston+St,+Boston,+Suffolk,+Massachusetts+02116&amp;gl=us&amp;t=m&amp;vpsrc=6&amp;ll=42.352138,-71.074333&amp;spn=0.014272,0.03253&amp;z=14&amp;output=embed"></iframe>');
		return false;
		});
	$('a#tab3').click(function(){
		$('#tab-nav a').removeClass('active');
		$(this).addClass('active');
		$('div#tab-1-content, div#tab-2-content, div#tab-4-content').hide();
		$('#tab-3-content').show();
		$('div.gallery-fullsize', $('body#contact #tab-3-content')).html('<iframe width="380" height="225" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?msid=211461769759605406140.0004ad4d8486c64afd8c1&amp;msa=0&amp;ie=UTF8&amp;t=m&amp;vpsrc=6&amp;ll=42.350045,-71.075449&amp;spn=0.003568,0.008132&amp;z=16&amp;output=embed"></iframe>');
		return false;
		});
	$('a#tab4').click(function(){
		$('#tab-nav a').removeClass('active');
		$(this).addClass('active');
		$('div#tab-1-content, div#tab-2-content, div#tab-3-content').hide();
		$('#tab-4-content').show();
		return false;
	});
	
	//Tabs Show-Hide Script for Who We Are Page
	$('a.showpic-1').click(function(){
		$(this).parent().find('a').removeClass('active');
		$(this).addClass('active');
		$(this).parent().prev().find('span.picture-2,span.picture-3,span.picture-4').hide();
		$(this).parent().prev().find('span.picture-1').fadeIn(100);
		return false;
		});
	$('a.showpic-2').click(function(){
		$(this).parent().find('a').removeClass('active');
		$(this).addClass('active');
		$(this).parent().prev().find('span.picture-1,span.picture-3,span.picture-4').hide();
		$(this).parent().prev().find('span.picture-2').fadeIn(100);
		return false;
		});
	$('a.showpic-3').click(function(){
		$(this).parent().find('a').removeClass('active');
		$(this).addClass('active');
		$(this).parent().prev().find('span.picture-1,span.picture-2,span.picture-4').hide();
		$(this).parent().prev().find('span.picture-3').fadeIn(100);
		return false;
		});
		
		$('a.showpic-4').click(function(){
		$(this).parent().find('a').removeClass('active');
		$(this).addClass('active');
		$(this).parent().prev().find('span.picture-1,span.picture-2,span.picture-3').hide();
		$(this).parent().prev().find('span.picture-4').fadeIn(100);
		return false;
		});
	

	//Animate Rollovers for Homepage
	$('div',$('#home-columns')).mouseenter(function() {
		rollover = $('span', $(this));
		delay = setTimeout(function() {
			clearTimeout(delay);
			rollover.animate({bottom : '1px'}, 80);
			}, 80);
		})
		.live('mouseleave', function() {
			clearTimeout(delay);
			$('span', $(this)).animate({bottom : '-391px'}, 80);
		})

});//End Document
