// JavaScript Document

/*window.onload=show;*/
function extractPageName(hrefString)
{
	var arr = hrefString.split('/');
	return  (arr.length<2) ? hrefString : arr[arr.length-1].toLowerCase();               
}
var currentPage;
function setActiveMenu(arr, crtPage)
{
	for (var i=0; i<arr.length; i++)
	{
		if(extractPageName(arr[i].href) == crtPage)
		{
			if (arr[i].parentNode.tagName != "DIV")
			{
				arr[i].className = "current";
				arr[i].parentNode.className = "current";
				x = arr[i].parentNode;
				if (x) {
					if (x.tagName == 'DT') {
							currentPage = x.id.replace('t','s');
							displaySubmenu(currentPage);
					}
					x = x.parentNode;
				}
				if (x) {
					x = x.parentNode;
				//	alert("2 " + x.tagName);
				}
				if (x.tagName == 'DD') {
					displaySubmenu(x.id);
					currentPage = x.id;
				}
			}
		}
	}
}

function setPage()
{
	hrefString = document.location.href ? document.location.href : document.location;

	if (document.getElementById("menu")!=null)
		setActiveMenu(document.getElementById("menu").getElementsByTagName("a"), extractPageName(hrefString));
}


function displaySubmenu(id) {
	var d = document.getElementById(id);
	if (d) d.style.display = 'block';
}


var currentMenu='';

function show(id, e) {
var d = document.getElementById(id);
var x,ii,src;
	if (document.all) { e = window.event; }
	_noBubbling(e);
	src = e.srcElement?e.srcElement:e.target;
	if (src.id.substr(0,5) != 'tmenu') return;
	for (var i = 1; i<=10; i++) {
		if ('smenu'+i == id) ii = i;
		if ('smenu'+i != currentPage && document.getElementById('smenu'+i)) {
			document.getElementById('smenu'+i).style.display='none';
		}
	}
	x = document.getElementById(currentMenu);
	if (x) x.style.display='none';
	if (d && id != currentPage) {
		x = document.getElementById(src.id + 'pulloutMenu');
		if (x) {
			// x is the pullout box.
			// x.parentNode is the box around the sidebar
			// d is probably not displayed
			// document.getElementById(id.replace('s','t')) is the box around the menu item.
			x.innerHTML = d.innerHTML;			
			currentMenu = x.id;
			x.style.display='block';
//			x.style.top = (ii*34 - 17) + "px";
//			x.style.left = (ii + 150) + "px";
//			x.style.top = "0px";
//			x.style.top = (e.offsetY + e.srcElement.currentStyle.pixelTop) + "px";
			//x.style.top = e.layerY + "px";

		}
	}
}

function hideMenu(e) {
	if (currentMenu.length > 0) {
		//alert("hiding " + currentMenu + " from " + window.event.srcElement.id);
		x = document.getElementById(currentMenu);
		if (x) x.style.display='none';
		currentMenu = "";
	}
}

function _noBubbling(e){
 if (document.all) {
  window.event.cancelBubble = true;
  window.event.returnValue = false;
 }else if(e.preventDefault){
  e.cancelBubble = true;
  e.stopPropagation();
  e.preventDefault();
 }
 return false;
}

//mouse out//		
//function unshow(id, e) {
//var d = document.getElementById(id);
//var x,ii;
//	for (var i = 1; i<=10; i++) {
//		if ('smenu'+i == id) ii = i;
	//	if ('smenu'+i != currentPage && document.getElementById('smenu'+i)) {
			//document.getElementById('smenu'+i).style.display='none';
		//}
	//}
	//if (d && id != currentPage) {
		//x = document.getElementById(e.srcElement.id + 'pulloutMenu');
		//if (x) {
			//if (document.all) { e = window.event; }
		//	x.innerHTML = d.innerHTML;			
			//x.style.display='none';
		//}
	//}
//}
			
		
			
			
//function doSomething(e) {
	//if (!e) var e = window.event;
	//var tg = (window.event) ? e.srcElement : e.target;
	//if (tg.nodeName != 'DIV') return;
	//var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	//while (reltg != tg && reltg.nodeName != 'BODY')
		//reltg= reltg.parentNode
	//if (reltg== tg) return;
//}



			
			// if IE Need to find fix for e.layer    should be    x.style.top = e.clientY + "px";    need to determine how to put into the file so both work  // 
			
			
			//x.style.top = getStyle(document.getElementById("tmenu" + ii), "scrollTop");
			//alert("menu" + ii + " " + x.style.top + " " + getStyle(document.getElementById("tmenu" + ii), "scrollTop"));
			//alert(x.style.left + " " + e.clientX);

			//x.style.display='inline';

// Need to add on mouseout command //

var sidebar=
'<dl id="menu">' +
'' +
'		<dt id="tmenu1" onMouseOver="javascript:show(\'smenu1\',event);"><a href="about.html" class="navlftactive">About Us</a>' +
'<div id="tmenu1pulloutMenu" class="pulloutMenu" style="display:none;position:relative;z-index:300;top:-25;left:125;" onmouseover="_noBubbling(event)"></div></dt>' +
'       	<dd id="smenu1" class="dropdown">' +
'				<ul>' +
'					<li><a href="customers_partners.html">Customers & Partners</a></li>' +
'					<li><a href="management_team.html">Management Team</a></li>' +
'					<li><a href="news.html">News</a></li>' +
'                   <li><a href="careers.html">Careers</a></li>' +
'                   <li><a href="contact.asp">Contact Us</a></li>' +
'				</ul>' +
'			</dd>	' +
'' +		
'		<dt id="tmenu2" onmouseover="javascript:show(\'smenu2\',event);"><a href="howitcworks.html" class="navlftactive">How ITC Works</a>' +
'<div id="tmenu2pulloutMenu" class="pulloutMenu" style="display:none;position:relative;z-index:300;top:-25;left:125;" onmouseover="_noBubbling(event)"></div></dt>' +
'			<dd id="smenu2" class="dropdown">' +
'				<ul>' +
'					<li><a href="services.html">Services Overview</a></li>' +
'					<li><a href="expertise.html">Expertise</a></li>' +
//'					<li><a href="success_stories.html">Success Stories</a></li>' +
'				</ul>' +
'			</dd>	' +
'' +
'		<dt id="tmenu3" onmouseover="javascript:show(\'smenu3\',event);"><a href="design.html" class="navlftactive">Design</a>' +
'<div id="tmenu3pulloutMenu" class="pulloutMenu" style="display:none;position:relative;z-index:300;top:-25;left:125;" onmouseover="_noBubbling(event)"></div></dt>' +
'			<dd id="smenu3" class="dropdown">' +
'				<ul>' +
'					<li><a href="proof_of_concept.html">Proof of concept</a></li>' +
'					<li><a href="analysis.html">Analysis</a></li>' +
'				</ul>' +
'			</dd>' +
'' +
'		<dt id="tmenu4" onmouseover="javascript:show(\'smenu4\',event);"><a href="fabrication.html" class="navlftactive">Fabrication</a>' +
'<div id="tmenu4pulloutMenu" class="pulloutMenu" style="display:none;position:relative;z-index:300;top:-25;left:125;" onmouseover="_noBubbling(event)"></div></dt>' +
'			<dd id="smenu4" class="dropdown">' +
'				<ul>' +
'					<li><a href="photolithography.html">Photolithography</a></li>' +
'					<li><a href="etching.html">Etching</a></li>' +
'                    <li><a href="cvd.html">CVD</a></li>' +
'                    <li><a href="pvd.html">PVD</a></li>' +
'                    <li><a href="cmp_grind.html">CMP/Grind</a></li>' +
'				</ul>' +
'			</dd>' +
'' +
'        <dt id="tmenu5" onmouseover="javascript:show(\'smenu5\',event);"><a href="packaging.html" class="navlftactive">Packaging</a>' +
'<div id="tmenu5pulloutMenu" class="pulloutMenu" style="display:none;position:relative;z-index:300;top:-25;left:125;" onmouseover="_noBubbling(event)"></div></dt>' +
'			<dd id="smenu5" class="dropdown">' +
'				<ul>' +
'					<li><a href="wafer_level_bonding.html">Wafer Bonding</a></li>' +
'					<li><a href="dicing.html">Dicing</a></li>' +
'                    <li><a href="surface_properties.html">Surface Properties</a></li>' +
'                    <li><a href="interconnections.html">Interconnections</a></li>' +
'                    <li><a href="flip_chip_bonding.html">Flip Chip Bonding</a></li>' +
'                    <li><a href="optoelectronics.html">Optoelectronics</a></li>' +
'                    <li><a href="adhesive.html">Adhesives</a></li>' +
'				</ul>' +
'			</dd>' +
'            ' +
'	  <dt id="tmenu6" onmouseover="javascript:show(\'smenu6\',event);"><a href="metrology.html" class="navlftactive">Metrology</a>' +
'<div id="tmenu6pulloutMenu" class="pulloutMenu" style="display:none;position:relative;z-index:300;top:-33;left:125;" onmouseover="_noBubbling(event)"></div></dt>' +
'			<dd id="smenu6" class="dropdown">' +
'				<ul>' +
'					<li><a href="reliability_testing.html">Reliability Testing</a></li>' +
'' +
'				</ul>' +
'			</dd>' +
'    ' +
'  	  <dt id="tmenu7" onmouseover="javascript:show(\'smenu7\',event);"><a href="other_itc_services.html" class="navlftactive">Other ITC Services</a>' +
'<div id="tmenu7pulloutMenu" class="pulloutMenu" style="display:none;position:relative;z-index:300;top:-25;left:125;" onmouseover="_noBubbling(event)"></div></dt>' +
'			<dd id="smenu7" class="dropdown">' +
'				<ul>' +
'					<li><a href="partnerships.html">Partnerships</a></li>' +
'                    <li><a href="community_support.html">Community</a></li>' +
'                    <li><a href="commercialization.html">Commercialization</a></li>' +
'' +
'				</ul>' +
'			</dd>' +
'            ' +
'        <dt id="tmenu8" onmouseover="javascript:show(\'smenu8\',event);"><a href="resources.html" class="navlftactive">Resources</a>' +
'<div id="tmenu8pulloutMenu" class="pulloutMenu" style="display:none;position:relative;z-index:300;top:-25;left:125;" onmouseover="_noBubbling(event)"></div></dt>' +
'			<dd id="smenu8" class="dropdown">' +
'				<ul>' +
'					<li><a href="equipment.html">Equipment</a></li>' +
'                    <li><a href="publications.html">Publications</a></li>' +
'                    <li><a href="marketing.html">Marketing</a></li>' +
' 					 <li><a href="links.html">Links</a></li>' +
'' +
'				</ul>' +
'</dl>';
function init(){
	x=document.getElementById('sidebar');
	if (x){
		x.innerHTML=sidebar;
	}	
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
	setPage();
}