$(document).ready(function(){	

	$('a').not('a.affiliations').removeAttr('title');

	//Nav
	$('#mainNav ul li ul').hover(function() {
		$(this).parents("li").addClass('selected');
	},
	function() {
		$(this).parents("li").removeClass('selected');
	});

	
	
	//------------------------------------------------------Main menu
	$('#mainNav ul li').hoverIntent(function() {
		$(this).children("ul").css("display", "none");
		$(this).children("ul").slideDown("fast");
	},
	function() {
		$(this).children("ul").slideUp("fast");
	});

	
	//Affiliations hover
	$('.affiliations img').fadeTo("fast", 0.5);
	$('.affiliations img').hoverIntent(function() {
		$(this).fadeTo("slow", 1);
	},
	function() {
		$(this).fadeTo("slow", 0.5);
	});
	
	
	//Scroll to top
	$('span.backtotop').click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});
	
	
	//Hover for subSubMenu
	$('#panelContent ul li').hoverIntent(function() {
		var notTarget = $(this).hasClass('selected');
		$(this).not(notTarget).addClass('selected');
	},
	function() {
		var notTarget = $(this).hasClass('selected');
		$(this).not(notTarget).removeClass('selected');
	});
	
	
	
	//Home Testimonials accordion
	$('div.acc> div').eq(0).show();
	$('div.acc> h3').click(function() {
		var $nextDiv = $(this).next();
		var $visibleSiblings = $nextDiv.siblings('div:visible');
		if ($visibleSiblings.length ) {
			$visibleSiblings.hide('fast', function() { $nextDiv.slideToggle('fast'); });
		} else {
			$nextDiv.slideToggle('fast');
		}
	});
	
	
	//Home page Carousel	
	$('#carousel').cycle({ 
		fx:    'fade',
		cleartype:  1,
		cleartypeNoBg:  true,
		next:   '#next',
        prev:   '#prev',
		timeout: 8000 
	});
	
	
	//Tooltips
	$('.affiliations').hover(
		function(e) {
		this.tip = this.title;
		var tipX = e.pageX-90;
		var tipY = e.pageY-90;
		$('body').append('<div class="toolTipWrapper">'+this.tip+'</div>');
		this.title = "";
		this.width = $(this).width();
		$('body').find('.toolTipWrapper').css({left:tipX, top:tipY })
		$('.toolTipWrapper').fadeIn('slow');
	},
	function() {
		$('.toolTipWrapper').fadeOut(100);
		$('body').find('.toolTipWrapper').remove();
		this.title = this.tip;
	});

	$(".affiliations").mousemove(function(e){
		var tipX = e.pageX-90;
		var tipY = e.pageY-90;
		$('.toolTipWrapper').css("left", tipX).css("top", tipY);
	});
	
}); //Close document.ready

$(window).bind("load", function() {
});