// JavaScript Document
// This script animates a tree menu structure using the jQuery "blind" ui function.  It is dependent on a nameing convention used in the div structure of the html.  Specifically, the link 
// selected will then display the div named "link name"+"menu".  It also assumes three levels and uses div classes of submenu and projlist to distinguish levels.  Also, classes: tier1, tier2,
// tier3 are used to identify the links at the different levels.  This allows us to reset the "current" link as new links are selected in the tree.  The currentMenu array is 
// a global array defined in the html page that lists the current menu state for the end node pages so when they load, the current state of the menu can be displayed.

jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	 {
		 $("<img>").attr("src", arguments[i]);
	 }
}

jQuery(document).ready(function(){

	//If there is a current menu state, set the current menu items
		if (currentitem!=null) {
			$(currentitem).addClass("current");
		}
			
	//Because we have two main menus, if portfolio is selected, hide the company menu then show the portfolio menu.
	//If Company is selected, hide all layers of the portfolio menu then show the company menu.
	jQuery("#portfolio").click(function() {
			jQuery("#companymenu").hide();
			jQuery(".tier1").removeClass("current");
			jQuery("#advanta").addClass("current");
			jQuery("#portfoliomenu").show("blind", { direction: "vertical" }, 1250, function(){ 
        		window.location = "ncadvanta.php"; //After the menu is done animating, go to the automatically selected link.
			}); 
	});
    jQuery("#company").click(function() {
			jQuery("#portfoliomenu").hide();
			jQuery(".tier1").removeClass("current");
			jQuery("#aboutus").addClass("current");
			jQuery("#companymenu").show("blind", { direction: "vertical" }, 800, function(){ 
        		window.location = "aboutus.php"; //After the menu is done animating, go to the automatically selected link.
			}); 
	});
	//The routine below swaps the thumb image with the large image.  It is based on a naming convention where the thumb version of each //image is "image name" + "tmb"
	jQuery(".thumbs a").click(function () {
		var clicked=jQuery(this).find("img").attr('src');
		var inmain=jQuery("#lgimage").attr('src');
		var newthumb=inmain.replace(".jpg","tmb.jpg");
		var newmain=clicked.replace("tmb.jpg",".jpg");
		jQuery(this).find("img").attr("src", newthumb);
		jQuery("#lgimage").attr("src", newmain);
	});
});

	
