//executes function when document has finished loading
$(document).ready(function(){
	//find each leftNavigation group class item and execute a function
	$('#leftNavigation .leftNavigationGroup').each(function(e){
	
		//set parentDiv equal to the div returned in the search above
		var parentDiv = this;
		
		//if the parentDiv has an h2 with an anchor, assign an onclick function to the anchor
		$(parentDiv).find('h2 a').click(function(){
		
			//see if there are any divs within the parentDiv that have the 'expanded' class
			if ($(parentDiv).filter('.expanded').get(0)) {
			
				//run animation on the div inside the parentDiv that has a class 'subNavigation'
				$(parentDiv).find('.subNavigation').slideUp('fast');
				
				//remove the 'expanded' class and add the 'collapsed' class to toggle the display
				$(parentDiv).filter('.expanded').removeClass('expanded').addClass('collapsed');
				
				//exit function
				return false;
				
			//otherwise execute as if the function is collapsed
			} else {
			
				//remove the 'collapsed' class and add the 'expanded' class to toggle the display
				$(parentDiv).filter('.collapsed').removeClass('collapsed').addClass('expanded');
				
				//run animation on the div inside the parentDiv that have the 'subNavigation' class
				$(parentDiv).find('.subNavigation').slideDown('fast');
				
				//exit function
				return false;
			}
		});
	});
	
	//set all tr elements within the tbody element to add the class 'mouseOver' when the mouse hovers over the element except for specified classes
	$('table')
		.not('.formTable')
		.not('.priceList')
		.not('.notesAndComments')
		.find('tbody tr')
		.mouseover(function(){ $(this).addClass('mouseOver'); });
	
	//remove the 'mouseOver' class from the tr element when the mouse leaves
	$('table')
		.not('.formTable')
		.not('.priceList')
		.not('.notesAndComments')
		.find('tbody tr')
		.mouseout(function(){ $(this).removeClass('mouseOver'); });
	
	//create a rollover state for all input type images.  will retrieve the src and replace '_off.gif' with '_on.gif'
	$("//input[@type='image']").each(function(i){
		if (document.getAttribute) return false;
		
		var original_src = this.getAttribute("src").substring( 0, this.getAttribute("src").indexOf("_off.gif") );
		
		$(this).mouseover(function(){ this.setAttribute("src", original_src + "_on.gif"); });
		$(this).mouseout(function(){ this.setAttribute("src", original_src + "_off.gif"); });
		
	});
	
	
});