if (typeof modelNavData != "undefined") {

	// Create drop-down menus

	$('#carline ul.model_list').each(function() {

		var $$ = $(this);

		var carline = $$.parents('li').attr('id');

		$$.children('li').each(function() {

			var $$ = $(this);

			var model = $$.attr('id');

			var menuContent = modelNavData[carline][model];

			if (menuContent) {

				// Insert content into menu table cell

				$$.find('tr.model_menu_content td.center').html(menuContent);

			}

		});

	});

}



$(function() {



	// Initialize model bar rollover graphics

	$('#carline > li > a > img').each(function() {

		var loSrc = this.src;

		var hiSrc = loSrc.replace(/\/low/, "/high");

		createGraphicLink(this, loSrc, hiSrc);	

	});



	// Highlight model bar items on hover

	$('#carline > li').hover(

		function() {

			var $$ = $(this);

			var modelImg = $$.find("img").get(0);

			/* showModelHilite() contains an aoa-specific callback hook,

			   so we must keep using it */

			showModelHilite(modelImg.alt, modelImg);

			$$.children("ul").show();

		},

		function() {

			var $$ = $(this);

			resetLinkHilite($$.find("img").get(0));

			$$.children("ul").hide();

		}

	);



	// Show drop-down menu for model items

	$('#carline ul.model_list > li').hover(

		function() {

			var $$ = $(this);

			if (!this.pngFixed) {

				// Fix PNG transparency in IE6

				$$.find('tr.model_menu_head tr.bottom, tr.model_menu_content, tr.model_menu_foot').pngFix();

				this.pngFixed = true;

			}

			$$.find('table.model_menu').show();

		},

		function() {

			$(this).find('table.model_menu').hide();

		}

	);



	// Hide the drop-down menu when entering the top right cell,

	// as it covers the model to the right of the current one

     $('#carline tr.model_menu_head tr.top td:last-child').mouseover(function() {

         $(this).parents('table.model_menu').hide();

     });



});