// Preload images with jQuery (the function);
jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		path_to_images = "img/tnav/";
		jQuery("<img>").attr("src", path_to_images + arguments[i]);
	}
}

$(document).ready(function() {
	// Preload images;
	$.preloadImages(
		'about_us.jpg',
		'about_us2.jpg',
		'product_line.jpg',
		'product_line2.jpg',
		'octal_advantages.jpg',
		'octal_advantages2.jpg',
		'env_advantages.jpg',
		'env_advantages2.jpg',
		'press_room.jpg',
		'press_room2.jpg',
		'contact.jpg',
		'contact2.jpg'
	);
	
	
	// Remove all 'nojs' classes (in other words, the user's browser supports JS);
	$("li.drop, li.nodrop").removeClass("nojs");
	
	// Deal with the hover menus + effect;
	$(".drop, .nodrop").hover
	(
		function() {
			/*if ($(this).attr("id") !== parentmenuid)
			{*/
				// Slide down;
				$("ul", this).slideDown("fast");
				
				// Change the src for the parent;
				$("img", this).eq(0).attr("src", $("img", this).eq(0).attr("src").replace(".jpg", "2.jpg"));
				
			/*}*/
		},
		function() {
			/*if ($(this).attr("id") !== parentmenuid)
			{*/
				// Slide down;
				$("ul", this).slideUp("fast");

				// Change the src for the parent;
				$("img", this).eq(0).attr("src", $("img", this).eq(0).attr("src").replace("2.jpg", ".jpg"));
			/*}*/
		}
	);
	

	// FAQ.htm
	//------------------
	// Hide all answers;
	$(".answer").hide();
	
	// Show the right answer upon click (on the question);
	$('.question').click
	(
		function()
		{
			$(this).parent().find('p').slideToggle('fast');
		}
	);
	
});
