﻿$(document).ready(function() {

	// preload all images

	$.preloadImages(

		"images/button_blog.gif",

		"images/button_blog_over.gif",

		"images/button_contact_us.gif",

		"images/button_contact_us_over.gif",

		"images/button_directions.gif",

		"images/button_directions_over.gif",

		"images/button_downloads.gif",

		"images/button_downloads_over.gif",

		"images/button_free_offers.gif",

		"images/button_free_offers_over.gif",

		"images/button_home.gif",

		"images/button_home_over.gif",

		"images/button_our_attorneys.gif",

		"images/button_our_attorneys_over.gif",

		"images/button_our_staff.gif",

		"images/button_our_staff_over.gif",

		"images/button_practice_areas.gif",

		"images/button_practice_areas_over.gif",

		"images/button_site_map.gif",

		"images/button_site_map_over.gif"

	);



	// setup menu button over image swaps

	$("img.menu_button").each(function() {

		$(this).mouseover(function() {

			var imageSource = $(this).attr("src");

			imageSource = imageSource.replace(".gif", "_over.gif");

			$(this).attr("src", imageSource);

		});

		$(this).mouseout(function() {

			var imageSource = $(this).attr("src");

			imageSource = imageSource.replace("_over.gif", ".gif");

			$(this).attr("src", imageSource);

		});

	});

	// get a URI object
	var uri = new Object();
	getURL(uri);
	
	// make sure that we've got a value for url.file; if not, default to index.html
	var fileName = uri.file;
	if (fileName == "") fileName = "index.html";
	
	// get a reference to the element that contains the anchor tag
	$("#menu ul li a[href*='" + fileName + "']").addClass("selected");

});



// extend jquery with function to preload images

jQuery.preloadImages = function() {

	for (var i = 0; i < arguments.length; i++) {

		jQuery("<img>").attr("src", arguments[i]);

	}

}


