$(document).ready(function(){
	// print link
	$('#content .entry-xtras .print').show().click(function(ev){
		ev.preventDefault();
		window.print();
	});

	// cufon
	Cufon.replace('h1', { fontFamily: 'Aller' });
	Cufon.replace('h2', { fontFamily: 'Aller' });

	// history.back links
	$('a[rev="referer"]').click(function(ev){
		ev.preventDefault();
		this.onclick = history.back();
	});

	// go to top
	$('a[href="#top"]').click(function(ev){
		ev.preventDefault();
		$('html, body').animate({scrollTop:0}, 'slow');
	});
});

$.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form')
			return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
	});
};
