function $object(obj){var tmp='';for(var x in obj)tmp+=x+'='+obj[x]+'\n';return alert(tmp)}
function $E(css,hold){return (hold?$(hold):document).getElement(css)}

var base=window.location.toString().replace(/\/[^\/]*$/gi,'/');

window.addEvent('domready',function(){
	$$('a').forEach(function(el){
		var href=el.href.replace(base,'');
		if(href.contains('/'))el.set('target','_blank')
		if(el.href.indexOf(base)===0&&$(href))el.set('href','#'+href);
	});
	$$('.home .concerts dt a').forEach(function(el,i){el.addEvent('click',function(){dt[i].hasClass('cur')||accord.display(dt[i].getNext())})});
	var dd=$$('dd'),dt=$$('.wrap.concerts dt'),smooth=new SmoothScroll();
	var accord=new Accordion(dd.getPrevious(),dd,{
		onActive:function(el){el.addClass('cur')},
		onBackground:function(el){el.removeClass('cur')},
		alwaysHide:true
	});
	$$('.archive:not(.opn) h6').forEach(function(el){
		var fx=new Fx.Tween(el=el.parentNode,{'link':'cancel'}).set('height',15);
		el.addEvents({
			mouseenter:function(){fx.start('height',el.scrollHeight-20).chain(function(){el.setStyle('height','auto')})},
			mouseleave:function(){fx.start('height',[el.scrollHeight-20,15])}
		});
	});
	$$('h4 a').addEvent('click',function(e,el){
		var e=new Event(e).stop(),href=this.href.replace(base,''),el=$E('.news dt a[href="'+href+'"]');
		News.archive.getElements('dt .cur').removeClass('cur');
		News.archive.getNext().load('get-'+href);
		if(el)el.addClass('cur');
		smooth.toElement(smooth.anchor='news');
	});
	$try(Media.initialize);
	$try(News.initialize);
});