        /* Adding submenus :
             * Fill in the sub-menu name at the end of the main menu entry (last parameter)
             * Create the sub-menu using startdivsub/bisub/enddivsub using the same name
             * Add the sub-menu to the whideall() function using the same name

             * Note : A sub-menu must be enclosed within its parent main menu's bistart()/biend()
        */

	var agt=navigator.userAgent.toLowerCase();
	var is_safari = agt.indexOf("safari")!=-1;
	var click_processed = false;

	function getdropdowns(){

                dn = 'store';startdiv(dn,'160');
                  bistart('http://www.naturalpoint.com/trackir/01-store/store-catalog.html',dn,'Store Catalog','');biend();
                  bistart('http://www.naturalpoint.com/trackir/01-store/store-adjust-shopping-cart.html',dn,'Adjust Shopping Cart','');biend();
                  bistart('http://www.naturalpoint.com/trackir/01-store/store-international-dealers.html',dn,'Find a Store / Dealer','');biend();
                  bistart('http://www.naturalpoint.com/trackir/01-store/store-limited-warranty.html',dn,'Limited Warranty','');biend();
                  bistart('http://www.naturalpoint.com/trackir/01-store/store-return-policy.html',dn,'Return Policy','');biend();
                  bistart('http://www.naturalpoint.com/trackir/06-support/support-online-store-help.html',dn,'Online Store Help','');biend();
                enddiv();

                dn = 'products';startdiv(dn ,'160');
                  bistart('http://www.naturalpoint.com/trackir/products/trackir5/',dn,'TrackIR 5','');biend();
                  bistart('http://www.naturalpoint.com/trackir/02-products/product-TrackIR-4-PRO.html',dn,'TrackIR 4:PRO','');biend();
                  bistart('http://www.naturalpoint.com/trackir/02-products/product-TrackClip-PRO.html',dn,'TrackClip PRO','');biend();
                  bistart('http://www.naturalpoint.com/trackir/02-products/product-Vector-PRO.html',dn,'Vector PRO','');biend();
                  bistart('http://www.naturalpoint.com/trackir/02-products/product-accessories.html',dn,'Accessories &amp; Apparel','');biend();
                  bistart('http://www.naturalpoint.com/trackir/02-products/retired-products.html',dn,'Retired Products','');biend();
                  bistart('http://www.naturalpoint.com/trackir/02-products/trackir-product-comparison.html',dn,'TrackIR Product Comparison','');biend();
                  bistart('http://www.naturalpoint.com/trackir/02-products/product-how-TrackIR-works.html',dn,'How TrackIR Works','');biend();
                  bistart('http://www.naturalpoint.com/trackir/02-products/product-videos.html',dn,'Videos / Demos','');biend();
                  bistart('http://www.naturalpoint.com/trackir/02-products/product-reviews.html',dn,'Reviews &amp; Interviews','');biend();
                enddiv();

                dn = 'games';startdiv(dn,'160');
                  bistart('http://www.naturalpoint.com/trackir/03-enhanced-games/enhanced-games-all.html',dn,'All Enhanced Games','');biend();
                  bistart('http://www.naturalpoint.com/trackir/03-enhanced-games/enhanced-games-flight.html',dn,'All Flight Titles','');biend();
                  bistart('http://www.naturalpoint.com/trackir/03-enhanced-games/enhanced-games-racing.html',dn,'All Racing Titles','');biend();
                  bistart('http://www.naturalpoint.com/trackir/03-enhanced-games/enhanced-games-more.html',dn,'More Titles','');biend();
                  bistart('http://www.naturalpoint.com/trackir/03-enhanced-games/enhanced-games-all.html',dn,'<b>Hot Releases &nbsp;&raquo;</b>','sub_games_hot');
                    dnsub = 'sub_games_hot';startdivsub(dnsub,'140');
                      bisub('http://www.naturalpoint.com/trackir/03-enhanced-games/game-arma-2.html',dnsub,'ArmA 2','sub_games_coming_ar');
                      bisub('http://www.naturalpoint.com/trackir/03-enhanced-games/game-dcs-black-shark.html',dnsub,'DCS: Black Shark','sub_games_hot_bs');
                      bisub('http://www.naturalpoint.com/trackir/03-enhanced-games/game-colin-mcrae-dirt-2.html',dnsub,'DiRT 2','sub_games_hot_di');
                      bisub('http://www.naturalpoint.com/trackir/03-enhanced-games/game-flight-simulator-x.html',dnsub,'Flight Simulator X','sub_games_hot_fs');
                      bisub('http://www.naturalpoint.com/trackir/03-enhanced-games/game-grid.html',dnsub,'GRID','sub_games_hot_gr');
                      bisub('http://www.naturalpoint.com/trackir/03-enhanced-games/game-lock-on-flaming-cliffs-2.html',dnsub,'Lock On: Flaming Cliffs 2','sub_games_hot_lo');
                      bisub('http://www.naturalpoint.com/trackir/03-enhanced-games/game-rfactor.html',dnsub,'rFactor','sub_games_hot_rfa');
                      bisub('http://www.naturalpoint.com/trackir/03-enhanced-games/game-rise-of-flight.html',dnsub,'Rise of Flight','sub_games_hot_rfl');
                    enddivsub();
                  biend();
                  bistart('http://www.naturalpoint.com/trackir/03-enhanced-games/enhanced-games-all.html',dn,'<b>Coming Soon &nbsp;&raquo;</b>','sub_games_coming');
                    dnsub = 'sub_games_coming';startdivsub(dnsub,'140');
                      bisub('http://www.naturalpoint.com/trackir/03-enhanced-games/game-jumpgate-evolution.html',dnsub,'Jumpgate Evolution','sub_games_coming_jg');
                    enddivsub();
                  biend();
                enddiv();

                dn = 'community';startdiv(dn,'160');
                  bistart('http://www.naturalpoint.com/trackir/04-community/community-welcome.html',dn,'Website Updates!','');biend();
                  bistart('http://www.naturalpoint.com/trackir/04-community/community-newsletter.html',dn,'Newsletter','');biend();
                  bistart('http://www.naturalpoint.com/trackir/04-community/community-events.html',dn,'Events &amp; Tradeshows','');biend();
                  bistart('http://www.naturalpoint.com/trackir/04-community/community-naturalpoint-sponsored.html',dn,'Sponsored Events / Teams','');biend();
                  bistart('http://www.naturalpoint.com/trackir/04-community/community-testimonials.html',dn,'TrackIR Testimonials','');biend();
                  bistart('http://www.naturalpoint.com/trackir/02-products/product-videos.html',dn,'Videos / Demos','');biend();
                  bistart('http://www.naturalpoint.com/trackir/04-community/community-free-game-demos-and-utilities.html',dn,'Free Game Demos / Utilities','');biend();
                  bistart('http://www.naturalpoint.com/trackir/04-community/community-forum-entrance.html',dn,'Forum Entrance','');biend();
                enddiv();

                dn = 'developers';startdiv(dn,'160');
                  bistart('http://www.naturalpoint.com/trackir/05-developers/developers-pc-game-simulation-sdk.html',dn,'Game / Simulation SDK','');biend();
                  bistart('http://www.naturalpoint.com/trackir/05-developers/which-sdk.html',dn,'Get SDK','');biend();
                  bistart('http://www.naturalpoint.com/trackir/05-developers/developer-research.html',dn,'Research &amp; Development','');biend();
                enddiv();

                dn = 'support';startdiv(dn,'160');
                  bistart('http://www.naturalpoint.com/trackir/06-support/contact/',dn,'Contact Us','');biend();
                  bistart('http://www.naturalpoint.com/trackir/06-support/support-download-software-and-manuals.html',dn,'Download Software / Manuals','');biend();
                  bistart('http://www.naturalpoint.com/trackir/06-support/support-vector-expansion-help.html',dn,'Vector Expansion Support','');biend();
                  bistart('http://www.naturalpoint.com/trackir/06-support/support-frequently-asked-questions.html',dn,'Frequently Asked Questions','');biend();
                  bistart('http://www.naturalpoint.com/trackir/06-support/support-troubleshooting.html',dn,'Troubleshooting','');biend();
                  bistart('http://www.naturalpoint.com/trackir/06-support/support-translate-software.html',dn,'Translate TrackIR Software','');biend();
                  bistart('http://www.naturalpoint.com/trackir/06-support/support-online-store-help.html',dn,'Online Store Help','');biend();
                  bistart('http://forum.naturalpoint.com/ubbthreads.php?Cat=0&C=2',dn,'<b>Support Forums</b>','');biend();
                enddiv();

                dn = 'corporate';startdiv(dn,'160');
                  bistart('http://www.naturalpoint.com/trackir/07-company-info/company-about-NaturalPoint.html',dn,'About NaturalPoint','');biend();
                  bistart('http://www.naturalpoint.com/trackir/07-company-info/company-employment-opportunities.html',dn,'Employment','');biend();
                  bistart('http://www.naturalpoint.com/trackir/07-company-info/company-press-releases.html',dn,'Press Releases','');biend();
                  bistart('http://www.naturalpoint.com/trackir/07-company-info/company-media-kit.html',dn,'Media Kit','');biend();
                  bistart('http://www.naturalpoint.com/trackir/07-company-info/company-terms-of-use.html',dn,'Terms of Use','');biend();
                  bistart('http://www.naturalpoint.com/trackir/07-company-info/company-privacy-statement.html',dn,'Privacy Statement','');biend();
                enddiv();
	}

	function startdiv(idval,w){
		var s = document.write ('<div id="'+idval+'"><table width="'+w+'" border="0" cellpadding="0" cellspacing="0" class="mt">');
	}
	function enddiv(){
		var s = document.write ("</table></div>");
	}
	function bistart(link,div,name,subname)
        {
          // if the submenu name is not null, include javascript to invoke it, otherwise don't try
          if (subname != '')
          {
		var s = document.write ("<tr><td onClick=\"lnk('"+link+"');\"      \
                                                 onMouseOver=\"menuovr('"+div+"','"+pn(name)+"',this); whidesubs(); wshow('"+subname+"');\"       \
                                                 onMouseOut=\"menuout('"+div+"',this);\" class=\"nav2\">      \
                                                 <a class=\"navmenutext\" HREF=\""+link+"\">"+name+"</a>");
          }
          else
          {
		var s = document.write ("<tr><td onClick=\"lnk('"+link+"');\" onMouseOver=\"menuovr('"+div+"','"+pn(name)+"',this); whidesubs();\" onMouseOut=\"menuout('"+div+"',this);\" class=\"nav2\"><a class=\"navmenutext\" HREF=\""+link+"\">"+name+"</a>");
          }
	}

        function biend()
        {
            document.write ("</td></tr>");
        }


	function pn(name){
		var s=name;if(s.indexOf("<")>0) {return(s.slice(0,s.indexOf("<")-1));}return(s);
	}
	function lnk(link){
      // prevent parent menu item table cell onClick events from stealing the sub menu navigation onClick events
        if (click_processed == false)
        {
          internal_clicked = true;
          click_processed = true;
		  window.open(link,'_self');
        }
	}
	function mainovr(div,status){
		if(is_safari){
			bHover=status;window.status=status;setDD(div,status,false);}
		else{
			bHover=status;window.status=status;setTimeout('setDD(\'' + div + '\', \'' + status + '\', false)',0);}
		whidesubs();
	}
	function mainout(div){
		bHover='';window.status='';setDDTimeout(div);
	}
	function menuovr(div, link, item){
		window.status=link;item.style.backgroundColor='#00487e';setDD(div,'',true);
	}
	function imgovr(div){
	}
	function menuout(div, item){
		setDDTimeout(div);item.style.backgroundColor='#449ed2';
		whidesubs();
	}
	function findDiv(n, d) {
		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findDiv(n,d.layers[i].document);
	  if(!x && document.getElementById) x=document.getElementById(n); return x;
	}
	function tNav() {
		var i,p,v,obj,args=tNav.arguments;
	  for (i=0; i<(args.length-2); i+=3) if ((obj=findDiv(args[i]))!=null) { v=args[i+2];
	    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	    obj.visibility=v;
            }
	}
	function hideDDs(sect) {
		tNav('store','','hide');tNav('products','','hide');tNav('games','','hide');tNav('community','','hide');tNav('developers','','hide');tNav('support','','hide');tNav('corporate','','hide');showElement('SELECT');showElement('OBJECT');showElement('EMBED');
	}
	function hideDD(sect) {
		tNav(sect,'','hide');hideDDs(sect);
	}
	var secSet = null;
	var activeTimer = null;
	var bHover = '';
	var img = '';
	function setDD(sect, windowStatusVal, bshow) {
		hideDDs(sect);
		if ((bHover==windowStatusVal)||(bshow)){
			tNav(sect,'','show');
			if (secSet != null) window.clearTimeout(secSet);
//			hideElement('SELECT', document.all[sect]);
//			hideElement('OBJECT', document.all[sect]);
//			hideElement('EMBED', document.all[sect]);
		}
	}
	function setDDTimeout(sect){
		if (secSet != null) window.clearTimeout(secSet);
		secSet = window.setTimeout('hideDD("' + sect + '")',270);
	}

	function hideElement( elmID, overDiv ) {
	  if(document.all) {
	    for(i = 0; i < document.all.tags( elmID ).length; i++) {
	      obj = document.all.tags( elmID )[i];
	      if(!obj || !obj.offsetParent) continue;
	      // Find the element's offsetTop and offsetLeft relative to the BODY tag.
	      objLeft   = obj.offsetLeft - overDiv.offsetParent.offsetLeft;
	      objTop    = obj.offsetTop;
	      objParent = obj.offsetParent;
	      while(objParent.tagName.toUpperCase() != 'BODY') {
	        objLeft  += objParent.offsetLeft;
	        objTop   += objParent.offsetTop;
	        objParent = objParent.offsetParent;}
	      objHeight = obj.offsetHeight;
	      objWidth  = obj.offsetWidth;

	      if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft);
	      else if((overDiv.offsetParent.offsetTop + overDiv.offsetHeight + 20) <= objTop);
	      else if(overDiv.offsetParent.offsetTop >= eval(objTop + objHeight));
	      else if(overDiv.offsetLeft >= eval(objLeft + objWidth));
	      else {
	        obj.style.visibility = 'hidden';
	      }

	    }
	  }
	}

	function showElement(elmID) {
	  if(document.all) {
	    for(i = 0; i < document.all.tags( elmID ).length; i++) {
	      obj = document.all.tags(elmID)[i];
	      if(!obj || !obj.offsetParent) continue;
	      obj.style.visibility = '';
	    }
	  }
	}

        // ==================================  START SUB MENU FUNCTIONS ======================================

        //--------shows whichever menu popup is sent to it.
        function wshow(whichMenu)
        {
          // reset click processed here whenever a new menu is opened, just to make sure navigation can occur if it failed before
          click_processed = false;         
        document.getElementById(whichMenu).style.visibility = "visible";
        }

        //--------hides whichever menu popup is sent to it.
        function whide(whichMenu){
        document.getElementById(whichMenu).style.visibility = "hidden";
        }

        function whidesubs(){
        document.getElementById('sub_games_hot').style.visibility = "hidden";
        document.getElementById('sub_games_coming').style.visibility = "hidden";
        }

	function startdivsub(idval,w){
		var s = document.write ('<div id="'+idval+'"><table width="'+w+'" border="0" cellpadding="0" cellspacing="0" class="navsubposition">');
	}
	function enddivsub(){
		var s = document.write ("</table></div>");
	}
	function bisub(link,div,name,subname){
          var s = document.write ("<tr><td class=\"navsubmenuitem\" onMouseOver=\"this.style.backgroundColor=\'#00487e\'\" onMouseOut=\"this.style.backgroundColor=\'#449ed2\';\" bgcolor=\"#449ed2\" onClick=\"lnk('"+link+"');\" > \
                                         <a class=\"navmenutext\" HREF=\""+link+"\">"+name+"</a></td></tr>");
	}

        // ==================================  END SUB MENU FUNCTIONS ======================================

