(function($){
	
	$(document).ready(function(){
		
		$("#searchInp").toggleVal({
			focusClass: 'hasFocus',
			changedClass: 'isChanged'
		});
		
		var updatesTips = [];
		

		$('#updatesTools a').each(function(){
			var t = $(this);
			var tt = $('<div class="tooltip"><span class="x1"></span><div class="bd">'+t.html()+'</div></div>').appendTo(t.parent());
			var isShowing = false;
			var away = true;
			var mouseOutSet = false;
			
			var thisTT = updatesTips[updatesTips.length] = t.tooltip({
				api: true,
				position: ['top','center'] ,
				triggers: t,
				onBeforeShow: function(){
					var that = this;					
					if (!isShowing) {
						setTimeout(function() {
							if(!away) {
								that.show();
								isShowing = true;
							}
						}, 100);
						return false;
					};					
				}

			});
						
			t.mouseleave(function(){
				away = true;
				thisTT.hide();
				isShowing = false;
			});
			t.mouseenter(function(){
				away = false;
			})
			
		});
		
		var speakerMetas = [];
		$('.home .speaker').each(function() {
			var meta = $(this).find('.speakerMeta');
			var away = true;
			$(this).mouseenter(function() {
				setTimeout(function() {
					if(!away) {
						meta.fadeIn('slow');
					}
				},400);
				away = false;
			});
			$(this).mouseleave(function() {
				meta.hide();
				away = true;
			});
		});
		
		var updatesNextLink = $('.home #updates .nav-next a').get(0);
		if(updatesNextLink) updatesNextLink.href = updatesNextLink.href+'#updates';
		
		var updatesPrevLink = $('.home #updates .nav-previous a').get(0);
		if(updatesPrevLink) updatesPrevLink.href = updatesPrevLink.href+'#updates';

		var internalLinks = $('a[href*=eduiconf],a[href^=/],a[href^=.]');
		if(location.href.match(/(\?|&)notrack=1/)) {
			internalLinks.each(function(){
				this.href = this.href+RegExp.$1+'notrack=1';
			});
		}

	});
	
	
	
})(jQuery);