$(document).ready(function(){
	// Tabs
	$("#tabs").tabs({event: "mouseover"});
	/*
	if(window.location.hash) {
		var hash = window.location.hash;
		hash.substring(1);
		alert(hash);
	}
	$("#tabs").tabs( "select" , 1 )*/
	// Tips
	$('area[title]').each(function(){
		var mon_titre = $(this).attr("title");
		$(this).qtip(
		{
			/*position: {my: 'center',at: 'center',target: $("#more_info")}*/
			position: {my: 'top left',target: 'mouse',viewport: $(window),adjust: {
            x: 10,
            y: 10
         }},
			content: {
				title: {
					text: mon_titre,
					button: false
				},
				attr: 'alt' // Use the ALT attribute of the area map for the content
			},
			style: {
				classes: 'ui-tooltip-pm'
			}
		});
	});
	/*
	$('.body-page.credentials map area').css("cursor", "help").qtip({
		position: {my: 'left center',at: 'right center',viewport: $(window),adjust: {method: $('#adjust_method').val(),
            x: parseInt($('#adjust_x').val(), 10) || 0,
            y: parseInt($('#adjust_y').val(), 10) || 0
         }
		},
		show:{ effect: function() { $(this).fadeIn(400); }},
		hide:{ fixed: true,delay: 1000,effect: function() { $(this).fadeOut(400); }},
		content: {title: { text: 'Où trouver les exemplaires ?',   button: false  }},
		style: {classes: 'ui-tooltip-arifor'}
	});*/
	
	// Smooth scrolling on area
	$("area").click(function() {
		var ancre = $(this).attr("href").split("#");
		var top = $("a[name="+ancre[1]+"]").offset().top;
		$("html, body").animate({
			scrollTop: (top-20) + "px"
		}, {
			duration: 500,
			easing: "swing"
		});
		return false;
	});
	
	
	// Smooth scrolling to go to top
	$("#gototop").click(function() {
		$("html, body").animate({scrollTop: "0px"}, {duration: 500,easing: "swing"});
		return false;
	});

	// Smooth scrolling for .topLink
	$("a.topLink").click(function() {
		var ancre = $(this).attr("href").split("#");
		var top = $("a[name="+ancre[1]+"]").offset().top;
		$("html, body").animate({
			scrollTop: (top) + "px"
		}, {
			duration: 500,
			easing: "swing"
		});
		return false;
	});
	
	// Hover homepage
	$("#homepage .service-areas .images .image a").hover(function() {
		$(this).find('img').animate({opacity : 0}, 250);
	},function() {
		$(this).find('img').animate({opacity : 1}, 250);
	});
	
	// Blockquote
	$("blockquote").each(function() {
		var quote = $(this).html();
		$(this).html("<p style='text-align:left'><div class='top'>&nbsp;</div></p><div class='content'>"+quote+"</div><div class='bottom'>&nbsp;</div>");
	});
});
