$('.code').each(function(e){
	var decoded = $(this).text($(this).html()).html();

	// remove if first thing is newline
	decoded = decoded.replace(/^[\n]/, '');

	// match element = value
 	decoded = decoded.replace(/([a-z\.\"]+)=("|')(.*?)("|')/ig,"<span class=\"red\">$1</span>=$2<span class=\"orange\">$3</span>$4");    

	// mach tags
 	decoded = decoded.replace(/&lt;(.*?)&gt;/ig,"&lt;<span class=\"blue\">$1</span>&gt;");    

	// wrap in pre element
	$(this).wrap('<pre>');

	//change html
	$(this).html(decoded); 
});

/* images */
$('.tdImg').each(function(){
	 $(this).html('<img class="imgsmall" src="'+$(this).attr("rel")+'">');
});

// ajax funciton
$(".ajax").live("click", function(event) {
	if (this.rel != 'nofollow') {
		var updatediv = '-' + this.rel;
	} else {
		var updatediv = '-' + this.id;
	}
	$.get(this.href, {
		'tpl' : 'false'
	}, function(data) {
		$('#' + updatediv).html(data).hide().fadeIn('slow');
	});
	return false;
});


/*tabs*/
$('.tab').each(function(e){
	$(this).hide();
})
$('.tab:first').show();

$('#tabnav a').click(function(e){
	$('.tab').each(function(e){
		$(this).hide();
	})
	$('#'+$(this).attr('class')).show();

	
})

$('.tabnavlink').click(function(e){
	$('.tab').each(function(e){
		$(this).hide();
	})
	//alert($(this).attr('rel'));
	$('#'+$(this).attr('rel')).show();

	
})
