jQuery.fx.prototype.update=function(){if(this.options.step)this.options.step.call(this.elem,this.now,this);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this)}
if(!$.support.opacity)$('#banner b').css({filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'g/banner.png\',sizingMethod=\'scale\')',background:'none'});
if(String(window.location.search).indexOf('?tag')===0)window.location.replace(String(window.location).replace('?','#'));
Cufon.replace('h2,h6,h5,b a,a b',{fontFamily:'Akagi',hover:true});

KLM={
	hash:String(window.location.hash).replace('#',''),
	tipel:$('<div id="tip"></div>').css('opacity',0.8).appendTo(document.body),
	tover:function(e){$(this)[e.type=='mouseenter'?'addClass':'removeClass']('hover')},
	hover:function(e){$(this).animate({paddingLeft:e.type=='mouseenter'?10:0},{queue:false,duration:100})},
	input:function(e){this.value=(e.type=='focus'&&this.value==this.title)?'':(this.value||this.title)},
	tip:function(e){KLM.tipped=e.type=='mouseenter'?KLM.tipel.html($(this).data('title')).show():!KLM.tipel.hide()},
	tab:function(e){(e=$(this).addClass('cur').parent('dl')).find('dd').hide().eq(e.find('dt').not(this).removeClass('cur').end().index(this)).show()},
	sort:function(){
		var tags=$('div.tags a').removeClass('cur'),tag=$(this).addClass('cur').attr('href').replace(/^[^\/?]*(\?tag=)?/,'');
		var els=$('div.thumbs').children(),show=els.filter('a[rel*='+tag+']');hide=els.not(show);
		show.animate({width:220,height:235,marginRight:15},{queue:false,duration:700});
		hide.animate({width:0,height:0,marginRight:0},{queue:false,duration:700});
		return !(window.location.hash='#'+tag);
	},
	slide:function(e){
		var el=$(this),t=e.target,imgs=el.find('img'),as=el.find('a').removeClass('cur');
		var i=t.src?imgs.index(t)+1:as.index(t);as.eq(i=i==imgs.length?0:i).addClass('cur');
		el.find('div').stop().animate({marginLeft:i*el.width()*-1});
	},
	audio:function(){
		var el=$(this).addClass('cur'),next=el.next();$('ul.audio a').not(this).removeClass('cur');
		$('div.audio').empty().html('<ins>'+el.html()+'</ins><br />'+next.html()+'<br /><br /><div id="audio"></div>');
		AudioPlayer.embed('audio',{soundFile:next.attr('title')});
	}
}

$('div.tags a').click(KLM.sort);
$('div.slider').click(KLM.slide);
$('ul.list a').hover(KLM.hover,KLM.hover);
$('input:text,textarea').bind('focus blur',KLM.input).each(function(i,el){el.value=el.value||el.title});
$('#weblog').length||$('a[title]').each(function(i,el){$(el).data('title',el.title).removeAttr('title')}).hover(KLM.tip,KLM.tip);
$('dl.tabs dt').addClass('tab').hover(KLM.tover,KLM.tover).click(KLM.tab).next().hide().appendTo('dl.tabs').eq(0).show();
$(document).mousemove(function(e){if(KLM.tipped)KLM.tipel.css({top:e.pageY+15,left:e.pageX+15})});
if(KLM.hash)$('div.tags a[href*='+KLM.hash+']').click();
$('ul.audio a').click(KLM.audio).eq(0).click();

$(function(){
	var el=$('#banner'),cur,blocks=$.makeArray(el.children()),swap=function(){el.animate({opacity:0},100,'linear',loop)};
	var loop=function(){el.css('opacity',cur?0:1).prepend(cur=blocks.shift()).animate({opacity:1},1000);
		$('img',cur).css('marginTop',0).animate({marginTop:-60},5000,'linear',swap,blocks.push(cur))}
	if(blocks.length)loop();
});

if(self!=top){
	if(document.images)top.location.replace(window.location.href);
	else top.location.href=window.location.href;
}
