//
//
// Copyright 2000-2001 SolidWorks Corporation.  All rights reserved.
//
// No part of these files may be reproduced or used outside of the 3D Instant Website product
// for any purpose, without the express written permission of SolidWorks Corporation.
//
//
//

if (document.all || document.getElementById) 
{
  document.write('<STYLE>');
  document.write('A.menu { color: black; text-decoration: none;'
                 + 'cursor: hand; width: 100%;}');
  document.write('A.menuOn { color: white; '
               + 'background-color: pink; text-decoration: none;');
  document.write(' cursor: hand; width: 100%; }');
  document.write('<\/STYLE>');
}

var Treecounter=1;
var GoId = "1";

if(top.ModelList)
     GoId = top.ModelList.selectedobj;

var treeName = "tree_" + GoId;

// Get the current tree state.
var TreeStatues=getTreeState();

function InitState(total,id)
{
  parent.stateArr[id] = new Array(total);
  for (var i = 1; i <= total; i++) 
  {
		 parent.stateArr[id][i] = 1; //show
  }
}

function changeState(modelId, partid)
{
  parent.stateArr[modelId][partid] = (parent.stateArr[modelId][partid])? 0 : 1;
}

function setHighlight(modelId, partid, tog)
{
  parent.stateArr[modelId][partid] = tog;
}

function getTreeState() 
{
	var myCookie = document.cookie;
	var pos = myCookie.indexOf(treeName + "=");
	if (pos != -1)
	{
		var endPos = myCookie.indexOf(";", pos);
  if (endPos == -1)
			return unescape(myCookie.substring(pos + treeName.length +1));
		else
			return unescape(myCookie.substring((pos+ treeName.length +1 ), endPos));
	}
	return "";
}

// Add a new tree node
function AddTree(isAssembly,display, ID,URL,indent,Icon,num) {
  parent.arTree[Treecounter] = new Object;
  parent.arTree[Treecounter].isAssembly = isAssembly;
  parent.arTree[Treecounter].ID = ID;
  parent.arTree[Treecounter].display = display;
  parent.arTree[Treecounter].URL = URL;
  parent.arTree[Treecounter].indent = indent;

  if(!parent.stateArr[globalModelId])
      parent.arTree[Treecounter].Icon = Icon;
  else {
      if(parent.stateArr[globalModelId][num] == 1)         //---show
         parent.arTree[Treecounter].Icon  = Icon; 
      else if(parent.stateArr[globalModelId][num] == 2){   //---highlight
         var indx = imgIconMapping(Icon);
         parent.arTree[Treecounter].Icon = arImageSrc[indx + 1];//Icon;
      }
      else																									//----hide
      {
         var indx = imgIconMapping(Icon);
         parent.arTree[Treecounter].Icon = arImageSrc[indx + 2];
      }
  }

  parent.arTree[Treecounter].num = num;
  Treecounter++;
}

//Delete the tree.
function DeleteTree(){
  var count = parent.arTree.length;
  for( i=1; i < count; i++)
  {
    delete parent.arTree[i].isAssembly;
    delete parent.arTree[i].ID;
    delete parent.arTree[i].display;
    delete parent.arTree[i].URL;
    delete parent.arTree[i].indent;
    delete parent.arTree[i].Icon;
    delete parent.arTree[i];
    parent.arTree[i] = null;
  }
  parent.arTree.length = 0;
}

// save a new cookie state
function setTreeState(newState) 
{
  var lastFor = new Date();

  // Expire after 1 day
  //lastFor.setTime(lastFor.getTime() + (7*24*60*60*1000) ); 
  //document.cookie = "Tree=" + escape(newState) ;//+ ";expires=" + lastFor.toGMTString();
  
  //Expires after 1 session.
   document.cookie = treeName + "=" + escape(newState) ;
   return;
}

// change tree state, save into cookie
function toggle(n) 
{
  if (n != 0) 
  {
    var newState = ""
    var clicked = TreeStatues.substring(n-1,n) // the clicked item
    newState += TreeStatues.substring(0,n-1)
    newState += clicked ^ 1 // Bitwise XOR clicked item
    newState += TreeStatues.substring(n,TreeStatues.length)
    setTreeState(newState) // write new state back to cookie
  }

  if(document.all)
     document.body.style.cursor = 'default';
  return;
}

// adding spaces
function pad(n) {
  var newIndent = "";
  for (var i = 1; i <= n; i++) 
	newIndent += "&nbsp;&nbsp;&nbsp;&nbsp;"; 
  return newIndent;
}


function InitTree()
{
	TreeStatues = "";
	newState="1";
    for (var i = 2; i < parent.arTree.length; i++) 
    {
		if(parent.arTree[i].isAssembly == true)	
			newState += "0";
		else
			newState += "1";
	}
    TreeStatues = newState;
    setTreeState(newState);
    return;
}
  
function setScroll(e)
{
    if (document.all ) 
    {
		if (document.all.contextMenu.style.visibility == 'visible')
			return;				// Don't autoscroll tree area if the RMB menu is currently displayed

        if((document.body.clientHeight - event.clientY) < 50 )
          window.scrollBy(0,5);

        else if(event.clientY < 40 )
          window.scrollBy(0,-5);
    }

}


var globNode = "";

function searchForSubset(str)
{
	var item = -1;
	if (str != "")
	{
		for (var i=1; i<parent.arTree.length; i++)
		{
			if (parent.arTree[i].ID == str)
			{
				item = i;
				break;
			}
		}
	}
	return item;			
}

function gojs(nodeName, hasChilden)
{
   var ModelId = "1";
   if(arguments[2] != "undefined" && arguments[2] != null && typeof(arguments[2])!= "undefined"){
         ModelId = arguments[2]; 
         GoId = ModelId;
   }
	  globNode = nodeName;
	
	if (parent.currenthighlightItem != nodeName) 
	{	
		var subSet = searchForSubset(parent.currenthighlightItem);
		if (subSet != -1)								// has highlighted node
		{
				UnhighlightIcons(subSet);
					
			if (hasChilden == true)
			{				
				var flag = -1;							// to detect if the previours highlighted item is the sub item of the clicked item

				subSet = searchForSubset(nodeName);
                if( subSet < 0)
                return;
                
				highlightSingleIcon(subSet);
				
				var topIndent = parent.arTree[subSet].indent;
				var i = subSet + 1;
				while ((i < parent.arTree.length) && (parent.arTree[i].indent >  topIndent))
				{
					if (parent.arTree[i].ID == parent.currenthighlightItem)
						flag = i;
                    if(ModelId != "")
   					 parent.ViewerObject.triggeranimation('Highlight_' + parent.arTree[i].ID,ModelId);
					else
    			       parent.ViewerObject.triggeranimation('Highlight_' + parent.arTree[i].ID);
	
					i++;
				}
		
				if (flag == -1)
				{
                   if(ModelId != "")
				      UnhighlightObjects(parent.currenthighlightItem,ModelId);
                   else
  					 UnhighlightObjects(parent.currenthighlightItem);
				}
			}
			else
			{
                   if(ModelId != "")
				     parent.ViewerObject.triggeranimation('Highlight_' + nodeName, ModelId);
                   else
                     parent.ViewerObject.triggeranimation('Highlight_' + nodeName);
            
 					subSet = searchForSubset(globNode);
	 				highlightSingleIcon(subSet);
		
    		        if(ModelId != "")
				      UnhighlightObjects(parent.currenthighlightItem, ModelId);
                    else
 				      UnhighlightObjects(parent.currenthighlightItem);
			}
		}
		else											//no highlighted node
		{
			if (hasChilden == true)
			{
			
				subSet = searchForSubset(nodeName);
				highlightSingleIcon(subSet);
				var topIndent = parent.arTree[subSet].indent;
				var i = subSet + 1;
				while ((i < parent.arTree.length) && (parent.arTree[i].indent >  topIndent))
				{
                  if(ModelId != "")
					  parent.ViewerObject.triggeranimation('Highlight_' + parent.arTree[i].ID, ModelId);
				  else
					  parent.ViewerObject.triggeranimation('Highlight_' + parent.arTree[i].ID);
	
					i++;
				}
			}
			else
			{		
                  if(ModelId != "")
				    parent.ViewerObject.triggeranimation('Highlight_' + nodeName, ModelId);	
                  else
				    parent.ViewerObject.triggeranimation('Highlight_' + nodeName);	

					subSet = searchForSubset(nodeName);
					highlightSingleIcon(subSet);
			}
		}
		parent.currenthighlightItem = nodeName;
	}	

    var res;
    if(ModelId != "")
      res = parent.ViewerObject.getproperty(nodeName, 'clps', 'mts_pnt1d', ModelId);
    else
      res = parent.ViewerObject.getproperty(nodeName, 'clps', 'mts_pnt1d');

	if (res == 0)
	{
		visibleOrNot = "visible";
	}
	else
	{
		visibleOrNot = "Not";	
	}
	return;

}


function UnhighlightIcons(i)
{	
  if( i <= 0 )
      return;
  
    if (parent.arTree[i].isAssembly == true)
	{
		UnhighlightSingleIcon(i);
		var topIndent = parent.arTree[i].indent;
		i++;
		while ((i < parent.arTree.length) && (parent.arTree[i].indent >  topIndent))
		{
			UnhighlightSingleIcon(i);
			i++;
		}
	}
	else
	{
		UnhighlightSingleIcon(i);	
	}
}

function imgIconMapping(theSrc)
{
	for (var i=1; i<arImageSrc.length; i++) 
	{
		 if (arImageSrc[i] == theSrc)
			  return i;
	}	
}

function UnhighlightSingleIcon(i)
{
	var IconSrc, leftsrc, rightsrc, holder, src;
	var pos = parent.arTree[i].Icon.indexOf("_hide.gif");
	if (pos == -1)
	{
		pos = parent.arTree[i].Icon.indexOf("_h.gif");
		if (pos != -1)
		{
			IconSrc = parent.arTree[i].Icon;			//to change the Icon setting in the array
			var num = imgIconMapping(IconSrc);
		
			// because in the Icon image list, the highligh icon is always 1 deep than the normal icon
			parent.arTree[i].Icon = arImageSrc[num-1];
		
            //persist highlight/unhighlight state
			setHighlight(GoId,i,1);
			
			holder = "document.images['img_" + i + "']";
            if(eval(holder))
				 eval(holder).src = arImageSrc[num-1];			
		}
	}
}

function highlightIcons(i)
{
 if( i <= 0)
    return;
	
 if (parent.arTree[i].isAssembly == true)
 {
		highlightSingleIcon(i);
		var topIndent = parent.arTree[i].indent;
		i++;
		while ((i < parent.arTree.length) && (parent.arTree[i].indent >  topIndent))
		{
			//highlightSingleIcon(i);
			i++;
		}
 }	
}

function highlightSingleIcon(i)
{
 if(i < 0)
   return;

 if(!parent.arTree[i])
   return;

 var IconSrc, leftsrc, rightsrc, holder, src;
	
 var pos = parent.arTree[i].Icon.indexOf("_hide.gif");
 if (pos == -1)
 {
		pos = parent.arTree[i].Icon.indexOf("_h.gif");
		if (pos == -1)
		{
			IconSrc = parent.arTree[i].Icon;			//to change the Icon setting in the array
			var num = imgIconMapping(IconSrc);
			parent.arTree[i].Icon = arImageSrc[num+1];	//highlighted Icon is always 1 step higher

            //persist highlight/unhighlight state 
            setHighlight(GoId,i,2);

			holder = "document.images['img_" + i + "']";
            if (eval(holder))
			 	eval(holder).src = arImageSrc[num+1];			
		}
 }
}

function UnhighlightObjects(str)
{
 if(arguments[1] != "undefined" && arguments[1] != null && typeof(arguments[1])!= "undefined"){
         GoId = arguments[1];
 }

	var subSet = searchForSubset(str);
 if(subSet < 0)
   return;
   
 if(!parent.arTree[subSet])
  return;

	if (parent.arTree[subSet].isAssembly == false){
	   if(GoId != "")
   	  parent.ViewerObject.triggeranimation('UnHighlight_' + str, GoId);
      else
     	  parent.ViewerObject.triggeranimation('UnHighlight_' + str);
 }
	else
	{
		var topIndent = parent.arTree[subSet].indent;
		var i = subSet + 1;
		while ((i < parent.arTree.length) && (parent.arTree[i].indent >  topIndent))
		{
			if (parent.arTree[i].ID != globNode){
			   if( GoId != "")
         	  parent.ViewerObject.triggeranimation('UnHighlight_' + parent.arTree[i].ID, GoId);
            else
         	  parent.ViewerObject.triggeranimation('UnHighlight_' + parent.arTree[i].ID);
        }
			else
			{
				if (globNode.indexOf("TYPE=ASSEMBLY") != -1)
				{
					var tempSubSet = searchForSubset(globNode);
					var tempIndent = parent.arTree[tempSubSet].indent;
					var j = tempSubSet + 1;
					while ((j < parent.arTree.length) && (parent.arTree[j].indent >  tempIndent))
					{
						j ++;
						i ++;
					}
				}
			}
			i++;
		}
	}
	parent.currenthighlightItem = "";
}

function highligthObjects(str)
{
 if(arguments[1] != "undefined" && arguments[1] != null && typeof(arguments[1])!= "undefined"){
         GoId = arguments[1];
 }

	var subSet = searchForSubset(str);
 if(subSet < 0)
  return;

 if(!parent.arTree[subSet])
   return;

	if (parent.arTree[subSet].isAssembly == false){
	  if(GoId != "")
    	 parent.ViewerObject.triggeranimation('Highlight_' + str, GoId);
     else
    	 parent.ViewerObject.triggeranimation('Highlight_' + str);
   }
	else
	{
		var topIndent = parent.arTree[subSet].indent;
		var i = subSet + 1;
		while ((i < parent.arTree.length) && (parent.arTree[i].indent >  topIndent))
		{
         if(GoId != "")
			  parent.ViewerObject.triggeranimation('Highlight_' + parent.arTree[i].ID, GoId);
         else
			  parent.ViewerObject.triggeranimation('Highlight_' + parent.arTree[i].ID);
			i++;
		}
	}
	parent.currenthighlightItem = globNode;
}

function option(str)
{
 
 if(arguments[1] != "undefined" && arguments[1] != null && typeof(arguments[1])!= "undefined")
 {
    GoId = arguments[1];
 }

	if ((str == "hide" && visibleOrNot == "visible") || (str == "show" && visibleOrNot == "Not"))
	{
		if (globNode.indexOf("TYPE=ASSEMBLY") == -1)
		{
			 if(GoId != "")
			   parent.ViewerObject.togglecollapsed(globNode, GoId);
			 else
			   parent.ViewerObject.togglecollapsed(globNode);
            
			 var subSet = searchForSubset(globNode);
			 hideOrShowSingleIcon(subSet);
			
			 if (str == "hide")
			 {
				if(GoId != "")
				   parent.ViewerObject.triggeranimation('UnHighlight_' + globNode, GoId);
				else
				   parent.ViewerObject.triggeranimation('UnHighlight_' + globNode);

				 parent.currenthighlightItem = "";
			 }
			 else
			 {
				if(GoId != "")
				  parent.ViewerObject.triggeranimation('Highlight_' + globNode, GoId);
				else
				  parent.ViewerObject.triggeranimation('Highlight_' + globNode);

				 parent.currenthighlightItem = globNode;
			 }	
		}
		else
		{
			if(GoId != "")
			  parent.ViewerObject.togglecollapsed(globNode, GoId);
			else
			  parent.ViewerObject.togglecollapsed(globNode);
        
			hideOrShowSingleIcon(searchForSubset(globNode));
			if (str == "hide")
			{
				if(GoId != "")
				     UnhighlightObjects(globNode,GoId);
				else
				     UnhighlightObjects(globNode);
			}
			if (str == "show")
			{
				if(GoId != "")
				    highligthObjects(globNode,GoId);
				else
				    highligthObjects(globNode);
			}
		}
  
		//set persistence 
		changeState(GoId, searchForSubset(globNode));

 }
 else if((str == "hideothers"))
 {
   if(GoId != "")
     HideRest(globNode, GoId);
   else
	 return;
 }
 else if((str == "showall"))
 {
   if(GoId != "")
    showAll(GoId);   
   else
    showAll();    
 }
 
 // Hide the RMB menu now that operation is complete.
 if (document.all)
	document.all.contextMenu.style.visibility = 'hidden';
 else
	document.contextMenu.visibility = 'hide';

 return;
}

function hideOrShowSingleIcon(i)
{
 if( i < 0)
   return;

	var IconSrc, leftsrc, rightsrc, holder, src;
	IconSrc = parent.arTree[i].Icon;
	
	var num = imgIconMapping(IconSrc);
	holder = "document.images['img_" + i + "']";
	var pos = IconSrc.indexOf("_h.gif");
	if (pos != -1)
	{
		
		parent.arTree[i].Icon = arImageSrc[num+1];		//hide Icon is always 1 step higher than the highlighted icon
  if (eval(holder))   
			  eval(holder).src = arImageSrc[num+1];		
	}
	else
	{
		pos = IconSrc.indexOf("_hide.gif");
		if (pos != -1)							// if the current icon is hide icon already
		{
			parent.arTree[i].Icon = arImageSrc[num-1];		//hide Icon is always 1 step lower than the highlighted icon		
   if (eval(holder))
			  eval(holder).src = arImageSrc[num-1];
		}
		else									// if the current Icon is unhilight ICon
		{
			parent.arTree[i].Icon = arImageSrc[num+2];		//reular Icon is always 12 step lower than the hide icon	
	  if (eval(holder))
			   eval(holder).src = arImageSrc[num+2];
		}
	}
}

function showAndUnhighlightIcon(i)
{
	var IconSrc, leftsrc, rightsrc, holder, src;
	IconSrc = parent.arTree[i].Icon;
	
	var num = imgIconMapping(IconSrc);
	holder = "document.images['img_" + i + "']";
	
	var pos = IconSrc.indexOf("_hide.gif");
	if (pos != -1)
	{
		parent.arTree[i].Icon = arImageSrc[num-2];		//reular Icon is always 12 step lower than the hide icon		
  if(eval(holder))   
		 eval(holder).src = arImageSrc[num-2];
	}
	else
	{
		pos = IconSrc.indexOf("_h.gif");
		if (pos != -1)
		{
			parent.arTree[i].Icon = arImageSrc[num-1];		//reular Icon is always 1 step lower than the highlighted icon	
		 if (eval(holder))
		  	eval(holder).src = arImageSrc[num-1];	
		}
	}
}

function HideRest(cur_node)
{ 
  var ModelId = "1";
  if(arguments[1] != "undefined" && arguments[1] != null && typeof(arguments[1])!= "undefined"){
         ModelId = arguments[1];
         GoId = ModelId;
  }
 
 if(cur_node == parent.arTree[1].ID)
  return;

	for (var i=2; i < parent.arTree.length; i++)
	{

   if(ModelId != "")
   			 parent.ViewerObject.triggeranimation('UnHighlight_' + parent.arTree[i].ID, ModelId);
   else
   			 parent.ViewerObject.triggeranimation('UnHighlight_' + parent.arTree[i].ID);


		 if(parent.arTree[i].ID != cur_node)
   {
 
     if(isItemHidden(parent.arTree[i].ID,ModelId) == "0")
     {
       if(parent.arTree[i].isAssembly)
        continue;

       hideOrShowSingleIcon(i);
       UnhighlightSingleIcon(i);     
     
       if(ModelId != "")
				     parent.ViewerObject.togglecollapsed(parent.arTree[i].ID, ModelId);
       else
				     parent.ViewerObject.togglecollapsed(parent.arTree[i].ID);
     }
     parent.stateArr[ModelId][i] = 0;
   }
   else
   {
     var offset = 0;
     if(parent.arTree[i].isAssembly)
        offset = getNextPeer(i);
     
     
     if(isItemHidden(cur_node,ModelId) == "1")
     {
       if(ModelId != "")
				     parent.ViewerObject.togglecollapsed(cur_node, ModelId);
       else
				     parent.ViewerObject.togglecollapsed(cur_node);
      
       showAndUnhighlightIcon(i);
     }
     else 
      UnhighlightSingleIcon(i);
   
     parent.stateArr[ModelId][i] = 1;
     i = i+ offset;
   }
   
	}
	parent.currenthighlightItem = cur_node;
 
	return;
}

function getNextPeer(indx)
{
  var offset = 0;
  
  for( var i = (indx + 1) ; i < parent.arTree.length ; i++)
  {
    if(parent.arTree[i].indent > parent.arTree[indx].indent )
     offset++; 
    if(parent.arTree[i].indent == parent.arTree[indx].indent)
     break;
  }  
  return offset;
}

function isItemHidden(item, ModelId)
{
   var status;
   if( ModelId != "")
        status = parent.ViewerObject.getproperty(item, 'clps', 'mts_pnt1d', ModelId);
   else
        status = parent.ViewerObject.getproperty(item, 'clps', 'mts_pnt1d');

   return status;
}

function showAll()
{
	var ModelId = "1";
	if(arguments[0] != "undefined" && arguments[0] != null && typeof(arguments[0])!= "undefined")
	{
	        ModelId = arguments[0];
	        GoId = ModelId;
	}

	for (var i=1; i<parent.arTree.length; i++)
	{
		if(ModelId != "")
   			parent.ViewerObject.triggeranimation('UnHighlight_' + parent.arTree[i].ID, ModelId);
		else
   			parent.ViewerObject.triggeranimation('UnHighlight_' + parent.arTree[i].ID);

		UnhighlightSingleIcon(i);

		var status ;
		if( ModelId != "")
			status = parent.ViewerObject.getproperty(parent.arTree[i].ID, 'clps', 'mts_pnt1d', ModelId);
		else
			status = parent.ViewerObject.getproperty(parent.arTree[i].ID, 'clps', 'mts_pnt1d');

		if(status != 0)
		{
			if(ModelId != "")
			    parent.ViewerObject.togglecollapsed(parent.arTree[i].ID, ModelId);
			else
				parent.ViewerObject.togglecollapsed(parent.arTree[i].ID);

		}
		showAndUnhighlightIcon(i);
	}
	
	parent.currenthighlightItem = "";

	//set persistence
	if(parent.stateArr[ModelId])
	{
	  var arrlength = parent.stateArr[ModelId].length;
	  for (var i = 1; i <= arrlength ; i++) 
	  {
			   parent.stateArr[ModelId][i] = 1; //show
	  }
	}

	return;
}


function showMenu (evt) 
{	
  var containerWidth, containerHeight, srcHeight, XPosition, href

 
  // IE
  if (document.all) 
  {
	   var testObj = event.srcElement;
	   href = testObj.href;
	   if (href == null)
	   {	
	   	   if (testObj.tagName == "FONT")	  //sepecific to this page, if you clicked on the Menu item
		   {
			   if (event.button == 2)
				   document.all.contextMenu.style.visibility = 'hidden';
			   
			   return;
		   }
		   if (parent.currenthighlightItem != "")
		   {
			     UnhighlightIcons(searchForSubset(parent.currenthighlightItem));
				 if(GoId != "")
   					UnhighlightObjects(parent.currenthighlightItem,GoId);
				 else
   					UnhighlightObjects(parent.currenthighlightItem);
		   }

      //Fix for preventing the default context menu from appearing.
      if(document.all.contextMenu.style.visibility == 'visible')
		      return false;
      else
		   return;
	   }
	
	   if (event.button == 1)
	   {	
		    document.all.contextMenu.style.visibility = 'hidden';
		
		    var src = event.srcElement.innerHTML;
		    if ((src == "Show All") || (src == ""))		// for the "Show All", or the plus/minus sign link
		     	return;
		
    		var pos = src.indexOf(".gif");				
		    if (pos == -1)
		     	return;
		
			return;
	   }
	   else							//right clicked, show menu
	   {
		    href = testObj.href;
		    var hrefLow = href.toLowerCase();
		    if (hrefLow.indexOf("showall") == -1)
		    {
			    href = href.replace(/%20/g, " ");
     			window.execScript(href);

//----------------

      if (testObj.tagName == "IMG")
      {
        var evalstr = (unescape(testObj.parentElement.href)).substring(11);
        if(evalstr.indexOf('gojs') != -1)
          eval(evalstr); // index of fuction start is 11th index (javascript:gojs)
        else
          return false;
      }
//----------------    

				if (visibleOrNot == "")
				      window.show.innerHTML = "<font face='Arial, Helvetica, sans-serif' size='2' color='gray'>Show</font>";
		
     			if (visibleOrNot == "Not")
			    {
				      window.hide.innerHTML = "<font face='Arial, Helvetica, sans-serif' size='2' color='gray'>Hide</font>";
				      window.show.innerHTML = "<font face='Arial, Helvetica, sans-serif' size='2' color='black'>Show&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>";
			    }
			    if (visibleOrNot == "visible")
			    {
				      window.show.innerHTML = "<font face='Arial, Helvetica, sans-serif' size='2' color='gray'>Show</font>";
				      window.hide.innerHTML = "<font face='Arial, Helvetica, sans-serif' size='2' color='black'>Hide&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>";
			    }

				if(window.hideothers)
  					window.hideothers.innerHTML = "<font face='Arial, Helvetica, sans-serif' size='2' color='black'>Hide Others</font>";
				if(window.showall)
					window.showall.innerHTML = "<font face='Arial, Helvetica, sans-serif' size='2' color='black'>Show All</font>";

 				XPosition = event.clientX;
			    containerWidth = document.body.clientWidth;
			    containerHeight = document.body.scrollTop + document.body.clientHeight;
			    srcHeight = document.body.scrollTop + event.clientY;
			    if (XPosition >  containerWidth)
				     document.all.contextMenu.style.pixelLeft = event.clientX - 140; 
			    else
				     document.all.contextMenu.style.pixelLeft = event.clientX - 5; 
			
				var bottomedge = document.body.clientHeight - event.clientY ;
				if (bottomedge < contextMenu.offsetHeight)
					contextMenu.style.top = document.body.scrollTop + event.clientY - contextMenu.offsetHeight ;
				else
					contextMenu.style.top = document.body.scrollTop + event.clientY ;
			
    			if (event.button == 2)	
				     document.all.contextMenu.style.visibility = 'visible';
    			
    			
    			return false;
		   }  
	  }
  }
  //Netscape 4.X
  else if (document.layers) 
  {
	   var testObj = evt.target;
   	   href = testObj.href;

    	//SRM:01/21/2002 Fix SPR 123034 for Netscape. Update current model Id.
	   if(top.ModelList)
			GoId = top.ModelList.selectedobj;
	
	   if (href == null && evt.which == 1)
	   {
		    UnhighlightIcons(searchForSubset(parent.currenthighlightItem));
			if(GoId != "")
		        UnhighlightObjects(parent.currenthighlightItem,GoId);
			else
				UnhighlightObjects(parent.currenthighlightItem);

                        routeEvent(evt);
     		        //return;
	   }

	   if (href == null && evt.which != 1)
	   {
		    UnhighlightIcons(searchForSubset(parent.currenthighlightItem));
			if(GoId != "")
		      UnhighlightObjects(parent.currenthighlightItem, GoId);
			else
		      UnhighlightObjects(parent.currenthighlightItem);
        
		    document.contextMenu.visibility = 'hide';
      
                    routeEvent(evt);
		    //return;
	   }
	
	   if (href != null && evt.which == 1)
	   {
                    routeEvent(evt);
	            //return;
	   }  
	   else
	   {
			var num_menuitems = document.contextMenu.document.links.length;

		    href = testObj.href;
		    var hrefLow = href.toLowerCase();

		    if (hrefLow.indexOf("showall") == -1)
		    {
                        var evalstr = (unescape(href)).substring(11);
                        if(evalstr.indexOf('gojs') == -1)
                         return false;

                           //      eval(evalstr); // SRM: doesn't seem to work in Netscape.

			     var tempHref = href.substring(18, (href.length-1));
			     tempHrefList = tempHref.split(",");
			     var tempFirst = tempHrefList[0].substring(0, (tempHrefList[0].length-1));
				 if(GoId != "")
			        gojs(tempFirst, tempHrefList[1],GoId );
				 else
			        gojs(tempFirst, tempHrefList[1]);

     			 if (visibleOrNot == "Not")
			     {
				      with (document.contextMenu.document) 
					  {
					       open();
					       str = "<DIV ID=\"contextMenu\" style=\"pixelLeft:10px; pixelTop: 50px; width: 140px; border: 2px outset white;\" ONMOUSEOUT=\"menu = this; this.tid = setTimeout('menu.style.visibility = \\'hidden\\'', 20);return false;\" ONMOUSEOVER=\"clearTimeout(this.tid);return false;\">"

						if(GoId != "")
						{
       						str += "<A href=\"JavaScript:option('hide'," + GoId + ");\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
       						str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"hide\"><font color='gray'>Hide</font></span></A>";
       						str += "<hr size=\"1\"></hr><A href=\"JavaScript:option('show'," + GoId + ");\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
       						str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"show\"><font color=\"\">Show</font></span></A>"
							if(num_menuitems > 2)
							{
       						  str += "<hr size=\"1\"></hr><A href=\"JavaScript:option('hideothers'," + GoId + ");\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
       						  str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"hideothers\"><font color=\"\">Hide Others</font></span></A>"
                              str += "<hr size=\"1\"></hr><A href=\"JavaScript:option('showall'," + GoId + ");\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
       						  str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"showall\"><font color=\"\">Show All</font></span></A>"
							}
     					}
						else
     					{
       						str += "<A href=\"JavaScript:option('hide');\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
       						str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"hide\"><font color='gray'>Hide</font></span></A>";
       						str += "<hr size=\"1\"></hr><A href=\"JavaScript:option('show');\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
       						str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"show\"><font color=\"\">Show</font></span></A>"
							if(num_menuitems > 2)
							{
       						   str += "<hr size=\"1\"></hr><A href=\"JavaScript:option('hideothers');\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
       						   str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"hideothers\"><font color=\"\">Hide Others</font></span></A>"
                   			   str += "<hr size=\"1\"></hr><A href=\"JavaScript:option('showall');\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
       				 		   str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"showall\"><font color=\"\">Show All</font></span></A>"
							}
     					}

					    str += "</DIV>"
					    write(str);
					    close();
				    }
			   }
		
   			   if ((visibleOrNot == "visible") || (visibleOrNot == ""))
			   {	
				   with (document.contextMenu.document) 
				   {
					    open();
					    str = "<DIV ID=\"contextMenu\" style=\"pixelLeft:10px; pixelTop: 50px; width: 140px; border: 2px outset white;\" ONMOUSEOUT=\"menu = this; this.tid = setTimeout('menu.style.visibility = \\'hidden\\'', 20);return false;\" ONMOUSEOVER=\"clearTimeout(this.tid);return false;\">"
						if(GoId != "")
						{
					  		str += "<A href=\"JavaScript:option('hide'," + GoId + ");\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
       						str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"hide\"><font color=\"\">Hide</font></span></A>";
					  		str += "<hr size=\"1\"></hr><A href=\"JavaScript:option('show'," + GoId + ");\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
  							str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"show\"><font color='gray'>Show</font></span></A>"
							if(num_menuitems > 2)
							{
       							str += "<hr size=\"1\"></hr><A href=\"JavaScript:option('hideothers'," + GoId + ");\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
  								str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"hideothers\"><font color=''>Hide Others</font></span></A>"
								str += "<hr size=\"1\"></hr><A href=\"JavaScript:option('showall'," + GoId + ");\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
   								str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"showall\"><font color=''>ShowAll</font></span></A>"  
							}
     					}
     					else
     					{
					  		str += "<A href=\"JavaScript:option('hide');\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
       						str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"hide\"><font color=\"\">Hide</font></span></A>";
					  		str += "<hr size=\"1\"></hr><A href=\"JavaScript:option('show');\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
  							str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"show\"><font color='gray'>Show</font></span></A>"
							if(num_menuitems > 2)
							{
					  			  str += "<hr size=\"1\"></hr><A href=\"JavaScript:option('hideothers');\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
  								  str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"hideothers\"><font color=''>Hide Others</font></span></A>"
								  str += "<hr size=\"1\"></hr><A href=\"JavaScript:option('showall');\" CLASS=\"menu\" ONMOUSEOVER=\"this.className = 'menuOn'\" ";
  								  str += "ONMOUSEOUT=\"this.className = 'menu';\"><span ID=\"showall\"><font color=''>Show All</font></span></A>"
							}
     					}

					     str += "</DIV>"
					     write(str);
					     close();
				   }
			  }
		
			document.contextMenu.left = evt.x;
			document.contextMenu.top = evt.y;
			document.contextMenu.onmouseout = function (evt) { this.visibility = 'hide'; };
				
		  	XPosition = evt.x;
			containerWidth = window.innerWidth;
  			containerHeight = window.innerHeight;
		  	srcHeight = evt.y;
		  	if (XPosition >  containerWidth)
				   document.contextMenu.left = evt.x - 140; 
			else
				   document.contextMenu.left = evt.x; 
			
			if ((srcHeight+50) < containerHeight)
				document.contextMenu.top = srcHeight;
			else
			   	document.contextMenu.top = srcHeight - 50;	
				
			document.contextMenu.visibility = 'show';
			return false;
		 }
	 }
 }
 return true;
}   

var arImageList = new Array ();
var arImageSrc = new Array (
        "images/minus.gif",
        "images/plus.gif",
        "images/Part.gif",
        "images/Part_h.gif",
        "images/Part_hide.gif",
        "images/Assem.gif",
        "images/Assem_h.gif",
        "images/Assem_hide.gif"
)
for (counter in arImageSrc) {
	arImageList[counter] = new Image();
    arImageList[counter].src = arImageSrc[counter];
}


if (document.all && document.getElementById) //oncontextmenu is not valid for IE4.0.
  document.oncontextmenu = showMenu;

if (document.layers) 
{
  document.captureEvents(Event.MOUSEDOWN);
  document.onmousedown = showMenu;
}
if (!document.all && document.getElementById)
  document.onmouseup = showMenu;

document.onmousedown = showMenu;


//--EOF



