$(document).ready(function() {
  // 2 level nav.
    if($("ul#pageNav_sub1").css("display") != "block")
    {
      $("li.navColor1").click(function() {
          //$("ul#pageNav_sub1").css("display", "block"); //Show the Subnav
          $("ul#pageNav_sub1").show(); //Show the Subnav
          $(this).addClass("clicked"); //Show the Subnav
      });
      $("ul#pageNav li").hover(function() { //Hover over event on list item
        //$(this).find("ul#pageNav_sub1").show(); //Show the Subnav
        //Icon hover
        //var hoverImg = HoverImgOf($(this).attr("src"));
        //$("#icon").attr("src", hoverImg);
      } , function() { //on hover out...
        if(!$(this).hasClass("clicked"))
        {
          $(this).find("ul#pageNav_sub1").hide(); //Hide the Subnav
          //Icon hover
          //var normalImg = NormalImgOf($(this).attr("src"));
          //$("#icon").attr("src", normalImg);
        }
      });
    }

/*
  $("ul#pageNav li").click(function() { //Hover over event on list item
    $(this).find("ul#pageNav_sub1").hide(); //Show the Subnav
    //Icon hover
    //var hoverImg = HoverImgOf($(this).attr("src"));
    //$("#icon").attr("src", hoverImg);
  });
*/

  // 3 level nav.
  $("ul#pageNav_sub1 li").hover(function() { //Hover over event on list item
    $(this).find("ul#pageNav_sub2").show(); //Show the subnav
  } , function() { //on hover out...
    $(this).find("ul#pageNav_sub2").hide(); //Hide the Subnav
  });






/*
  //Change on top right icon
  function HoverImgOf(filename) {
     var re = new RegExp("(.+)\\.(gif|png|jpg)", "g");
     return filename.replace(re, "$1_hover.$2");
  }
  function NormalImgOf(filename) {
     var re = new RegExp("(.+)_hover\\.(gif|png|jpg)", "g");
     return filename.replace(re, "$1.$2");
  }
*/
});

