
		var xhr;
		var h='';
		
		var color= new Array();
		color[0]= 'e8a123'; /* general #/ */
		color[1]= '005e96'; /* listen #/l */
		color[2]= '3f97bf'; /* read #/r */
		color[3]= '51b5b2'; /* watch #/w */
		color[4]= '55b23b'; /* behide #/b */
		color[5]= 'b0597e'; /* teams #/t */
		
		function goHash(s) {
			window.location.hash=s;
			updateHash();
			return false;
		}
		
		function goHashInv(s) {
			window.location.replace(s);
			updateHash();
			return false;
		}
		
		function silentHash(s) {
			window.location.hash=h=s;
			return false;
		}
		
		function goPage(s) {
			if(!window.location.hash.match(/^#\/(l|r|w|b|p)\/x?search:[aygbs]\/([1-9][0-9]*(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?)$/)) return;
			h=window.location.hash=window.location.hash.replace(/^#\/(l|r|w|b|p)\/x?search:([aygbs])\/[1-9][0-9]*((\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?)$/,'#/$1/search:$2/'+s+'$3');
			gS('/@/ajax/general/search.php?c='+window.location.hash.replace(/^#\/(l|r|w|b|p)?.+$/,'$1')+'&q='+window.location.hash.replace(/^#\/(l|r|w|b|p)\/x?search:([aygbs]\/[1-9][0-9]*(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?)$/,'$2'));
			return false;
		}
		
		function goXPage(s) {
			if(!window.location.hash.match(/^#\/(l|r|w|b|p)\/x?search:[aygbs]\/([1-9][0-9]*(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?)$/)) return;
			h=window.location.hash=window.location.hash.replace(/^#\/(l|r|w|b|p)\/x?search:([aygbs])\/[1-9][0-9]*((\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?)$/,'#/$1/xsearch:$2/'+s+'$3');
			gS('/@/ajax/general/search.php?x=1&c='+window.location.hash.replace(/^#\/(l|r|w|b|p)?.+$/,'$1')+'&q='+window.location.hash.replace(/^#\/(l|r|w|b|p)\/x?search:([aygbs]\/[1-9][0-9]*(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?)$/,'$2'));
			return false;
		}
		
		function goIPage(i) {
			if(window.location.hash.match(/^#\/(l|r|w|b|p)\/xsearch:[aygbs]\//)) goXPage(i);
			else goPage(i);
		}
		
		window.onhashchange = updateHash;  
		
		function goMod(s) {
			if(window.location.hash.match(/^#\/(l|r|w|b|p)\/[1-9][0-9]*$/)) {
				h=window.location.hash=window.location.hash+'/mod';
				document.title='*'+document.title;
			}
			else if(!window.location.hash.match(/^#\/(l|r|w|b|p)\/[1-9][0-9]*\/mod$/)) return;
			gS('/@/ajax/general/mod.php?c='+window.location.hash.replace(/^#\/(l|r|w|b|p)?.+$/,'$1')+'&id='+window.location.hash.replace(/^#\/(l|r|w|b|p)\/([1-9][0-9]*)\/mod$/,'$2'));
			$('#subMenuTitle').html('Fiche <a href="#/'+window.location.hash.replace(/^#\/(l|r|w|b|p)?.+$/,'$1')+'/'+window.location.hash.replace(/^#\/(l|r|w|b|p)\/([1-9][0-9]*)\/mod$/,'$2')+'" onclick="goHash(\'#/'+window.location.hash.replace(/^#\/(l|r|w|b|p)?.+$/,'$1')+'/'+window.location.hash.replace(/^#\/(l|r|w|b|p)\/([1-9][0-9]*)\/mod$/,'$2')+'\')" style="color:#000">*</a>');
			return false;
		}	
		
		function goType(s) {
			if(!window.location.hash.match(/^#\/(l|r|w|b|p)\/x?search:[aygbs]\/([1-9][0-9]*(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?)$/)) return;
			if(s!='') s='/t/'+s;
			h=window.location.hash=window.location.hash.replace(/^#\/(l|r|w|b|p)(\/x?search:[aygbs]\/[1-9][0-9]*)(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?$/,'#/$1$2$3'+s+'$5');
			goIPage(1);
		}
		
		function goOrder(s) {
			if(!window.location.hash.match(/^#\/(l|r|w|b|p)\/x?search:[aygbs]\/([1-9][0-9]*(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?)$/)) return;
			h=window.location.hash=window.location.hash.replace(/^#\/(l|r|w|b|p)(\/x?search:)[aygbs](\/[1-9][0-9]*(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?)$/,'#/$1$2'+s+'$3');
			goIPage(1);
		}
		
		function goGenre() {
			var s='';
			$('#selectable .ui-selected').each(function(){
				if(s!='') s+=',';
				s+=$(this).attr('id').replace('genre','');
			});
			if(s!='') s='/g/'+s;
			h=window.location.hash=window.location.hash.replace(/^#\/(l|r|w|b|p)(\/xsearch:[aygbs]\/[1-9][0-9]*)(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?$/,'#/$1$2$3$4'+s);
			goIPage(1);
		}
		
		function changeGenre() {
			var s=',';
			$('#selectable .ui-selected').each(function(){
				s+=$(this).attr('id').replace('genre','')+',';
			});
			var e= window.location.hash.replace(/^#\/(l|r|w|b|p)\/([1-9][0-9]*)\/mod$/,'$2');
			$.post('/@/ajax/general/change.php',{ eid: e, com: 'genres', value: s });
		}
		
		function goQuery(s,t) {
			if(!window.location.hash.match(/^#\/(l|r|w|b|p)\/x?search:[aygbs]\/([1-9][0-9]*(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?)$/)) return;
			if(s!='') s='/'+t+'/'+encodeURIComponent(s);
			h=window.location.hash=window.location.hash.replace(/^#\/(l|r|w|b|p)(\/x?search:[aygbs]\/[1-9][0-9]*)(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?$/,'#/$1$2'+s+'$4$5');
			goIPage(1);
		}
		
		function gS(s) {
			if (xhr && xhr.readyState != 0) xhr.abort();
			xhr= $.getScript(s);
		}
		
		function gSAt(s) {
			if (xhr && xhr.readyState != 0) xhr.abort();
			xhr= $.getScript(s,function(){ goAt(); });
		}
	
		function updateHash() {
			
			var hash= window.location.hash;
			
			if(hash==h)
			{
				if(h=='') hash='#/';
				else return;
			}
			if(hash=='#/')	gS('/@/ajax/general/display.php?f=general&c=');
			else
			{
				if(hash.match(/^#\/(l|r|w|b|p)/))
				{
					if(hash.match(/^#\/(l|r|w|b|p)$/)) gS('/@/ajax/general/display.php?f=general&c='+hash.replace(/^#\/(l|r|w|b|p)$/,'$1'));
					else if(hash.match(/^#\/(l|r|w|b|p)\/add$/)) gS('/@/ajax/general/display.php?f=add&c='+hash.replace(/^#\/(l|r|w|b|p).+$/,'$1'));
					else if(hash.match(/^#\/(l|r|w|b|p)\/[1-9][0-9]*$/)) gS('/@/ajax/general/display.php?f=display&c='+hash.replace(/^#\/(l|r|w|b|p).+$/,'$1')+'&id='+hash.replace(/^#\/(l|r|w|b|p)\/([1-9][0-9]*)$/,'$2'));
					else if(hash.match(/^#\/(l|r|w|b|p)\/[1-9][0-9]*\/@$/)) gSAt('/@/ajax/general/display.php?f=display&c='+hash.replace(/^#\/(l|r|w|b|p).+$/,'$1')+'&id='+hash.replace(/^#\/(l|r|w|b|p)\/([1-9][0-9]*)\/@$/,'$2'));
					else if(hash.match(/^#\/(l|r|w|b|p)\/[1-9][0-9]*\/mod$/)) gS('/@/ajax/general/display.php?f=mod&c='+hash.replace(/^#\/(l|r|w|b|p).+$/,'$1')+'&id='+hash.replace(/^#\/(l|r|w|b|p)\/([1-9][0-9]*)\/mod$/,'$2'));
					else if(hash.match(/^#\/(l|r|w|b|p)\/[1-9][0-9]*\/[1-9][0-9]*/)) gS('/@/ajax/general/display.php?f=part&id='+hash.replace(/^#\/(l|r|w|b|p)\/[1-9][0-9]*\/([1-9][0-9]*)$/,'$2'));
					else if(hash.match(/^#\/(l|r|w|b|p)\/x?search:[aygbs]\/([1-9][0-9]*(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?)$/)) gS('/@/ajax/general/display.php?'+(hash.match(/^#\/(l|r|w|b|p)\/xsearch:[aygbs]\//)?'x=1&':'')+'f=search&c='+hash.replace(/^#\/(l|r|w|b|p)?.+$/,'$1')+'&q='+hash.replace(/^#\/(l|r|w|b|p)\/x?search:([aygbs]\/[1-9][0-9]*(\/[nrq]\/[%~!*\(\)'A-Za-z0-9_-]+)?(\/t\/[0-9]+)?(\/g\/-?[0-9]+(,-?[0-9]+)*)?)$/,'$2'));
					else
					{
						if(h=='')
						{
							hash='#/';
							gS('/@/ajax/general/display.php');
						}
						else
						{
							window.location.hash=h;
							return;
						}
					}
				}
				else if(hash.match(/^#\/[1-9][0-9]*$/))
				{
					gS('/@/ajax/fiche/attribute.php?eid='+hash.replace('#/',''));
					return;
				}
				else if(hash.match(/^#\/no\/(resume|resfrbuten|link|mu|wom|image|year|genres)$/))
				{
					gS('/@/ajax/general/display.php?f=no&c=&o='+hash.replace(/^#\/no\/(resume|resfrbuten|link|mu|wom|image|year|genres)$/,'$1'));
				}
				else if(hash.match(/^#\/import\/((s|m|p|f)-mu)$/))
				{
					gS('/@/ajax/general/display.php?f=import&c=&o='+hash.replace(/^#\/import\/(ak|[smpf]-mu)$/,'$1'));
				}
				else if(hash.match(/^#\/fuse$/))
				{
					gS('/@/ajax/general/display.php?f=fuse&c=');
				}
				else if(hash.match(/^#\/host$/))
				{
					gS('/@/ajax/general/display.php?f=host&c=');
				}
				else if(hash.match(/^#\/u\/[1-9][0-9]*$/))
				{
					gS('/@/ajax/general/display.php?f=user&c=&n='+hash.replace(/^#\/u\/([1-9][0-9]*)$/,'$1'));
				}
				else
				{
					if(h=='')
					{
						hash='#/';
						gS('/@/ajax/general/display.php');
					}
					else
					{
						window.location.hash=h;
						return;
					}
				
				}
			}
			h=window.location.hash=hash;
		
		}
		
		$(document).ready(function(){
	
			updateHash();	
		
		});
		
	$(function() {
		$("#sortable").sortable();
		$("#sortable").disableSelection();
	});
	
	function prevImage(obj) {
		$(obj).parent().append('<img src="'+$(obj).attr('value')+'" style="max-width:600px; max-height:400px; position: absolute;bottom: 30px; left: 10px;" />');
	}
	
	function unprevImage(obj) {
		$(obj).parent().find('img').remove();
	}
	
	function optionslang() {
		$.getScript('/util/lang.js');
	}
	
	function al(lang) {
		$('#langpicker').append('<img onClick="sl(\''+lang+'\')" src="/@/img/lang/'+lang+'.png" title="Language : '+lang+'" /><br />');
	}
	function sl(lang) {
		$('#langpicker').html('<img onClick="optionslang()" src="/@/img/lang/'+lang+'.png" title="Language : '+lang+'" />');
		$.get('/@/ajax/user/chlang.php?lang='+lang);
	}
	function goAt() {
		$('.rshort').show('normal',function(){$(this).css('display','inline');});$('.rlong').hide('normal'); $('#image').animate({'max-width':'10%'},'normal');$('#ddl').slideDown('normal');$('.resume').animate({'font-size':'0.8em'},'normal');
	}
	function ungoAt() {
		$('.rshort').hide('normal');$('.rlong').show('normal'); $('#image').animate({'max-width':'50%'},'normal');$('#ddl').slideUp('normal');$('.resume').animate({'font-size':'1em'},'normal');
	}
	function trygoAt() {
		if(window.location.hash.match(/^#\/(l|r|w|b|p)\/[1-9][0-9]*\/mod$/)) goHash(window.location.hash.replace(/^(#\/(l|r|w|b|p)\/[1-9][0-9]*)\/mod$/,'$1/@'));
		else if(window.location.hash.match(/^#\/(l|r|w|b|p)\/[1-9][0-9]*$/))
		{
			silentHash(window.location.hash.replace(/^(#\/(l|r|w|b|p)\/[1-9][0-9]*)$/,'$1/@'));
			goAt();
		}
		else if(window.location.hash.match(/^#\/(l|r|w|b|p)\/[1-9][0-9]*\/@$/))
		{
			silentHash(window.location.hash.replace(/^(#\/(l|r|w|b|p)\/[1-9][0-9]*)\/@$/,'$1'));
			ungoAt();
		}
	}
	
	
