			var pos = 0;
            var selected_name = '';

			var section_info = new Array();
				section_info['portfolio'] = {id: 'portfolio_content', title: 'Portfolio', position: '140px'};
				section_info['photos'] = {id: 'photos_content', title: 'Galerie de Photos & Dessins', position: '270px'};
				section_info['docs'] = {id: 'docs_content', title: 'Documents', position: '392px'};
				section_info['contact'] = {id: 'contact_content', title: 'Contact', position: '512px'};
				section_info['accueil'] = {id: 'accueil_content', title: 'Accueil', position: '4px'};

			var form_errors = new Array();

			function get_section()
			{
				var section = 'accueil';

				if (location.hash.length != 0 && (section_info[location.hash.substr(1)] != null))
				{
					section = location.hash.substr(1);
				}

				return section;
			}

			function set_title(title)
			{
				window.document.title = title;
			}

			function set_section(hash, title)
			{
				if (!hash.length)
					name = 'accueil';

				if (!title.length)
					title = 'Warpdesign > Accueil';
				else
					title = 'Warpdesign > ' + title;

				location.hash = hash;

				setTimeout('set_title("' + title + '")', 1000);
			}

			function get_link(text)
			{
				var link_expression = /goto_[a-z_]+/i;
				var lien = link_expression.exec(text);

				if (lien)
				{
					return lien[0].substr(5);
				}
				else 
					return null;
			}

			function scroll(elt_id, selection)
			{
                if (typeof elt_id == 'string')
                {
                    var position = $('#' + elt_id).position();
					if (selection)
					{
						selected_name = selection;
					}
                }
                else
                {
                    // Get div to go to position...
                    selected_name = $(this).attr('id');
                    var position = $('#' + selected_name + '_content').position();
                }
				var menu_pos = $('#' + selected_name).position();

				$('div.selection').animate({left: menu_pos.left+'px', top: menu_pos.top+'px'});
                $('#scroll').animate({left:"-"+position.left+"px"}, 600, function() { $('a.scroll').removeClass('still'); $('#' + selected_name).addClass('still'); set_section(selected_name, section_info[selected_name].title); });

				return false;
			}

			function clear_form()
			{
				$('#contact_form input').val('');
				$('#contact_form textarea').val('');
			}

			function clear_errors()
			{
				$('#contact_form label').removeClass('error');
			}

			function error_form()
			{
				$('#loading_span').fadeOut('normal', function() 
				{
					$('#form_error_span').fadeIn('normal', function() 
					{
						for (var i = 0; i < form_errors.length; i++)
						{
							$("#contact_form #lab_" + form_errors[i]).addClass('error');
						}
						setTimeout("$('#form_error_span').fadeOut('normal', function() { $('#contact_form').fadeIn(); $('#submit_form').fadeIn(); });", 2000);
					});
				});
			}

			function success_msg()
			{
				$('#loading_span').fadeOut('normal', function() 
				{
					$('#success_span').fadeIn('normal', function() 
					{
						setTimeout("clear_form(); $('#success_span').fadeOut('normal', function() { $('#contact_form').fadeIn(); $('#submit_form').fadeIn(); });", 1000);
					});
				});
			}

			function error_msg()
			{
				$('#loading_span').fadeOut('normal', function() 
				{
					$('#error_span').fadeIn('normal', function() 
					{
						setTimeout("$('#error_span').fadeOut('normal', function() { $('#contact_form').fadeIn(); $('#submit_form').fadeIn(); });", 2000);
					});
				});
			}

			function send_message()
			{
				// Reinitialize form tab
				form_errors = new Array();

				$.post("send_message.php?id=120548648",
				{ nom: $("#nom").val(), email: $("#email").val(), societe: $("#societe").val(), message: $("#message").val(), sujet: $("#sujet").val() },
					function(response)
					{
						var msg = eval("(" + response + ")");
						if (msg != null && msg['return_code'] == 1)
						{
							form_errors = msg['form_errors'];
							error_form();
						}
						else if (msg != null && msg['return_code'] != 0)
						{
							clear_errors();
							error_msg();
						}
						else
						{
							clear_errors();
							success_msg();
						}
					}
				);				
			}

			TB_chemin_animation = "/img/thick/circle_animation.gif";
			TB_chemin_close = "/img/thick/close.gif";
			var gallery_images = new Array();
			var current_image = 0;


			function fade_picture(id)
			{
				current_image++;
				if (current_image >= gallery_images.length)
					current_image = 0;

				$(id).fadeOut('fast', function() { $(this).attr('src', gallery_images[current_image]); $(this).fadeIn('fast'); } );
				setTimeout('fade_picture("' + id + '")', 4000);
			}

			function init_gallery(id_img, id_src)
			{
				$(id_img).each(function(i) { gallery_images[i] =  $(this).attr('src'); } );
				setTimeout('fade_picture("' + id_src + '")', 4000);
			}

			function show_chat()
			{
				//$('<div id="chat"/>').html('<object width="540" height="380" align="middle" id="flash_banner" data="flash/warpchat.swf" type="application/x-shockwave-flash"><param value="always" name="allowScriptAccess"/><param value="flash/warpchat.swf" name="movie"/><param value="high" name="quality"/><param value="#ffffff" name="bgcolor"/><param value="transparent" name="wmode"/></object>').appendTo('body');
			}

			function close_chat()
			{
				$('div#chat').remove();
			}

			$(document).ready(
				function(){
					// IE6 png fixes
					$('img[src$=.png], div#main').ifixpng();
					$('div#logo img').ifixpng();
					$('div#logo').ifixpng();
					$('div#content').ifixpng();
					$('div#mini_show').ifixpng();
					$('div#contact_content').ifixpng();
					$('#link_blog').ifixpng();
					$('#docs_back').ifixpng();
					$('div.item img.item_icon').ifixpng();

					$('<div class="selection"/>').html('&nbsp;').appendTo('#main');

					// scrolling stuff
					$('a.scroll:not([class*=still])').livequery("click", scroll );

                    $('a.scroll').hover( function() { $(this).toggleClass('selected'); }, function() { $(this).toggleClass('selected'); });
                    $('a.still').livequery("click", function() { return false; } );

                    $('a.goto').click( function() { scroll($(this).attr('id').substr(5)); return false; } );
                    $('a[class^=goto_]').click( function() { scroll(get_link($(this).attr('class'))); return false; } );

					// Contact form
					$('#submit_form').click( function()
					{
						$('#contact_form').fadeOut('normal', function() { $('#loading_span').fadeIn('normal', send_message ); } );
						$('#submit_form').fadeOut('normal');
						return false;
					});

					$('form input,form textarea').focus(function() { $(this).css('backgroundColor', 'white'); } );
					$('form input,form textarea').blur(function() { $(this).css('backgroundColor', ''); } );

					// redirect
					var go_there = get_section();
					if (go_there != 'accueil')
					{
						setTimeout("scroll('" + section_info[go_there].id + "', '" + go_there + "')", 1000);
					}

					// Init home gallery
					init_gallery('img.intro_gal', '#gallery_screen');

					// gallery fancy animation
                    $("#photos_content .img_cadre").hover(function() { $(this).animate({opacity: .7}, 600); }, function() { $(this).animate({opacity: 1}, 600); });

					// portfolio slide init
					$('#wrapper').slide({selected: 0});

					// PiroBox nice gallery
					  $().piroBox({
						  my_speed: 400, //animation speed
						  bg_alpha: 0.8, //background opacity
						  radius: 4, //caption rounded corner
						  pirobox_next : 'next', // 
						  pirobox_prev : 'prev', // 
						  slideshow: '',
						  gallery: 'a.pirobox_gall'
				   });

				   /*
					  $().piroBox({
						  my_speed: 400, //animation speed
						  bg_alpha: 0.8, //background opacity
						  radius: 4, //caption rounded corner
						  this_next : 'next2', // next button inside or outside the imageBox--> next == inside, next_out == outside
						  this_prev : 'prev2', // prev button inside or outside the imageBox--> prev == inside, prev_out == outside
						  gallery: 'a.pirobox_gal2'
				   }); 

					  $().piroBox({
						  my_speed: 400, //animation speed
						  bg_alpha: 0.8, //background opacity
						  radius: 4, //caption rounded corner
						  this_next : 'next3', // next button inside or outside the imageBox--> next == inside, next_out == outside
						  this_prev : 'prev3', // prev button inside or outside the imageBox--> prev == inside, prev_out == outside
						  gallery: 'a.pirobox_gal3'
				   }); 
					*/
				   $('#galerie a').hover(
					   function() {
						$('.legende', $(this)).slideDown();
				   },
					   function() {
	   					$('.legende', $(this)).slideUp();
				   });

				}
			);