$(document).ready(function(){
	
	$("input[name='oohmun']").remove();
	
	$("img.popup").each(function(){
		
		var href = $(this).attr("src").replace('/lores/','/hires/');
		var title = $(this).attr("alt");
		$(this).wrap("<a></a>")
			.parent("a")
				.attr("href",href)
				.attr("title",title)
				.attr("rel","inpage")
				.addClass("thickbox")	
	});
	
	$("h2, p, a, li").each(function(){
		$(this).html($(this).html().replace(/&amp;/g,'<em class="amp">&amp;</em>'))
	});
	
	$(":header, li.current, #menu li a").each(function(){
		var el = $(this);
		if(el.html()=='Our Home Page') el.html("Our <em>Home</em> Page");
		if(el.html()=='Learn About It') el.html("Learn <em>About</em> It");
		if(el.html()=='Customer Login') el.html("Customer <em>Login</em>");
	});
	
	$("ul.gallery li a, ul.sidegallery li a").each(function(){
		$tit = $("img", this).attr("alt");
		$(this)
			.prepend("<p>" + $tit + "</p>")
	})
	
	$("img[@src$=png], ul.gallery p, ul.sidegallery p,#head, #foot, #footwrapper, li.current a").pngfix();
			  
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});

	$("li.photo a").addClass("thickbox").attr("rel","galleryimg");
	
	//makes nav bar items (LIs) clickable, rather than just the contained anchors.
	var navigating = false; //flag used when document.location has changed, to handle nested stuff
	$("#page_submenu li, .dropdown li > ul > li, .dropdown li > ul > li.parent > ul > li, #news ul li, .news-archive ul li, .news ul li, #sub-menu ul li").click(function() {
		if (!navigating) { //only allow this to be executed once, clicks on li's within li > ul would be picked up twice otherwise
			document.location = $(this).children("a")[0].href; //navigate to page
			navigating=true; //update flag
		}
	});
	
});