var ext = '.png';

// used to test whether browser has images enabled
// basically, pick the smallest image your site uses, as it will be loaded twice: once for normal use, once for the test.
var testimg = '/_img/content/pdf.png';



function do_replace(hlev) {
	if (hlev == 1 || hlev == 4) {
		$('h'+hlev+'.replace_with').removeClass('replace_with').each(function() {
			$(this).replaceWith('<img class="replaced h'+hlev+'" src="/_img/headings/h'+hlev+'/' + $(this).attr('class') + ext + '" />' +
								'<div class="heading_underline">&nbsp;</div>');
		});		
	} else {
		$('h'+hlev+'.replace_with').removeClass('replace_with').each(function() {
			$(this).replaceWith('<img class="replaced h'+hlev+'" src="/_img/headings/h'+hlev+'/' + $(this).attr('class') + ext + '" />');
		});		
	}
}

$(document).ready(function() {
	// Only perform image replacement if user has images enabled
	$('<img src="' + testimg + '#' + Math.random() + '"/>').load(function() {
		for (var i = 1; i <= 6; i++) {
			do_replace(i);
		}				  
	});
	
	$('#nav div.nav1').hover(
		function() {
			$('#nav ul:not(.' + $(this).attr('id') + ')').hide(150);		
			$('#nav ul.' + $(this).attr('id')).show(150);
		}
		,
		function() {
			//$('#nav ul').hide(150);			
		}
	);
});
