﻿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=\'images/banner.png\',sizingMethod=\'scale\')',background:'none'});
if(String(window.location.search).indexOf('?tag')===0)window.location.replace(String(window.location).replace('?','#'));
Cufon.replace('h2,h3,h5,strong a,a strong',{fontFamily:'AvantGardeMdITCTT',hover:true});

jam={
	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){jam.tipped=e.type=='mouseenter'?jam.tipel.html($(this).data('title')).show():!jam.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});
	},
};

$('div.tags a').click(jam.sort);
$('div.slider').click(jam.slide);
$('ul.list a').hover(jam.hover,jam.hover);
$('input:text,textarea').bind('focus blur',jam.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(jam.tip,jam.tip);
$('dl.tabs dt').addClass('tab').hover(jam.tover,jam.tover).click(jam.tab).next().hide().appendTo('dl.tabs').eq(0).show();
$(document).mousemove(function(e){if(jam.tipped)jam.tipel.css({top:e.pageY+15,left:e.pageX+15})});
if(jam.hash)$('div.tags a[href*='+jam.hash+']').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},2000);
		$('img',cur).css({'marginTop':0}).animate({marginTop:-100},10000,'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;
}
