
$(document).ready(function() { 
    
	WebFont.load({
		custom: {
			families: [
				'News Gothic Condensed',/*fontslive*/
				'Proxima Nova Semibold', 'Proxima Nova Condensed Semibold', 'Proxima Nova Thin'/*fontdeck*/
			],
			urls: [
			'http://webfonts.fontslive.com/css/58fee642-674e-4de9-9b5b-a185bf590737.css',
			'http://f.fontdeck.com/s/css/kWYKRc4MzVAUQfilQ9P0BWiOJ8E/wcm-ct-1-preview.stern.nyu.edu/8173.css',
			'http://f.fontdeck.com/s/css/kWYKRc4MzVAUQfilQ9P0BWiOJ8E/www-preview.stern.nyu.edu/8173.css',
			'http://f.fontdeck.com/s/css/kWYKRc4MzVAUQfilQ9P0BWiOJ8E/www.stern.nyu.edu/8173.css',
			'http://f.fontdeck.com/s/css/kWYKRc4MzVAUQfilQ9P0BWiOJ8E/stern.nyu.edu/8173.css',
			'http://f.fontdeck.com/s/css/kWYKRc4MzVAUQfilQ9P0BWiOJ8E/localhost/8173.css'
			]
		}
	});
	
	// detect support for position:fixed
	$.support.positionFixed = (function(){ 
		var container = document.body;
		var el = document.createElement('div');	
		if (!el.getBoundingClientRect) { return null; }
		el.innerHTML = 'x';
		el.style.cssText = 'position:fixed;top:100px;';
		container.appendChild(el);	
		var originalHeight = container.style.height,
		originalScrollTop = container.scrollTop;	
		container.style.height = '3000px';
		container.scrollTop = 500;	
		var elementTop = el.getBoundingClientRect().top;
		container.style.height = originalHeight;	
		support = (elementTop === 100);
		container.removeChild(el);
		container.scrollTop = originalScrollTop;
		return support;
	})();
	
	// detection is returning false negative in ie7	
	if (!$.support.positionFixed && !($.browser.msie && $.browser.version === '7.0')) {
		$('html').addClass('no-positionfixed');
	}
    

	// detect touch screen
	$.support.touchEvents = (function(){ 		
		return ('ontouchstart' in window);		
	})();	
		
	if ($.support.touchEvents) {
		$('html').addClass('touch');
	}
		
	
	
	$.fn.doOnce = function(func){ 
	    this.length && func.apply(this); 
	    return this; 
	}

	// placeholder fix for non-supporting browsers
	$('input[placeholder]').doOnce(function(){
		this.placeholder();
	});
		
	// main nav
	$('#nav-main > ul').doOnce(function(){
		this.mainNav();
	});
	
	// footer (except home page)
	$('#pagewrapper:not(.home-page) #footer-global').doOnce(function(){
		this.footerDisplay();
	});
	
	// home page footer on touch screens
	if ($.support.touchEvents) {
		$('#pagewrapper.home-page #footer-global').doOnce(function(){
			this.footerDisplay();
		});
	}
	
	// "mega-menu"
	$('#nav-section').doOnce(function(){
		this.navSection();
	});
	
	// share/print menu
	$('#utilities-menu').doOnce(function(){
		this.hoverSlide();
	});

	// video lightbox
	$('#contentwrapper').find('a[href*="/media/video/"]').doOnce(function(){
		this.videoModal();
	});

	// back to top link
	$('#backtotop').doOnce(function(){
		this.backToTop();
	});
	
	// floating elements
	$('#pagewrapper:not(.global-page) #side-nav').doOnce(function(){
		this.floatingEl();
	});
	$('.article-col-side #page-nav').doOnce(function(){
		this.floatingEl();
	});
	$('#filter').doOnce(function(){
		this.floatingEl();
	});
	
		
	// carousels
	$('#program-highlights').find('div.section-wrap').doOnce(function(){
		this.carousel();
	});
	$('#program-highlights.alternate').doOnce(function(){
		this.carouselExpand({
			container : 'div.section-wrap'
		});
	});	
	
	// random image
	$('#slides.random').doOnce(function(){
		this.randomImg();
	});
	
	// smooth scolling
	$('#page-nav').find('a').doOnce(function(){
		this.smoothScroll();
	});

	// programs admissions page
	$('#programs-list').find('div.title > a').doOnce(function(){
		this.appendHtml();
	});	
	$('#programs-list').doOnce(function(){
		this.hideShow({
			container : 'li.program',
			target_el : 'div.preview',
			toggle_el : 'div.title > a'
		 });
	});
			
	// faculty directory
	$('#faculty-search-by').doOnce(function(){
		this.tabs({
			external : true
		 });
	});
	$('#expertise-list').doOnce(function(){
		this.nestedListDisplay();
	});	
	$('#faculty-directory').find('div.pagination').doOnce(function(){
		this.directoryPager();
	});
	$('#faculty-directory').find('div.alpha-list').doOnce(function(){
		this.directoryAlpha();
	}); 
	
	// dept. landing page
	$('#dept-splash').doOnce(function(){
		this.randomImg({
			item : 'div.figure'
		});
	});
	$('#message-letter').doOnce(function(){
		this.expandText({
			target_el : '#dept-splash'
		 });
	});
	
	// tabs
	$('#tabbed-block').doOnce(function(){
		this.tabs();
	});
		
	// stripe tables
	if($.browser.msie && $.browser.version<="8.0") {
		$('#col-main .table-style-a table').doOnce(function(){
			this.stripeTables();
		});
		$('#col-main .table-style-c table').doOnce(function(){
			this.stripeTables();
		});
	}
	
});

// ------------------------------------------------------------------------ /	

// window.onload funcitons
$(window).load(function() {
	
	// home page footer (except touch screens)
	if (!$.support.touchEvents) {
		$('#pagewrapper.home-page #footer-global').doOnce(function(){
			this.footerDisplayHome();
		});
	}
	
	// programs admissions page
	$('#pagewrapper.program-landing').doOnce(function(){
		this.programLandingLayout();
	});
	
	// slideshow
	$('#slides.slideshow').doOnce(function(){
		this.slideshow();
	});
	
	// min-height page fix
	$('#pagewrapper.article-page').doOnce(function(){
		this.fullHeight();
	});
	$('#pagewrapper.utility-page').doOnce(function(){
		this.fullHeight();
	});
	$('#pagewrapper.network-page').doOnce(function(){
		this.fullHeight();
	});
});	


// ------------------------------------------------------------------------ /
    
(function($){
	$.fn.mainNav = function() {
		var $this = $(this);
		var all_nav_items = $this.find('> li');
		var all_nav_menus = $this.find('div.menu');
		var vis_menu;
		var nav_init = false;
		$this.hoverIntent(
			function () { }, 
			function () {
				mainNavClose()
			}
		);
		all_nav_items.hoverIntent(
			function () {
				$this = $(this);			
				var this_menu = $this.find('div.menu');
				all_nav_items.removeClass('active');
				$this.addClass('active');
				if (!nav_init) {
					nav_init = true;
					vis_menu = this_menu;			
					this_menu.css({'opacity' : '0', 'height' : 'auto'})
					.animate({
						opacity: 0.99,
						height: 'toggle'
					}, 500);	
				}
				else {
					if (vis_menu !== undefined) {
						vis_menu.stop()
						.animate({
							opacity: 0
							}, 500);
					}			
					vis_menu = this_menu;	
					this_menu.stop()
					.css({'opacity' : '0', 'height' : 'auto'})
					.show()
					.animate({
						opacity: 0.99
					}, 500);
				}					
			}, 
			
			function () {		
			}
		);
		
		$(document).bind('touchstart', function() {
		    mainNavClose();
		});
		all_nav_items.bind('touchstart', function(e) {
		    e.stopPropagation();
		});
		if ($.support.touchEvents) {			
			all_nav_items.find('> a').bind('click', function() {
				if ($(this).siblings('div.menu').css('opacity') !== '0.99') { return false; }				
			});		
		}
		
		function mainNavClose() { 
			all_nav_menus.stop()
			.delay(10)
			.fadeOut();	
			all_nav_items.removeClass('active');		
			nav_init = false;
		}
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.footerDisplay = function() {	
		return this.each(function() {
			var $this = $(this);
			var footer_menu_el = $('#footer-menu');
			$this.hover(
				function () {
					clearTimeout(window.t_foot_out);
					window.t_foot_in = setTimeout(
						function() {
							footer_menu_el.slideDown();	
							}, 750);
				},
				function () {
					clearTimeout(window.t_foot_in);
					window.t_foot_out = setTimeout(
							function() {
								footer_menu_el.slideUp();	
							}, 750);
				}
			);
			$('#footer').bind('touchstart', function() {	
				footer_menu_el.slideToggle();
			});
			$this.bind('touchstart', function(e) {
				$this.unbind('mouseover')
				.unbind('mouseout');	
				e.stopPropagation();				
			});
			$(document).bind('touchstart', function() {
				footer_menu_el.slideUp();
			});	
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.footerDisplayHome = function() {	
		return this.each(function() {
			var $this = $(this);
			var ft_hvr = false;
			var footer_menu_el = $('#footer-menu');
			var footer_menu_h = footer_menu_el.height();
			var sub_lis = $('#footer-menu LI:first-child').nextAll();			
			$this.hoverIntent(function() {
				ft_hvr = true;
			}, 
			function() {
				ft_hvr = false;
			});
			function footerDelay(interval) { 
				window['hm_foot_timer'] = setTimeout( function() {
					if (!ft_hvr) {
						footer_menu_el.animate({
							height: '29px'
							},'normal', function() {
								sub_lis.hide();
								$this.hoverIntent({
									interval: 100,
									over: footerMenuShow, 
									timeout: 500, 
									out: footerMenuHide
								});
							}
						);
					} else { footerDelay(2000); }
				}, interval);
			} 
			footerDelay(4000);		
			function footerMenuShow(){ 
				sub_lis.show();
				footer_menu_el.animate({
					height: footer_menu_h + 'px'
				});
			}
			function footerMenuHide(){ 
				footer_menu_el.animate({
					height: '29px'
					},'normal', function() {
						sub_lis.hide();
					}
				);
			}			
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.fullHeight = function() {
		return this.each(function() {
			content_el = $('#maincontent');
			var win_h = $(window).height();
			var el_off = content_el.offset().top;
			var el_top = parseInt(content_el.css('paddingTop'));
			var el_bot = parseInt(content_el.css('paddingBottom'));
			x = win_h - el_off - el_top - el_bot;
			side_nav_el = $('#side-nav');
			if (side_nav_el.length) {
				sn_l = side_nav_el.innerHeight();
				if (sn_l + 40 > $(window).height()) { 
					//this is not fixed
					y = sn_l;
				}	
				else {
					y = sn_l + el_bot;
				}
				x = Math.max(x,y);	
			}		
	 		content_el.css('minHeight', x + 'px')
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.videoModal = function() {
		return this.each(function() {
			if(!$.fancybox) { return false }				
			$(this).click(function(e) {				
				var $this = $(this);
				if ($this.is('a[href*="index.htm"]')) { return true };
				var vid_path = $this.attr('href');
				var hide_el = $('<div class="hide" />');
				var vid_el = $('<div id="video-inline-ajax" />')
				.appendTo(hide_el);
				hide_el.appendTo($('body'));
				$.ajax({
					url: vid_path,
					dataType: 'html',
					success: function(data){
						x = data.replace(/<head[^>]*?>[\s\S]*?<\/head>/i, '');	
						vid_el.html(x);
						y = vid_el.find('#video-content');
						if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') {
							width = y.width();
							y.wrapInner('<div id="video-content" style="width:' + width +'px" />');
							var content = y.html();							
						}
						else{							
							vid_el.html(y);
							var content = vid_el
						}
						$.fancybox({
							'content': content,
							'onClosed':	function() {
								hide_el.remove();
							}
						});
					}
				});
				e.preventDefault();
			});	
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.stripeTables = function() {
		return this.each(function() {
			$(this).find('tbody tr:even').addClass('odd');
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.appendHtml = function(options) {	
		defaults = {
			html : '<span />'	
		};
		var options = $.extend(defaults, options);
		return this.each(function() {
			$(this).append(options.html);
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.expandText = function(options) {	
		defaults = {
			target_el : ''		
		};
		var options = $.extend(defaults, options);
		return this.each(function() {
			var $this = $(this);
			var all_paras = $(this).find('div.body > p');
			if (all_paras.length < 2) { return false; }
			var first_para = all_paras.eq(0);
			var sub_para = all_paras.eq(0).nextAll();
			if (options.target_el) {
				var this_top = $this.offset().top;
				var target_top = $(options.target_el).offset().top;
				var target_h = $(options.target_el).height();
				var distance = this_top - (target_top + target_h);
			}			
			sub_para.hide();
			var btn_open = $('<span />', {			  
				html: 'more&#8230;',
				click: function() {
					$(this).hide();
					sub_para.fadeIn();
					if (options.target_el) {
						$this.animate({
							marginTop: -distance + 'px'
							}, 750, function() {
							    btn_close.show();
						});						
					}					
				}
			}).addClass('expand-txt')
			.insertAfter(first_para);
			var btn_close = $('<span />', {	
				click: function() {
					$(this).hide();
					btn_open.show().addClass('hide-btn');
					sub_para.fadeOut();
					if (options.target_el) {
						$this.animate({
							marginTop: '0px'
							}, 500	, function() {
								btn_open.removeClass('hide-btn');
						});				
					}					
				}
			}).addClass('hide-txt')
			.hide()
			.prependTo($this);
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.navSection = function() {	
		return this.each(function() {
			var $this = $(this);
			var nav_section_ul = $this.children('ul');
			var nav_section_hdr = nav_section_ul.clone();
			nav_section_ul.children('li').children('a').remove();
			nav_section_hdr.attr('id', 'nav-section-hdr')
			.find('ul').remove();
			
			if (nav_section_ul.find('li > ul').length) { 
				$this.hover(
					function () {
						clearTimeout(window.t_navsec_out);
						window.t_navsec_in = setTimeout(
							function() {
								nav_section_ul.slideDown();
								}, 750);
					},
					function () {
						clearTimeout(window.t_navsec_in);
						window.t_navsec_out = setTimeout(
								function() {
									nav_section_ul.fadeOut('fast');	
								}, 750);
					}
				);
				nav_section_hdr.delegate('a', 'touchstart', function() {
					if (nav_section_ul.is(':hidden')) {
						nav_section_ul.slideDown();
						return false;
					}
					$this.unbind('mouseover')
					.unbind('mouseout');									
				});
				$(document).bind('touchstart', function() {
					nav_section_ul.fadeOut('fast');
				});
				nav_section_ul.bind('touchstart', function(e) {
					e.stopPropagation();
				});
			}	
						
			nav_section_hdr.prependTo($this);
			nav_h = nav_section_hdr.innerHeight();
			nav_section_ul.css({'top': nav_h + 'px'});
			$this.css({'height': nav_h + 'px'});
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.backToTop = function() {
		return this.each(function() {
			var $this = $(this);
			$this.find('a').smoothScroll();
			$(window).scroll(function(){
				if ($(window).scrollTop() > 100) {
					$this.fadeIn(750);
				} else {
					$this.fadeOut(750);
				}
			});
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /	

(function($){
	$.fn.hoverSlide = function(options) {	
		defaults = {
			toggle_el : 'div.body',
			trigger_el : 'div.header'		
		};
		var options = $.extend(defaults, options);
		return this.each(function() {
			var $this = $(this);
			target = $this.find(options.toggle_el);
			$this.hoverIntent(
				function () {
					target.slideToggle();
				 },
				function () {
					target.slideToggle();
				}
			);
			$this.find(options.trigger_el).bind('touchstart', function() {	
				target.slideToggle();
			});
			$this.bind('touchstart', function(e) {	
				$this.unbind('mouseover')
				.unbind('mouseout');
				e.stopPropagation();
			});
			$(document).bind('touchstart', function() {
			    target.slideUp();
			});
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

//Uses JQuery URL Parser plugin
(function($){
	$.fn.tabs = function(options) {	
		defaults = {
			/*
			external: tabs contain link to external page 
			query string pattern: ?tab=[section name]
			*/
			external : false
		};
		var options = $.extend(defaults, options);
		return this.each(function() {
			var $this = $(this);
			var all_sec = $this.find('div.section');
			var tabs_nav = $this.find('ul.tabnav');
			var all_tabs = tabs_nav.find('> li');
			var active_ref;
			var tab_fancy = false;
			if (tabs_nav.hasClass('tabnav-fancy')) {
				var tab_fancy = true;
			}
			all_sec.hide();	
			
			//if there's an anchor in the url open correct tab
			var tab_anchor = $.url.attr('anchor');
			if (tab_anchor !== null) { 
				var sec_select = $('#' + tab_anchor);
				if (sec_select.hasClass('section')) {
					sec_select.show();
					tabSet(tab_anchor);
					$(window).scrollTop(0);
				}
				else if (all_sec.length) {
					tabSetUp();
				}
			}	
				
			else if (options.external) {
				tab_ref = $.url.param('tab');
				if (tab_ref !== undefined) { 
					$('#' + tab_ref).show();
					tabSet(tab_ref)
				} else if (all_sec.length) {
					tabSetUp();
				}
			}
						
			else if (all_sec.length) {
				tabSetUp();				
			}
			
			function tabSet(ref) {
				this_tab = all_tabs.filter(function() {
					return $(this).find('a').attr('href') == '#' + ref;
				});
				this_tab.addClass('active');
				if (tab_fancy) {
					active_ref = this_tab.attr('id');
					tabs_nav.addClass(active_ref);	
				}
			}
			
			function tabSetUp() {
				all_tabs.first().addClass('active');
				all_sec.first().show();	
				if (tab_fancy) {
					active_ref = all_tabs.first().attr('id');
					tabs_nav.addClass(active_ref);	
				}			
			}
				
			$this.delegate('ul.tabnav > li', 'click', function() {
				this_tab = $(this);
				this_href = this_tab.find('a').attr('href');
				if (this_href.match(/^#/)) { 
					all_tabs.removeClass('active');
					this_tab.addClass('active');
					all_sec.hide();
					$(this_href).show();
					if (tab_fancy) {
						tabs_nav.removeClass(active_ref);
						active_ref = this_tab.attr('id');
						tabs_nav.addClass(active_ref);						
					}
					return false;		
				}						
			});
			if (!tab_fancy) {
				all_tabs.find('a').append('<span class="arw" />');
			}
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.hideShow = function(options) {	
		defaults = {
			container : '',
			target_el : '',
			toggle_el : ''		
		};
		var options = $.extend(defaults, options);
		return this.each(function() {
			var $this = $(this);
			var all_containers = $this.find(options.container);
			var all_targets = $this.find(options.target_el);
			all_containers.filter(function() {
				return $(this).hasClass('selected');
			})
			.find(options.target_el).show();
			$this.find(options.toggle_el).hoverIntent(
				function () {
					all_targets.hide();
					all_containers.removeClass('selected');
					$(this).parents(options.container).addClass('selected')
					.find(options.target_el).show();
				}, 
				function () {
				}
			);
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.floatingEl = function() {	
		return this.each(function() {
			if ($('html').hasClass('no-positionfixed')) { return false; }
			var $this = $(this);
			if ($this.innerHeight() + 40 > $(window).height()) { return false; }
			var top_pos = $this.css('top');
			var el_top = $this.offset().top;
			function positionEl() {
				if ($(window).scrollTop() > el_top) {
					$this.css({ 'position' : 'fixed', 'top' : '0' });
				}
				else {
					$this.css({ 'position' : 'absolute', 'top' : top_pos });
				}
			}
			positionEl();
			$(window).scroll(positionEl);
			$(window).resize(positionEl);
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.randomImg = function(options) {	
		defaults = {
			item : 'div.slide'
		};
		var options = $.extend(defaults, options);
		return this.each(function() {			
			var $this = $(this);			
			all_items = $this.find(options.item);
			random_num = Math.floor(Math.random()*(all_items.length));
			all_items.eq(random_num).show();
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.carousel = function(options) {	
		defaults = {
			control_el : $('<div id="slides-control" />'),
			vis_width : 477,
			vis_items : 3,
			interval : 12000,
			speed : 1000,
			autoplay : true	
		};
		var options = $.extend(defaults, options);
		return this.each(function() {	
			var $this = $(this);		
			var carousel_l = $this.find('div.section').length;
			var carousel_pos = 0;	
			var carousel_anim = false;
			var carousel_hvr = false;
			$this.hover(function() {
				carousel_hvr = true;
			}, 
			function() {
				carousel_hvr = false;
			});
			if (carousel_l > options.vis_items) {
				var slide_num = Math.ceil(carousel_l/options.vis_items);
				i=0;
				while (i<slide_num) {		
					$('<span  />')
					.click(function() {
						var this_btn = $(this);
						if (this_btn.hasClass('active')) { return false; }
						clearTimeout(window['carousel_timer']);				
						this_inc = (this_btn.data('inc')) * options.vis_width;
						distance = this_inc - carousel_pos;
						carouselMove(this_btn, distance);
					})
					.data('inc',i)
					.appendTo(options.control_el);
					i++;
				}
				options.control_el.insertAfter($this);
				options.control_el.find('span:first-child').addClass('active');
				if (options.autoplay) {
					carouselDelay();
				}
			}
			 
			function carouselMove(btn, distance) {
				if (carousel_anim) { return false; }
				carousel_anim = true;
				options.control_el.find('span').removeClass('active');	
				$this.animate({opacity: 0.25}, 100)
				.animate({left: '-=' + distance + 'px'}, options.speed, function() {
					btn.addClass('active');
				})				
				.animate({opacity: 0.99}, 500, function() {
					carousel_anim = false;
				});
				carousel_pos += distance;
			}
			
			var btn_count = 1;
			var btn_length = options.control_el.find('span').length;
			
			function carouselDelay() { 
				window['carousel_timer'] = setTimeout(			
					function() {
						if (carousel_hvr) {
							carouselDelay();
							return false;
						}
						btn = options.control_el.find('span').eq(btn_count);
						carouselMove(btn, options.vis_width);
						btn_count++;
						if (btn_count < btn_length) {
							carouselDelay();
						}
					}, options.interval);
			}
			
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.carouselExpand = function(options) {	
		defaults = {
			container : ''
		};
		var options = $.extend(defaults, options);
		return this.each(function() {	
			var $this = $(this);
			var carousel_el = $this.find(options.container);	
			carousel_ex_el = $('<div />', {
			  id: 'carousel-expand'			
			}).hover(
				function () {
					carousel_ex_el.stop()
					.css({'width' : '25px'});
				},
				function () {
					carousel_ex_el.stop()
					.animate({
					width: '0px'
				}, 100);
			});
			$('<div />').attr('title', 'expand')
			.click(function(){
				$(this).remove();
				clearTimeout(window['carousel_timer']);
				$('#slides-control').remove();
				carousel_el.stop()
				.animate({'opacity' : '0'}, 'fast', function() {
					carousel_el.animate({'opacity' : '0.99'}, 'slow');
				    $this.addClass('expanded ')
					.animate({'width': '953px'}, 'slow', function() {
					    carousel_el.carousel({
							vis_width : 954,
							vis_items : 6,
							speed : 1500,
							autoplay : false });
					  })
					.unbind('mouseenter')
					.unbind('mouseleave');
					carousel_el.css({ 'left' : '0' });
				  });		
			}).appendTo(carousel_ex_el);			
			carousel_ex_el.insertBefore($this);
			
			$this.hover(
				function () {
					carousel_ex_el.stop()
					.animate({
						width: '25px'
					}, 100);

				}, 
				function () {
					carousel_ex_el.stop()
					.animate({
						width: '0px'
					}, 100);
				}
			);
			if ($.support.touchEvents) {
				$this.unbind('mouseenter')
				.unbind('mouseleave');
				carousel_ex_el.unbind('mouseenter')
				.unbind('mouseleave');
			}			
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /	

(function($){
	$.fn.slideshow = function(options) {	
		defaults = {
			interval : 8000,
			restart : 8000
		};
		var options = $.extend(defaults, options);
		return this.each(function() {	
			var $this = $(this);
			var all_ss_slides = $this.find('div.slide');
			if (all_ss_slides.length < 2) { return false; }	
			var slideshow_control = $('<div id="slides-control" />');
			var pause_slides = false;
			var slideshow_hvr = false;					
			var visible_slide = $this.find('div.default');
			$this.find('div.caption').hover(function() {
				pause_slides = true;
			}, 
			function() {
				pause_slides = false;
			});	
			all_ss_slides.filter(function() {
				return $(this).is(':hidden');
			}).addClass('preload');

			all_ss_slides.each(function() {
				slide = $(this);
				this_id = slide.attr('id');
				slide_but = $('<span data-slide-id=' + this_id + ' />')
				.click(function() {
					this_btn = $(this);
					this_btn.addClass('active')
					.siblings('span').removeClass('active');
					this_btn_id = this_btn.attr('data-slide-id');
					var this_target = $('#' + this_btn_id);
					active_slide = all_ss_slides.filter(function() {
						return $(this).hasClass('active');
					}).css('z-index' , '5');
					active_slide.removeClass('active');
					if (this_target.hasClass('preload')) {
						this_target.removeClass('preload').hide();
					}
					this_target.addClass('active')
					.css('z-index' , '10')
					.fadeIn('slow', function() {
						active_slide.hide();
						this_target.css('z-index' , '5');
					});				
					visible_slide = this_target;	
					clearTimeout(window['slideshow_timer']);
					clearTimeout(window['slideshow_delay_timer']);
					window['slideshow_delay_timer'] = setTimeout(
						function() {
							slidesDelay();
						}, options.restart);
				});
				if (slide.hasClass('default'))	{
					slide_but.addClass('active');
				}		
				slide_but.appendTo(slideshow_control);
				slideshow_control.appendTo($this);
			});		

			function slidesFade() { 
				if(!pause_slides) {
					if (visible_slide.next('div.slide').length) {
						next_slide = visible_slide.next('div.slide');
					}
					else { 
						next_slide = all_ss_slides.eq(0);
					}
					if (next_slide.hasClass('preload')) {
						next_slide.removeClass('preload').hide();
					}
					visible_slide.removeClass('active');
					next_slide.hide()
					.addClass('active')
					.css('z-index' , '10')
					.fadeIn('slow', function() {
						visible_slide.hide();
						visible_slide = next_slide;
					});	
					visible_slide.css('z-index' , '5');
					slideshow_control.find('span').removeClass('active')
					.filter(function() {
						return $(this).attr('data-slide-id') == next_slide.attr('id');
					}).addClass('active');
				}
			}

			function slidesDelay() { 
				window['slideshow_timer'] = setTimeout(
					function() {
						slidesFade();
						slidesDelay();
					}, options.interval);
			}
			
			slidesDelay();
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /

(function($){
	$.fn.programLandingLayout = function() {	
		return this.each(function() {
			var $this = $(this);
			var splash_img = $('#splash-img');
			var splash_img_h = splash_img.height();
			var splash_img_src = splash_img.attr('src');
			$('html, body, #pagewrapper').css({ 'height' : '100%' });
			$('#pagewrapper').css('background-image', 'url(' + splash_img_src + ')');
			var prog_page_h = $('#maincontent').innerHeight() + splash_img.height();
			function calcProgPageH() {
				if ($(window).height() < 500) {
					$this.css({ 'height' : '500px' });
					$('#contentwrapper').css({ 'position' : 'absolute' });
				}
				else if (prog_page_h < $(window).height()) {
					$this.css({ 'height' : prog_page_h });
					$('#contentwrapper').css({ 'position' : 'absolute' });
				}
				else {
					$this.css({ 'height' : '100%' });
					$('#contentwrapper').css({ 'position' : 'fixed' });
				}
			}
			calcProgPageH();
			$('#contentwrapper').css({ 'visibility' : 'visible' }); 
			$(window).resize(calcProgPageH);
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /	

(function($){
	$.fn.nestedListDisplay = function() {	
		return this.each(function() {
			var $this = $(this);
			var all_spans = $(this).find('span');
			var all_sub_uls = $(this).find('li > ul');
			var all_lnks = $(this).find('a');
			all_sub_uls.hide()
			.first().show();
			$this.find('> ul > li:first-child span').addClass('active');
			$this.delegate('span', 'click', function(){
				all_spans.removeClass('active');
				all_sub_uls.hide();
				$(this).addClass('active')
				.siblings('ul').show();
			});
			$this.delegate('a', 'click', function(){
				all_lnks.removeClass('active');
				$(this).addClass('active');
				return false;
			});
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /	

(function($){
	$.fn.directoryPager = function() {	
		return this.each(function() {
			var $this = $(this);
			$this.delegate('a', 'click', function(){
				$(this).siblings('a').removeClass('current');
				$(this).addClass('current');
				return false;
			});
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /	

(function($){
	$.fn.directoryAlpha = function() {	
		return this.each(function() {
			var $this = $(this);
			$this.delegate('a', 'click', function(){
				$(this).siblings('a').removeClass('current');
				$(this).addClass('current');
				return false;
			});
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /	

(function($){
	$.fn.twitterfall = function(options) {
		defaults = {
			url: null,
			reveal: 300,
			fetch: 5000,
			interval: 5000,
			max: 3
		};
		var options = $.extend(defaults, options);
		return this.each(function() {
			$.ajaxSetup({ cache: true });
			var NYU = {
				tweets: $(this),
				url: $(this).data('url'),
				queue: [],
				fetch: function() {
					$.getJSON(NYU.url,function(d) {
						var h;
						$.each(d, function(i, t) {
							if(t.text !== undefined) {
								h = '<div class="tweet"><div class="tweetinner">';
								h += '<img src="' + t.user.profile_image_url + '"/>';
								h += '<p><span>' + t.user.name + '</span> ' + t.text + '</p>';
								h += '</div></div>';
								NYU.queue.push(h);
							}
						});
						setTimeout(NYU.fetch,options.fetch);
					});
				},
				showNext: function() {
					if(NYU.queue.length) {
						var n = $(NYU.queue.shift());
						NYU.tweets.prepend(n);
						n.slideDown(options.reveal);
						NYU.tweets.find('.tweet:gt(' + options.max + ')').remove();
					}
				},
				init: function() {
					NYU.fetch();
					setInterval(NYU.showNext,options.interval);
				}
			};
			NYU.init();
		});
	};
})(jQuery);

// ------------------------------------------------------------------------ /	

$(document).ready(function() { 
	var isIE6 = ($.browser.msie && $.browser.version === '6.0');
	
	if ($('#pagewrapper.home-page').length) {
		var NYU = {
			autoplay: {
				locked: false,
				timer: null,
				delay: 6000,
				fade: 300
			},
			moving: false,
			building: false,
			speed: {
				slide: 500,
				copy: 1000
			},
			timer: null,
			butd: {
				array: [],
				i: 0,
				speed: 100,
				pending: false
			},
			queue: [],
			setAutoplay: function(autoplay) {
				clearTimeout(NYU.autoplay.timer);
				if (autoplay) {
					NYU.autoplay.timer = setTimeout(function(){
						NYU.autoplay.locked = true;
						$('#row a, #row span').css({'opacity':.01});
						$('#row .current a').css({'opacity':1});
						NYU.slideIn($('#row .current'),true);
						var curr = $('#row .current').removeClass('current');
						var next = curr.next();
						curr.find('a').fadeTo(NYU.autoplay.fade,.01);
						next.addClass('current').find('a').fadeTo(NYU.autoplay.fade,1,function(){
							NYU.slideIn(next,false,function(){
								$('#row a, #row span').css({'opacity':.01});
								$('#row .current a').css({'opacity':1});
								NYU.autoplay.locked = false;
								if ($('#hometheaterrow').hasClass('hover')) {
									NYU.buildUpTearDown(false);
								} else {
									NYU.setAutoplay(true);
								}
							});
						});
					},NYU.autoplay.delay);
				}
			},
			setMoving: function(moving) {
				NYU.moving = moving;
				setTimeout(NYU.tryToDequeue,200);
			},
			setBuilding: function(building) {
				NYU.building = building;
				setTimeout(NYU.tryToDequeue,200);
			},
			tryToDequeue: function() {
				if (!NYU.moving && !NYU.building && !NYU.autoplay.locked) {
					if (NYU.queue.length) {
						NYU.dequeue();
					} else {
						/*recenter*/
						var clas = $('#row .current a').data('safe_class');
						NYU.slideIn($('#row .orig.' + clas),true);
						if (NYU.butd.pending) {
							NYU.butd.pending = false;
							NYU.buildUpTearDown(true);
						}
					}
				}
			},
			enqueue: function(elem) {
				NYU.queue.push(elem);
			},
			dequeue: function() {
				NYU.queue.shift().trigger('click');
			},    
			showIt: function() {
				var clas = $('#row .current a').data('safe_class');
				var next = $('#hometheaterbgs img.' + clas);
				if (!next.hasClass('current')) {
				  $('#hometheatercopy p.current').fadeOut(NYU.speed.copy,function(){
						$(this).removeClass('current');
						$('#hometheatercopy p.' + clas).fadeIn(NYU.speed.copy,function(){
							$(this).addClass('current');
						});
					});
					$('#hometheaterbgs img.current').fadeOut(NYU.speed.copy,function(){
						$(this).removeClass('current');
					});
					$('#hometheaterbgs img.' + clas).fadeIn(NYU.speed.copy,function(){
						$(this).addClass('current');
						
					});
					
				}
			},
			slideIn: function(elem,instant,callback) {
				if (!NYU.moving || instant) {
					if (!instant) {
						NYU.setMoving(true);
						clearTimeout(NYU.timer);
					}
					var wrap_l = $('#rowwrapper').offset().left;
					var this_l = $(elem).offset().left;
					var w = Math.ceil(this_l - wrap_l);
					$('#row .current').removeClass('current');
					$(elem).addClass('current');
					if (!instant) {
						NYU.showIt();
					}
					$('#row').animate({'left':'-=' + (w) + 'px'},{
						duration: instant ? 0 : NYU.speed.slide,
						complete: function(){ 
							if (!instant) {
								NYU.setMoving(false);
							}
							if ($('#row .current.orig').length === 0) {
								/*recenter*/
								var clas = $('#row .current a').data('safe_class');
								NYU.slideIn($('#row .orig.' + clas),true);
							}
							if (callback) {
								callback();
							}
						}
					});
				}
			},
			buildUp: function() {
				if (++NYU.butd.i < NYU.butd.array.length) {
					$(NYU.butd.array[NYU.butd.i]).fadeTo(NYU.butd.speed,1,NYU.buildUp);
				} else {
					NYU.setBuilding(false);
					$('#row a, #row span').css({'opacity':1});
				}
			},
			tearDown: function() {
				if (--NYU.butd.i >= 0) {
					$(NYU.butd.array[NYU.butd.i]).fadeTo(NYU.butd.speed,.01,NYU.tearDown);
				} else {
					NYU.setBuilding(false);
					$('#hometheater #bg').stop(true,true).fadeTo(500,.01);
					$('#hometheatercopy h2 .bg').stop(true,true).animate({'height': (isIE6 ? '135px' : '100%') },300);
				}
			},
			buildUpTearDown: function(down) {
				NYU.setBuilding(true);
				NYU.butd.array = [];
				NYU.butd.array.push($('#row .current span'));
				$('#row .current').nextAll().find('a,span').each(function(){
					if ($(this).offset().left < 1400) {
						NYU.butd.array.push($(this));
					}
				});
				$('#row a, #row span').stop();
				if (down) {
					NYU.butd.i = NYU.butd.array.length-1;
					NYU.tearDown();
				} else {
					$('#hometheater #bg').stop(true,true).fadeTo(500,.5);
					$('#hometheatercopy h2 .bg').stop(true,true).animate({'height': (isIE6 ? '66px' : '50%') },300);
					NYU.butd.i = -1;
					NYU.buildUp();
				}
			},
			init: function() {
				var row = $('#row');
				var bgs = $('<div id="hometheaterbgs">');
				var ps = $('<div id="hometheaterps">');
				var links = $('#row li').each(function(){
					/*extract copy/bg from each link*/
					var _this = $(this);
					var a = _this.find('a');
					/*make the html into a safe class name (replacing spaces, lowercase)*/
					var clas = a.html().toLowerCase().replace(' ','_');
					/*cache the safe class name in the element's data*/
					a.data('safe_class',clas);
					bgs.append(_this.find('img').remove().addClass(clas));
					ps.append(_this.find('p').remove().addClass(clas).wrapInner('<span>').prepend('<span class="bg"></span>'));
					_this.addClass(clas);
				});
				/*setup copy/bgs*/
				bgs.find('img:first').addClass('current');
				ps.find('p:first').addClass('current');
				$('#bodywrapper').before(bgs);
				$('#hometheatercopy p').remove();
				$('#hometheatercopy').append(ps);
				links.filter('.first').removeClass('first');
				/*duplicate words to allow for inifinite loop*/
				var cloned = links.clone(true);/*do a 'deep' clone (or the data-safe_class set earlier will be removed)*/
				row.prepend(cloned)
				row.append(cloned);
				/*mark original links (for recentering)/show first link*/
				var first = links.addClass('orig').filter(':first');
				first.addClass('first');
				NYU.slideIn(first,true);
				NYU.setAutoplay(true);
				/*bind clicks,hovers*/
				$(document).delegate('#prev, #next','click',function(e){
					e.preventDefault();
					NYU.setAutoplay(false);
					if (!NYU.autoplay.locked) {
						if (NYU.moving) {
							NYU.enqueue($(this));
						} else {
							if ($(this).attr('id') === 'next') {
								NYU.slideIn($('#row .current').next());
							} else {
								NYU.slideIn($('#row .current').prev());
							}
						}
					}
					return false;
				}).delegate('#row a','click',function(e){
					e.preventDefault();
					NYU.setAutoplay(false);
					if (!NYU.autoplay.locked) {
						if (!NYU.moving) {
							if (NYU.building) {
								NYU.enqueue($(this));
							} else {
								NYU.slideIn($(this).parent());
							}
						}
					}
					return false;
				}).delegate('#hometheaterrow','mouseover',function(){
					$('#hometheaterrow').addClass('hover');
					if (!NYU.autoplay.locked) {
						NYU.setAutoplay(false);
						NYU.butd.pending = false;
						NYU.buildUpTearDown(false);
					}
				}).delegate('#hometheaterrow','mouseout',function(){
					$('#hometheaterrow').removeClass('hover');
					if (!NYU.autoplay.locked) {
						NYU.butd.pending = true;
						if (!NYU.moving && !NYU.building) {
							NYU.buildUpTearDown(true);
						}
					}
					NYU.setAutoplay(true);
				});
			}
		};
		/*give webfont time to load*/
		setTimeout(NYU.init,250);
	}
	
	if ($('#refine-list').length) {
			var NYU = {
				cache_list: null,
				filterIt: function(catg) {
					var filter;
					if (catg !== 'all') {
						filter = 'li.filter,li.' + catg;
					} else {
						filter = 'li[data-id]';
					}
					$refine_ul = $('#refine-list ul.nav');
					$refine_ul.quicksand(NYU.cache_list.find(filter),{
						duration:1000,
						adjustHeight:false
					},function() {
						$refine_ul.css({'height':''});
						NYU.bindMapHover($refine_ul.find('> li').has('div.map'));
					});
			  	},
				initFiltering: function() {
					var $refinelist = $('#refine-list');
					all_lis = $refinelist.find('ul.nav > li');
					NYU.bindMapHover($refinelist.find('ul.nav > li').has('div.map'));
					NYU.cache_list = $('#refine-list ul.nav').clone();
					$(document).delegate('.refine-filter a[data-catg]','click',function(e){
						e.preventDefault();
						$('.refine-filter a.current').removeClass('current');
						NYU.filterIt($(this).addClass('current').data('catg'));
					}).delegate('#catg','change',function(e){
						e.preventDefault();
						NYU.filterIt($(this).val());
						$('#backtotop').trigger('click');
					});
					var start_catg = $.url.param('refine');
					if (start_catg) {
						$.fx.off = true;
						var a = $('.refine-filter a[data-catg="' + start_catg + '"]');
						if (a.length) {
							a.trigger('click');
						} else {
							$('#catg').val(start_catg);
							NYU.filterIt(start_catg);
						}
						$.fx.off = false;
					}
				},
				initFancyBox: function() {
					var FB = {
						curr: null,
						trigger_elem: null,
						elems: '#refine-list li[data-id]:not(.filter)',
						open: function(elem) {
							$.fancybox({
								overlayOpacity: 0.5,
								overlayColor: '#000',
								showCloseButton: false,
								padding: 0,
								content:'<div class="listing-page-fancybox"><a href="TEST" id="fancyboxprev">Prev</a><div id="fancyboxcopy">TEST</div><a href="TEST" id="fancyboxnext">Next</a>&nbsp;<a href="TEST" id="fancyboxclose">close</a></div>'
							});
							FB.update(elem);
							FB.trigger_elem = elem;
						},
						update: function(elem) {
							FB.curr = elem;
							$('#fancyboxcopy').html(elem.children().clone());
							var i = $('#fancyboxcopy img.icon');
							if (i.length) {
								i.after('<span class="icon">' + i.attr('alt') + '</span>');
							}
							var cls = $('#refine-list').attr('class');
							$('#fancybox-content').addClass(cls);
							$('#fancybox-wrap').addClass('refine');
						},
						close: function() {
							$.fancybox.close();
							if (FB.trigger_elem.find('div.map').length) {
								NYU.mapHoverOff(FB.trigger_elem);
							}
						}
					};
					$(document).delegate(FB.elems,'click',function(e) {
						e.preventDefault();
						FB.open($(this));
					}).delegate('#fancyboxclose','click',function(e) {
						e.preventDefault();
						FB.close();
					}).delegate('#fancyboxprev, #fancyboxnext','click',function(e) {
						e.preventDefault();
						var elem;
						if ($(this).attr('id') === 'fancyboxnext') {
							elem = FB.curr.next();
							if (!elem.length) {
								elem = $(FB.elems + ':first');
							}
						} else {
							elem = FB.curr.prev();
							if (!elem.length) {
								elem = $(FB.elems + ':last');
							}
						}
						FB.update(elem);
					});
				},
				bindMapHover: function(map_lis) {
					map_lis.hoverIntent(
						function () {
							NYU.mapHoverOn($(this));
						},
						function () {
							NYU.mapHoverOff($(this));
						}
					);
				},
				mapHoverOn: function(map) {
					map.find('div.header').show();
					map.find('div.img img').stop().animate({
						opacity: 0.2
						}, 300);
				},
				mapHoverOff: function(map) {
					map.find('div.header').hide();
					map.find('div.img img').stop().animate({
						opacity: 1
						}, 300);
				}
			};
			NYU.initFiltering();
			NYU.initFancyBox();
		
	}
	
	
	if ($('#pagewrapper.experience-culture').length) {
		var NYU = {
			w: 190,
			speed: 300,
			thumbs: $('.thumbs'),
			controls: $('.controls'),
			locked: false,
			pending: null,
			init: function() {
				$('.video-js').VideoJS();
				$('.vjs-controls').delay(4000).fadeOut(1000);
				var all = $('.thumbs li');
				if (all.length <= 4) {
					$('.controls a').remove();
				} else {
					if (all.length === 5) {
						$('.thumbs ul').append(all.clone());
					}
					var l = $('.thumbs li:last').remove();
					$('.thumbs ul').prepend(l).animate({'left':'-=191px'},0);
					$(document).delegate('.controls .prev, .controls .next','click',function(e){
						e.preventDefault();
						if ($(this).hasClass('prev')) {
							$('.thumbs ul').animate({'left':'-=191px'},function(){
								var f = $('.thumbs li:first').remove();
								$('.thumbs ul').append(f).animate({'left':'+=191px'},0);
							});
						} else {
							$('.thumbs ul').animate({'left':'+=191px'},function(){
								var l = $('.thumbs li:last').remove();
								$('.thumbs ul').prepend(l).animate({'left':'-=191px'},0);
							});
						}
					});
				}
				$('#tweets').twitterfall();
			},
			buildVideo: function(img, mp4, webm, ogv, caption) {
			  /* NOTE: the paths to the img, mp4, webm, and ogv will come from the markup on the page, these paths should be absolute (with http://) */
				var s = '';
				s += '<video class="video-js" width="954" height="537" controls preload poster="' + img + '">';
				s += '<source src="' + mp4 + '" type=\'video/mp4; codecs="avc1.42E01E, mp4a.40.2"\' />';
				s += '<source src="' + webm + '" type=\'video/webm; codecs="vp8, vorbis"\' />';
				s += '<source src="' + ogv + '" type=\'video/ogg; codecs="theora, vorbis"\' />';
				s += '<object class="vjs-flash-fallback" width="954" height="537" type="application/x-shockwave-flash" data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">';
				s += '<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />';
				s += '<param name="allowfullscreen" value="true" />';
				s += '<param name="wmode" value="transparent" />';
				s += '<param name="flashvars" value=\'config={"playlist":["' + img + '", {"url": "' + mp4 + '","autoPlay":false,"autoBuffering":true}]}\' />';
				s += '<img width="954" height="537" alt="" src="' + img + '">';
				s += '</object>';
				s += '</video>';
				s += '<div class="caption">' + caption + '</div>';
				return s;
			},
			openIt: function(elem) {
				NYU.locked = true;
				var t = $(elem).addClass('moving');
				var p = t.parent();
				$('.thumbs li .dim').fadeIn(NYU.speed);
				t.find('.dim').hide();
				$('<p>').animate({'top':'100'},{
					duration: NYU.speed,
					step:function(step) {
						var s = Math.floor(NYU.w * step/100);
						t.css({'width':(NYU.w + s) + 'px'});
						p.css({'margin-left':(-s) + 'px'});
						NYU.controls.css({'left':(-s) + 'px'});
					},
					complete:function() {
						NYU.locked = false;
						if (!t.hasClass('hover')) {
							NYU.closeIt(t);
						}
					}
				});
			},
			closeIt: function(elem) {
				NYU.locked = true;
				$('.thumbs li .dim').fadeOut(NYU.speed);
				var t = $(elem);
				var p = t.parent();
				var w = t.width() - NYU.w;
				$('<p>').animate({'top':'100'},{
					duration: NYU.speed,
					step:function(step) {
						var s = w - Math.floor(NYU.w * step/100);
						t.css({'width':(NYU.w + s) + 'px'});
						p.css({'margin-left':(-s) + 'px'});
						NYU.controls.css({'left':(-s) + 'px'});
					},
					complete:function() {
						$('.thumbs li .dim').fadeOut(NYU.speed,function(){
							t.removeClass('moving');
							NYU.locked = false;
						});
					}
				});
			}
		};
		$(this).delegate('.thumbs li','mouseenter',function(){
			clearTimeout(NYU.pending);
			$(this).addClass('hover');
			if (!NYU.locked && $('.thumbs li.moving').length === 0) {
				NYU.openIt($(this));
			} else {
				var h = $('.thumbs .hover');
				if (h.length) {
					NYU.pending = setTimeout(function(){
						NYU.openIt(h);
					},NYU.speed*2.5);
				}
			}
		}).delegate('.thumbs li','mouseleave',function(){
			clearTimeout(NYU.pending);
			$(this).removeClass('hover');
			if (!NYU.locked && $(this).hasClass('moving')) {
				NYU.closeIt($(this));
			}
		}).delegate('.thumbs li','click',function(e){
			e.preventDefault();
			$('.thumbs .current').removeClass('current');
			var t = $(this).addClass('current');
			var img = t.find('.img').attr('href');
			var mp4 = t.find('.mp4').attr('href');
			var webm = t.find('.webm').attr('href');
			var ogv = t.find('.ogv').attr('href');
			var caption = t.find('.caption').html();
			$('.video-js-box').html(NYU.buildVideo(img, mp4, webm, ogv, caption));
			$('#tweets').stop().animate({
				'height':'59px'
			},NYU.speed,function(){
				$(this).find('.tweet:gt(0)').remove();
				$(this).css({'height':''});
			});
			$('.video-js').VideoJS();
			$('.vjs-controls').delay(4000).fadeOut(1000);
			
		}).delegate('.video-js-box','mouseenter',function(){
			$('#tweets').stop().animate({
				'height':'59px'
			},NYU.speed);
			$('.vjs-controls').stop().hide().css({'opacity':''}).fadeIn(500);
		}).delegate('.video-js-box','mouseleave',function(){
			$('#tweets').stop().animate({
				'height':'177px'
			},NYU.speed);
			$('.vjs-controls').stop().show().fadeOut(500);
		});
		NYU.init();
	}
});


