jQuery.fn.extend({
	buffer:{
		files:[],
		html:[]
		},
	page:function() {
		return $(document.location.href.split('#')[0].split('/')).get().reverse().shift();
	},
	label:function(t){
		if(typeof(t)!='string')return;
		return t.split('/').reverse()[0].split('_')[0];
	},
	key: function(v,a)
	{
		for (i=0; i < a.length; i++) 
		{
			if (a[i] === v)  { return i; }
		}
		return false;
	},
	getvars:(function(){
			r={};
			with(document.location.href)
			{
				g=substring((indexOf('?')>indexOf('#')?indexOf('?'):indexOf('#'))+1,length).split('&');
			}
			
			for(i in g) { x=g[i].split('='); r[x[0]]=x[1]?x[1]:true; }
			return r;
		})(),
	qget:function(what)
	{ 
		return $().getvars[what]; 
	}
});


$().ready(function(){
	$('#nav li')
	.mouseover(function(){ $(this).addClass('hover'); })
	.mouseout(function(){ $(this).removeClass('hover'); })
	.click(function(){if(typeof($(this).attr('link'))!='undefined' && $(this).attr('link')!=$().page()){document.location=$(this).attr('link');} }) ;
	
	if($().page()=='blog.php')
	{
		$('#nav li:contains("blog")').attr('link','').click(function(){
		$().article_open('blog.php');
		});
		
		$().buffer.files.push($().page());
		$().buffer.html.push($('#blog').html());
	}
	
	if($().page()=='about.php')
	{
		$('#pix a').focus(function(){
		var t=$(this).attr('img'); 
		$('#pic').attr({'src':t});
		$('#piclabel').text($().label(t));
		return false;
		});
	}
	
	
	if(typeof($().qget('b'))!='undefined')
	{
		$().article_open($().qget('b')+'.html');
	}
});
