(function(){
	var	dl = document.getElementById('comments-block'),
		dts = dl && dl.getElementsByTagName('dt'),
		l = dts && dts.length;

	if( l < 20 ) return;

	// General link
	dl.parentNode.style.position = 'relative';
	
	var showall = amf_link('Show All');
	showall.id = 'show-all';
	showall.onclick = function(){
		dl.className = dl.className ? '' : 'js_collapse';
		amf_toggle_text( this, 'Show All', 'Revert' );
		this.blur();
		return false;
	};
	dl.parentNode.insertBefore( showall, dl );

	// Show/Hide links
	
	dl.className = 'js_collapse';

	function t(){
		amf_toggle_text( this, 'show', 'hide' );
		
		var dd = amf_next( this.parentNode, 'dd' );
		amf_toggle( dd );
		amf_toggle( amf_next(dd,'dd') );
		
		this.blur();
		return false;
	};

	var showhide = amf_link('show');
	showhide.className = 'show-hide';

	while( l-- )
		dts[l].appendChild( showhide.cloneNode(true) ).onclick = t;
})();

(function(){
	var debug = location.search == '?debug',
		SCROLLTO = '2009/05/jqueryscrollto-142-released',
		SERIALSCROLL = '2008/04/doctorate-on-jqueryserialscroll',
		LOCALSCROLL = '2009/03/jquerylocalscroll-127-released';
		
	
	var page = location.pathname.split('/').pop().slice(0,-5);
	var mapping = {
		'jqueryserialscroll'   : SERIALSCROLL,
		'jqueryserialscroll-110': SERIALSCROLL,
		//'doctorate-on-jqueryserialscroll':SERIALSCROLL,
		'jqueryscrollto'       : SCROLLTO,
		'jqueryscrollto-14-released': SCROLLTO,
		'jquerylocalscroll-10' : LOCALSCROLL,
		'jquerylocalscroll-12' : LOCALSCROLL
	};
	
	if( !page || !mapping[page] )
		return;
	
	page = location.protocol + '//' + location.host + '/' + mapping[page] + '.html';
	
	var	dl = document.getElementById('comments-block'),
		p = amf_next(dl,'p'),
		link = amf_first( p, 'a' );	
	
	if( link ){
		link.href = page + '#comments'
		link.onclick = function(e){
			alert('This post has too many comments. You will now be redirected to\n' + page);
		};
	}
})();

/*
(function(){
	var links = document.getElementsByTagName('a'),
		l = links.length;
	
	function noclick(e){
		if( e )
				e.preventDefault();
		else
			e.returnValue = false;
		alert('sorry, this demo is unavailable, will be back soon!');
	}
	
	while( l-- ){
		var link = links[l];
		if( link.href.indexOf('flesler.com') != -1 ){
			link.onclick = noclick;
			link.innerHTML = '<del>' + link.innerHTML + '</del>';
		}
	}
})();
*/