/*
  generic dd menu handler
  must include fnDDMenu function elsewhere
*/

/*
  ddsmooth vertical tabs

  function setVTab(tabId,index){
//alert ("index.js setVTab "+index);
		$(tabId+" #t"+index).trigger("click");
	}
*/

  $(document).ready(function() {
$.log("tjDDMenu.js .ready 15");
    $.fn.reverse = [].reverse; // add reverse

    /* menu watcher builds selection chain
      tjDDMenu.php builds menu so ul holds class
    */
    $("#mainMenu a").click(function() {
$.log("tjDDMenu.js",this);
      var sItem=$(this).html().replace(/ /gi,"_");
      var p=$(this).parents("ul").reverse();			
			var href=$(this).attr("href");
      var sLoc="";
      var iLast=0;
			
      $(p).each(function(i) {
        c=$(this).attr("rel");
        if (c) {
          sLoc+="m"+i+"="+c+"&";
          iLast=i;
        }
      });
      iLast++;
      s=sItem.split("<"); // menu images and such
      sLoc+="m"+iLast+"="+s[0];     

$.log (">> tjDDMenu.js 39:"+sLoc+" /href: "+href);

			if (href==undefined) {
				href=true;
			}
      fnDDMenu(sLoc,href); // process the menu choice
      return false; // cancel default
    });
$.log("exit .ready 15");

  });
