/*
 * petit script pour mon petit site perso.
 *
 * Pieterjan Montens Octobre 2008
 */


// le bon vieux document onload.
$(document).ready(function() {
	$('ul#site_menu a').hover(
		function() {
			$(this)
				.parent('li').animate({
					marginLeft:'-80px',
					width:'200px'}, { queue:false, "easing":"easeOutCubic" });
			},
		function() {
			$(this)
				.parents('li')
				//.css('width','120px')
					.randMarginLeft(40);
			});

		$('ul#site_menu').hover(
		function() {
			$(this)
				.animate({
					width:'120px'}, { queue:false, "easing":"easeInCubic" })
				.children('li').each(function() {
					$(this).randMarginLeft(40);
					});
			},
		function() {
			$(this)
				.animate({
					width:'13px'})
				.children('li').animate({marginLeft:0},  { queue:false, "easing":"easeInExpo" });
			});

		$('ul#site_menu a').click(function() {
				$.scrollTo('div'+$(this).attr('href'),1200,{easing:'easeInOutBack'});
				return false;
					});

		$('li.li_title').css('margin-left','-80px');

		// Twitter account settings:
		$("#tweets .text").getTwitter({
			userName: "pieterjan_m",
			numTweets: 5,
			loaderText: "Loading tweets...",
			slideIn: true,
			showHeading: false,
			headingText: "Latest Tweets",
			showProfileLink: true
			});

});

// ajout d'une méthode jQuery pour gérer plus facilement le placement aléatoire du menu;
jQuery.prototype.randMarginLeft = function(p)
	{
	var r = Math.floor(Math.random() * p);
	var q = parseInt(this.css('width')) + r;
	this.css('width',q);
	this.animate({marginLeft:'-' + r}, { queue:false, "easing":"easeInCubic" });
	return this;
	}


