var ns4, ns6, ie
if (document.all) 
{
  ie = 1
}
else if (document.layers) 
{
  ns4 = 1
}
else if (document.getElementById) 
{
  ns6 = 1
}

//alert("ie: " + ie + "\nns4: " + ns4 + "\nns6: " + ns6)

var currOpen = ""

window.onload=init;

function foo()
{
	//alert("foo")
	return true
}

var loaded = 0;

//***********************************************************************************************
function init() 
{
	if (ns4) 
	{
		for (var i=0;i<document.layers.length;i++) 
		{
			var thisObj = document.layers[i];
			thisObj.captureEvents(Event.MOUSEOUT);
			thisObj.onmouseout = hideit;
		}
	}
	
	if (ns6)
	{
		var array = document.getElementsByTagName("div")
		
		for (i=0; i < array.length; i++)
		{
			thisObj = array[i]
			thisObj.addEventListener("mouseout", hideit, false);
		}
	}

	if (ie)
	{
		var array = document.getElementsByTagName("div")
		
		for (i=0; i < array.length; i++)
		{
			thisObj = array[i]
			thisObj.onmouseout = hideit;
		}
	}

loaded = 1;
}

//***********************************************************************************************
function show(strObj, opaque)
{
	hide()
	
	if (ns4)
	{
		if(document.layers[strObj])
		{
			document.layers[strObj].visibility = "show"
			currOpen = strObj
		}
	}
	else
	{
		obj = document.getElementById(strObj)

		if (obj)
		{
			if (opaque){opacity = 100}
			else{opacity = 80}
			
			obj.style.filter = "alpha(opacity=" + opacity + ")"
			obj.style.visibility = "visible"
			currOpen = strObj
		}
	}	
}

//***********************************************************************************************
function hide()
{
	if(currOpen != "")
	{
		if (ns4)
		{
			document.layers[currOpen].visibility = "hide"
		}
		else
		{
			document.getElementById(currOpen).style.visibility = "hidden"
		}
	}
}

//***********************************************************************************************
function hideit (e) 
{
	if (ns4)
	{
		var layname = e.target.name;
		var tar = e.target+"";
		//alert(e.srcElement)
		if (tar.indexOf('Layer')>=0) 
		{
			hide();
		}
	}
	else
	{
		if (ns6)
		{
			//alert(e.currentTarget)
			var tar = e.target.tagName
			if (tar.indexOf('DIV') >= 0)
			{
				hide();
			}
		}
		else
		{
			if (ie)
			{
				if (document.getElementById(currOpen))
				{
					if (!(document.getElementById(currOpen).contains(window.event.toElement))) 
					{
						hide()
					}
				}
			}	
			else 
			{
				routeEvent(e);
			}
		}
	}
}

//***********************************************************************************************
function MouseOn(objName, ImagesDir)
{

	if (ImagesDir==null)
	{
		ImagesDir = "./images/"
	}

	//Close Menu if needed
	if (currOpen != "") hide();
	
	//Set the higlight image, if needed
	if (self.document.images[objName]) self.document.images[objName].src = ImagesDir + "/top/top_" + objName + "_on.gif"
	
	//Set the arrow, if needed
	if (self.document.images[objName + "_arrow"]) self.document.images[objName + "_arrow"].src = ImagesDir + "/arrow_small.gif"

	//Set the pointer, if needed
	if (self.document.images[objName + "_pointer"]) self.document.images[objName + "_pointer"].src = ImagesDir + "/pointer_on.gif"
	
	
	//Set the rollover button, if needed
	if (self.document.images["button_" + objName]) self.document.images["button_" + objName].src = ImagesDir + "/button_" + objName + "_on.gif"
}

//***********************************************************************************************
function MouseOff(objName, ImagesDir)
{
	if (ImagesDir==null)
	{
		ImagesDir = "./images/"
	}

	//Set the normal image, if needed
	if (self.document.images[objName]) self.document.images[objName].src = ImagesDir + "/top/top_" + objName + "_off.gif"
	
	//Remove the arrow, if needed
	if (self.document.images[objName + "_arrow"]) self.document.images[objName + "_arrow"].src = ImagesDir + "/arrow_blank.gif"

	//Set the pointer, if needed
	if (self.document.images[objName + "_pointer"]) self.document.images[objName + "_pointer"].src = ImagesDir + "/pointer_off.gif"
	
	//Set the normal button, if needed
	if (self.document.images["button_" + objName]) self.document.images["button_" + objName].src = ImagesDir + "/button_" + objName + "_off.gif"
}

//***********************************************************************************************
function MenuOn(obj, ImageName, ImagesDir)
{
	//alert("hey")
	if (ImagesDir==null)
	{
		ImagesDir = "./images"
	}
	
	if (ns4)
	{
		var count = document.layers.length
		
		for (i=0; i<count; i++)
		{
			if (document.layers[i].document.images[ImageName]) document.layers[i].document.images[ImageName].src = ImagesDir + '/arrow_head.gif';
		}
	}	
	else 
	{
		if (self.document.images[ImageName]) self.document.images[ImageName].src=ImagesDir + '/arrow_head.gif';
	}
	
}

//***********************************************************************************************
function MenuOff(obj, ImageName, ImagesDir)
{
	if (ImagesDir==null)
	{
		ImagesDir = "./images/"
	}
	if (ns4)
	{
		var count = document.layers.length
		
		for (i=0; i<count; i++)
		{
			if (document.layers[i].document.images[ImageName]) document.layers[i].document.images[ImageName].src = ImagesDir + '/spacer_pixel.gif';
		}
	}	
	else 
	{
		if (self.document.images[ImageName]) self.document.images[ImageName].src=ImagesDir + '/spacer_pixel.gif';
	}
}

//***********************************************************************************************
function TreeOn(node, level, ImagesDir)
{
	//Close dropdown Menu if needed
	if (currOpen != "") hide(currOpen);
	
	index = -1
	count = self.document.images.length
	
	for (i=0; i<count; i++)
	{
		currName = self.document.images[i].name
		if (currName == node) index = i
	}
	
	if (index >= 0)
	{

		if (level == 1)
		{
			image = ImagesDir + "/arrow_menu.gif"
		}
		else
		{
			image = ImagesDir + "/arrow_head_tree.gif"
		}
		self.document.images[index].src = image
	}
	
}

//***********************************************************************************************
function TreeOff(node, level, ImagesDir)
{
	index = -1
	count = self.document.images.length
	
	for (i=0; i<count; i++)
	{
		currName = self.document.images[i].name
		if (currName == node) index = i
	}
	
	if (index >= 0)
	{
		self.document.images[index].src = ImagesDir + "/arrow_blank.gif"
	}
	
}

//***********************************************************************************************
function OpenBranch(name, url)
{
	self.document.location = url + "?Node=" + name	
}

//***********************************************************************************************
function OpenBranchTicket(name, url)
{
	show('loading', 1)
	url = url + "?Node=" + name
	//alert(url)
	self.document.location.href = url
}

//***********************************************************************************************
function OpenWindow(width, height, url, name, scroll)
{
	if (name)
	{
		windowName = name
	}
	else
	{
		windowName = "Message"
	}
	
	//center window
	var w = 800, h=600

 	w = screen.availWidth
	h = screen.availHeight

	var popW = width, popH = height

	var leftPos = (w-popW)/2, topPos = (h-popH)/2

	if (scroll)
	{
		var options = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no"
	}
	else
	{
		var options = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,titlebar=no"
	}
	options = options + ",width=" + popW
	options = options + ",height=" + popH
	options = options + ",left=" + leftPos
	options = options + ",top=" + topPos
		
	newwin = self.open(url,windowName,options)	
	
	return newwin		
}

//***********************************************************************************************
function PositionWindow(width, height, left, top, url, name)
{
	if (name)
	{
		windowName = name
	}
	else
	{
		windowName = "Message"
	}
	
	var options = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,titlebar=no"

	options = options + ",width=" + width
	options = options + ",height=" + height
	options = options + ",left=" + left
	options = options + ",top=" + top
		
	newwin = self.open(url,windowName,options)	
	
	//return newwin		
}

//***********************************************************************************************
function onSelDir(dir)
{
	document.location.replace("company2.asp?Node=CompanyDownloads&Dir=" + dir)
}


//***********************************************************************************************
function suiteWindow(url, name)
{
	
	if (name)
	{
		windowName = name
	}
	else
	{
		windowName = "Suite"
	}
	
	//center window
	var w = 800, h=600

	if (document.all || document.layers) 
	{
	   w = screen.availWidth
	   h = screen.availHeight
	}

	var popW = 620, popH = 600

	var leftPos = (w-popW)/2, topPos = (h-popH)/2

	var options = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no"
	options = options + ",width=" + popW
	options = options + ",height=" + popH
	options = options + ",left=" + leftPos
	options = options + ",top=" + topPos
		
	newwin = self.open(url,windowName,options)	
	
	//return newwin		
}


//***********************************************************************************************
function ticketList(url)
{
	//alert("hey!!!")
	currOpen = ""
	show("loading", 1)
	parent.document.location.href = url
	return false
}

