/*# AVOID COLLISIONS #*/
;if(window.jQuery) (function($){
/*# AVOID COLLISIONS #*/

$(document).ready(function() {

/* Page Scroll */
	function filterPath(string) {
	return string
		.replace(/^\//,'')
		.replace(/(index|default).[a-zA-Z]{3,4}$/,'')
		.replace(/\/$/,'');
	}
	var locationPath = filterPath(location.pathname);

	/* AL - When user clicks link with hash start at top then scroll down to position */
/*	$('html, body').scrollTop(0);	
	var $target = $(location.hash), target = location.hash;
	if (target) {
		var targetOffset = $target.offset().top;
		//event.preventDefault();
		$('html, body').animate({scrollTop: targetOffset}, 3000, 'easeInOutCubic');
	}
*/	
	/* Assign onclick functions to all internal document hash links */
	$('a[href*=#]').each(function() {
		var thisPath = filterPath(this.pathname) || locationPath;
		if (  locationPath == thisPath
		&& (location.hostname == this.hostname || !this.hostname)
		&& this.hash.replace(/#/,'') ) {
			var $target = $(this.hash), target = this.hash;
			if (target) {
				var targetOffset = $target.offset().top;
				$(this).click(function(event) {
					event.preventDefault();
					$('html, body').animate({scrollTop: targetOffset}, 1200, 'easeInOutCubic', function() {
						location.hash = target;
					});
				});
			}
		}
	});
	
	/* Add CSS Class to Even Table Rows */
	$(function(){
		$("table.search-results").each(function() {
			$(this).find("tbody tr:odd").addClass("even");
		});
	});

	$("#vehicle-treeview").treeview({
		animated: "fast",
		collapsed: true,
		unique: true
	});
	
});

/*# AVOID COLLISIONS #*/
})(jQuery);
/*# AVOID COLLISIONS #*/
