$(document).ready(function() {
	
	// CONVERT ALT TAGS TO CAPTIONS FOR INLINE IMAGES
	// MUST BE IN WINDOW.LOAD EVENT TO ENSURE IMAGES ARE LOADED FIRST IN ORDER TO CALCULATE WIDTH FOR MOZILLA
	$(window).load(function() {
		$("#main-content img.inline").each(function() {
			var imgwidth = $(this).width();
			var caption = $(this).attr("alt");
			var imgfloat = $(this).attr("class").replace("inline ", "");
			$(this).removeClass("left, right");
			$(this).wrap("<div class='img-container' style='float:"+imgfloat+";width:"+imgwidth+"px;' />").after("<p class='caption'>" + caption + "</p>");
		});
	});		
	
	// NAV DROP DOWNS
//	$("#nav li ul").hide();
//	$("#nav li").hover(function() {
//		$(this).stop().find("ul").slideDown("fast");					
//	}, function() {
//		$(this).stop().find("ul").slideUp("fast");
//	});
	
	// CLEAR FLOAT FIXES
	var clearfix = "<div class='clear'></div>";
	$("#main-content").after(clearfix);
	$("#locations").append(clearfix);
	$("#locations").after(clearfix);
	
	$("#rotating-facts p").hide();
	
	var randomtip = function() {
		var length = $("#rotating-facts p").length;
		var ran = Math.floor(Math.random()*length) + 1;
		$("#rotating-facts p:nth-child(" + ran + ")").show();
	}
	
	randomtip();
	
	$("#rotating-services div.featured-info").hide();
	
	var randomservice = function() {
		var length = $("#rotating-services div.featured-info").length;
		var ran = Math.floor(Math.random()*length) + 1;
		$("#rotating-services div.featured-info:nth-child(" + ran + ")").show();
	}
	
	randomservice();
	
	$("#gallery div.rotating-ad").hide();
	
	var randomad = function() {
		var length = $("#gallery div.rotating-ad").length;
		var ran = Math.floor(Math.random()*length) + 1;
		$("#gallery div.rotating-ad:nth-child(" + ran + ")").show();
	}
	
	randomad();
		
});
