        /* 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/smartnav/store/catalog.html',dn,'Catalog','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/store/accessories.html',dn,'Accessories','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/cart/editcart.html',dn,'Adjust Shopping Cart','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/corporate/dealers.html',dn,'Authorized Dealers','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/products/trade.html',dn,'Trade In / Trade Up','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/support/onlinestorehelp.html',dn,'Online Store Help','');biend();
                enddiv();

                dn = 'products';startdiv(dn ,'160');
                  bistart('http://www.naturalpoint.com/smartnav/products/about.html',dn,'About SmartNav','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/products/4-at/',dn,'<b>SmartNav 4:AT</b> &nbsp;&raquo;<br />Assistive Technology','sub_products_4at');
                    dnsub = 'sub_products_4at';startdivsub(dnsub,'140');
                      bisub('http://www.naturalpoint.com/smartnav/products/4-at/',dnsub,'Overview','sub_products_4at_overview');
                      bisub('http://www.naturalpoint.com/smartnav/products/4-at/inthebox.html',dnsub,'In the Box','sub_products_4at_inthebox');
                      bisub('http://www.naturalpoint.com/smartnav/products/4-at/photos.html',dnsub,'Product Photos','sub_products_4at_photos');
                      bisub('http://www.naturalpoint.com/smartnav/support/dwellclick.html',dnsub,'Dwell Clicking FAQ','sub_products_4at_dwellclick');
                      bisub('http://www.naturalpoint.com/smartnav/products/software.html',dnsub,'Software','sub_products_4at_software');
                    enddivsub();
                  biend();
                  bistart('http://www.naturalpoint.com/smartnav/products/4-eg/',dn,'<b>SmartNav 4:EG</b> &nbsp;&raquo;<br />Ergonomics','sub_products_4eg');
                    dnsub = 'sub_products_4eg';startdivsub(dnsub,'140');
                      bisub('http://www.naturalpoint.com/smartnav/products/4-eg/',dnsub,'Overview','sub_products_4eg_overview');
                      bisub('http://www.naturalpoint.com/smartnav/products/4-eg/inthebox.html',dnsub,'In the Box','sub_products_4eg_inthebox');
                      bisub('http://www.naturalpoint.com/smartnav/products/4-eg/photos.html',dnsub,'Product Photos','sub_products_4eg_photos');
                      bisub('http://www.naturalpoint.com/smartnav/products/software.html',dnsub,'Software','sub_products_4eg_software');
                    enddivsub();
                  biend();
                  bistart('http://www.naturalpoint.com/smartnav/products/compare.html',dn,'<b>Compare</b> &nbsp;&raquo;','sub_products_compare');
                    dnsub = 'sub_products_compare';startdivsub(dnsub,'140');
                      bisub('http://www.naturalpoint.com/smartnav/products/compare.html',dnsub,'SmartNav 4 Feature Comparison','sub_products_compare_snav');
                      bisub('http://www.naturalpoint.com/smartnav/products/older-model-comparison.html',dnsub,'Older Model Comparison','sub_products_compare_older');
                      bisub('http://www.naturalpoint.com/smartnav/products/competitors.html',dnsub,'Competitor Breakdown','sub_products_compare_comp');
                    enddivsub();
                  biend();
                  bistart('http://www.naturalpoint.com/smartnav/store/accessories.html',dn,'Accessories','');biend();
                  biend();
                  bistart('http://www.naturalpoint.com/smartnav/products/3-at/',dn,'Retired Products &nbsp;&raquo;','sub_products_retired');
                    dnsub = 'sub_products_retired';startdivsub(dnsub,'140');
                      bisub('http://www.naturalpoint.com/smartnav/products/3-at/',dnsub,'SmartNav 3:AT','sub_products_retired_3at');
                      bisub('http://www.naturalpoint.com/smartnav/products/3-eg/',dnsub,'SmartNav 3:EG','sub_products_retired_3eg');
                      bisub('http://www.naturalpoint.com/smartnav/products/3-standard/',dnsub,'SmartNav 3:Standard','sub_products_retired_3basic');
                    enddivsub();
                  biend();
                  bistart('http://www.naturalpoint.com/smartnav/products/mac.html',dn,'Mac Users','');biend();
                  /*
                  bistart('http://www.naturalpoint.com/smartnav/products/3-at/',dn,'::&nbsp; SmartNav 3:AT &nbsp;&raquo;','sub_products_3at');
                    dnsub = 'sub_products_3at';startdivsub(dnsub,'140');
                      bisub('http://www.naturalpoint.com/smartnav/products/3-at/',dnsub,'Overview','sub_products_3at_overview');
                      bisub('http://www.naturalpoint.com/smartnav/support/dwellclick.html',dnsub,'Dwell Clicking FAQ','sub_products_3at_dwellclick');
                      bisub('http://www.naturalpoint.com/smartnav/products/howitworks.html',dnsub,'How It Works','sub_products_3at_howitworks');
                      bisub('http://www.naturalpoint.com/smartnav/products/software.html',dnsub,'Software','sub_products_3at_software');
                      bisub('http://www.naturalpoint.com/smartnav/products/3-at/inthebox.html',dnsub,'In the Box','sub_products_3at_inthebox');
                      bisub('http://www.naturalpoint.com/smartnav/products/3-at/accessories.html',dnsub,'Accessories','sub_products_3at_accessories');
                      bisub('http://www.naturalpoint.com/smartnav/products/videos.html',dnsub,'Videos','sub_products_3at_videos');
                      bisub('http://www.naturalpoint.com/smartnav/products/testimonials/all-testimonials.html',dnsub,'Testimonials','sub_products_3at_testimonials');
                    enddivsub();
                  biend();
                  bistart('http://www.naturalpoint.com/smartnav/products/3-eg/',dn,'::&nbsp; SmartNav 3:EG &nbsp;&raquo;','sub_products_3eg');
                    dnsub = 'sub_products_3eg';startdivsub(dnsub,'140');
                      bisub('http://www.naturalpoint.com/smartnav/products/3-eg/',dnsub,'Overview','sub_products_3eg_overview');
                      bisub('http://www.naturalpoint.com/smartnav/products/howitworks.html',dnsub,'How It Works','sub_products_3eg_howitworks');
                      bisub('http://www.naturalpoint.com/smartnav/products/software.html',dnsub,'Software','sub_products_3eg_software');
                      bisub('http://www.naturalpoint.com/smartnav/products/3-eg/inthebox.html',dnsub,'In the Box','sub_products_3eg_inthebox');
                      bisub('http://www.naturalpoint.com/smartnav/products/3-eg/accessories.html',dnsub,'Accessories','sub_products_3eg_accessories');
                      bisub('http://www.naturalpoint.com/smartnav/products/videos.html',dnsub,'Videos','sub_products_3eg_videos');
                      bisub('http://www.naturalpoint.com/smartnav/products/testimonials/all-testimonials.html',dnsub,'Testimonials','sub_products_3eg_testimonials');
                    enddivsub();
                  biend();
                  bistart('http://www.naturalpoint.com/smartnav/products/3-standard/',dn,'::&nbsp; SmartNav 3:Standard &nbsp;&raquo;','sub_products_3basic');
                    dnsub = 'sub_products_3basic';startdivsub(dnsub,'140');
                      bisub('http://www.naturalpoint.com/smartnav/products/3-standard/',dnsub,'Overview','sub_products_3basic_overview');
                      bisub('http://www.naturalpoint.com/smartnav/products/howitworks.html',dnsub,'How It Works','sub_products_3basic_howitworks');
                      bisub('http://www.naturalpoint.com/smartnav/products/software.html',dnsub,'Software','sub_products_3basic_software');
                      bisub('http://www.naturalpoint.com/smartnav/products/3-standard/inthebox.html',dnsub,'In the Box','sub_products_3basic_inthebox');
                      bisub('http://www.naturalpoint.com/smartnav/products/3-standard/accessories.html',dnsub,'Accessories','sub_products_3basic_accessories');
                      bisub('http://www.naturalpoint.com/smartnav/products/videos.html',dnsub,'Videos','sub_products_3basic_videos');
                      bisub('http://www.naturalpoint.com/smartnav/products/testimonials/all-testimonials.html',dnsub,'Testimonials','sub_products_3basic_testimonials');
                    enddivsub();
                  biend();
                  */
                enddiv();

                dn = 'community';startdiv(dn,'160');
                  bistart('http://www.naturalpoint.com/smartnav/community/welcome.html',dn,'Welcome!','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/community/democenters.html',dn,'Demo Centers','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/products/videos.html',dn,'Video Gallery','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/products/testimonials/all-testimonials.html',dn,'Testimonials &amp; Reviews','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/community/forums.html',dn,'Forums','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/community/newsletter.html',dn,'Newsletter','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/products/gaming.html',dn,'PC Gaming','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/community/events.html',dn,'SmartNav Events','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/community/resources.html',dn,'<b>FAQs &amp; Resources</b> &nbsp;&raquo;','sub_community_resources');
                    dnsub = 'sub_community_resources';startdivsub(dnsub,'140');
                      bisub('http://www.naturalpoint.com/smartnav/community/cts-faq.html',dn,'Carpal Tunnel FAQ','sub_community_resources_carpal');
                      bisub('http://www.naturalpoint.com/smartnav/community/rsi-faq.html',dn,'RSI FAQ','sub_community_resources_rsi');
                      bisub('http://www.naturalpoint.com/smartnav/community/resources.html',dnsub,'Useful Resources','sub_community_resources_medicare');
                      bisub('http://www.naturalpoint.com/smartnav/community/medicare.html',dnsub,'Medicare Reimbursement','sub_community_resources_medicare');
                      /* bisub('http://www.naturalpoint.com/smartnav/community/resources.html#vpat',dnsub,'Voluntary Product Accessibility Template','sub_community_resources_vpat'); */
                    enddivsub();
                  bistart('http://www.naturalpoint.com/smartnav/community/survey-intro.html',dn,'Satisfaction Survey','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/support/translate-software.html',dn,'Translate Software','');biend();
                enddiv();

                dn = 'support';startdiv(dn,'160');
                  bistart('http://www.naturalpoint.com/smartnav/support/overview.html',dn,'Overview','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/support/downloads.html',dn,'Downloads','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/support/getting-started.html',dn,'Getting Started Guide','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/support/manual/sn-index.html',dn,'Manual','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/support/dwellclick.html',dn,'Dwell Clicking Tutorial','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/support/onlinestorehelp.html',dn,'Online Store Help','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/support/troubleshooting.html',dn,'Troubleshooting','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/community/forums.html',dn,'Forums','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/support/returnpolicy.html',dn,'Return Policy','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/support/warranty.html',dn,'Warranty','');biend();
                enddiv();

                dn = 'corporate';startdiv(dn,'160');
                  bistart('http://www.naturalpoint.com/smartnav/corporate/aboutus.html',dn,'About NaturalPoint','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/support/contact/',dn,'Contact Us','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/corporate/employment-opportunities.html',dn,'Employment Opportunities','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/corporate/mediakit.html',dn,'Media Kit','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/corporate/pressreleases.html',dn,'Press Releases','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/corporate/dealers.html',dn,'Authorized Dealers','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/corporate/privacy.html',dn,'Privacy Policy','');biend();
                  bistart('http://www.naturalpoint.com/smartnav/corporate/termsofuse.html',dn,'Terms of Use','');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='#F0F0F0';setDD(div,'',true);
	}
	function imgovr(div){
	}
	function menuout(div, item){
		setDDTimeout(div);item.style.backgroundColor='#ecf3ff';
		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('community','','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_products_compare').style.visibility = "hidden";
        document.getElementById('sub_products_4at').style.visibility = "hidden";
        document.getElementById('sub_products_4eg').style.visibility = "hidden";
        document.getElementById('sub_products_retired').style.visibility = "hidden";
        //document.getElementById('sub_products_3at').style.visibility = "hidden";
        //document.getElementById('sub_products_3eg').style.visibility = "hidden";
        //document.getElementById('sub_products_3basic').style.visibility = "hidden";
        //document.getElementById('sub_products_accessories').style.visibility = "hidden";
        document.getElementById('sub_community_resources').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=\'#DDDDDD\'\" onMouseOut=\"this.style.backgroundColor=\'#F0F0F0\';\" bgcolor=\"#ecf3ff\" onClick=\"lnk('"+link+"');\" > \
                                         <a class=\"navmenutext\" HREF=\""+link+"\">"+name+"</a></td></tr>");
	}

        // ==================================  END SUB MENU FUNCTIONS ======================================


