window.addEvent('domready',function() {
									
	var accordion = new Accordion($$('.toggler'),$$('.element'), {
		opacity: 0,
		onActive: function(toggler) { toggler.setStyle('color', '#ff3300'); },
		onBackground: function(toggler) { toggler.setStyle('color', '#000000'); }
	});
	
	//break out of frames
	if (top.location != self.location) {
		top.location = self.location;
	}
	
	$('gototop').set('opacity','0').setStyle('display','block');
	window.addEvent('scroll',function(e){
		$('gototop').fade((window.getScroll().y > 180) ? 'in' : 'out')
	});
	
	new SmoothScroll({duration:500});
	
	$$('#header ul li a').each(function(el){
		var opad = el.getStyle('padding-left').replace('px','').toInt();
		var fx = new Fx.Morph(el,{ duration:300, link:'cancel' });
		
		el.addEvents({
			mouseenter: function(){
				fx.start({
					'padding-left': (opad + 15).toInt()
				});
			},
			mouseleave: function(){
				fx.start({
					'padding-left': opad 
				});
			}
		});
	});
	
	$$('pre').set('name','code');
	dp.SyntaxHighlighter.ClipboardSwf = 'http://youngdutchdesign.com/wp-content/themes/ydd-1/syntaxhighlighter/clipboard.swf';
	dp.SyntaxHighlighter.HighlightAll('code');
	
	$$('.entry a[href^="http://"]').each(function(a) {
		/* if it's not on the davidwalsh.name domain */
		if(a.target && a.target.test(/^_blank/i)){
			var src = a.get('href').replace(/^(http:\/\/[^\/]+).*$/, '$1') + '/favicon.ico';
			var favicon = new Element('img', {'src': src, 'width': 16, 'heigth': 16, 'class': 'entry_favicon'});
			
			favicon.inject(a, 'before');
		}
	});
	
	/* grab all complete linked anchors */
	$$('#pingbacks a[href^="http://"]').each(function(a) {
		/* if it's not on the davidwalsh.name domain */
		if(!a.get('href').contains(window.location.host)) {
			/* get the favicon */
			var src = a.get('href').replace(/^(http:\/\/[^\/]+).*$/, '$1') + '/favicon.ico';
			
			var favicon = new Element('img', {'src': src, 'width': 16, 'heigth': 16});
			/* place it in the anchor */
			
			//a.setStyle('background-image','url(' + favicon + ')').addClass('favicon');
			
			favicon.inject(a, 'before');

		}
	});
	
	var rcolstart = $('rcol_content').getHeight();
	
	if($('content').getHeight() > $('rcol_div').getHeight()){
		$('rcol').set('styles', {
			'height': $('content').getHeight()
		});
	}

	$$('.entries').each(function(e){
		if(e.innerHTML == ''){
		   e.dispose();
		}
	});
	
	var vert = new cvNewsTicker('images',{speed:500,delay:8000,direction:'vertical'});
});