//preload images
pic1= new Image(180,42); 
pic1.src="/images/menu_sensing_solutions_on.gif";

pic2= new Image(158,41); 
pic2.src="/images/menu_filters_lasers_on.gif";

pic3= new Image(112,42); 
pic3.src="/images/menu_about_us_on.gif";

pic4= new Image(123,41); 
pic4.src="/images/menu_contact_us_on.gif";

pic5= new Image(1,20); 
pic5.src="/images/sub_sensing_bg.gif";

pic6= new Image(1,20); 
pic6.src="/images/sub_filters_bg.gif";

pic7= new Image(1,20); 
pic7.src="/images/sub_about_bg.gif";

pic8= new Image(1,25); 
pic8.src="/images/filters_3rd_level_bg.gif";

pic9= new Image(1,25); 
pic9.src="../images/sensing_3rd_level_bg.gif";

pic10= new Image(1,25); 
pic10.src="/images/about_3rd_level_bg.gif";


var menu = { selectedMenu: null, lists: $('sub-menu').getElementsByTagName('ul')};
var running = false;
var speed = 50;
var speedWanted = 50;
$('menu-sensing-solutions').onmouseover = function() {
	moveListNoSlide('menu-sensing-solutions','subnav_9');
}
$('menu-filters-lasers').onmouseover = function() {
	moveListNoSlide('menu-filters-lasers','subnav_10');	
}
$('menu-about-us').onmouseover = function() {
	moveListNoSlide('menu-about-us','subnav_11');	
}
$('menu-contact-us').onmouseover = function(){
	moveListNoSlide('menu-contact-us','none');
}
var j = 0; // debugging varible

function moveListNoSlide(tab,id){
	document.getElementById('subnav_9').style.display = "none";
	document.getElementById('subnav_10').style.display = "none";
	document.getElementById('subnav_11').style.display = "none";
	document.getElementById('menu-sensing-solutions').className = '';
	document.getElementById('menu-filters-lasers').className = '';
	document.getElementById('menu-about-us').className = '';
	document.getElementById('menu-contact-us').className = '';
	document.getElementById(tab).className = 'selected';
	if(id != 'none'){
		document.getElementById(id).style.display = "block";
	}
}

function moveList(id){
	if(!running){
		running = true;
		var menu_arr = Array('menu-sensing-solutions', 'menu-filters-lasers', 'menu-about-us', 'menu-contact-us');
		var submenu_arr = Array('subnav_9', 'subnav_10', 'subnav_11');
		var index = 0;
		for(var i = 0; i < menu_arr.length; i++)
		{
			if(submenu_arr[i] != id){
				//Effect.BlindUp(submenu_arr[i], {duration:1.0});
				if($(submenu_arr[i])!= null){
				$(submenu_arr[i]).style.display = 'none';
				}
				$(menu_arr[i]).className = '';
				
			} else {
				index = i;
			}
		}
		
		if(id != 'subnav_81' && $(id) != null){
			if(($(id).style.display != "block")){
				//alert(id);
				$(menu_arr[index]).className = 'selected';
				//$(submenu_arr[index]).onmouseout = function(){Effect.BlindUp(submenu_arr[index], {duration:0.5})}
				Effect.BlindDown(id, {duration:0.1, afterFinish:function(){running=false}});
			} else {
				clearAll();
			}
		} else if(id == 'subnav_81'){
			$('menu-contact-us').className = 'selected';
		}
	}
}
function clearAll(){
	document.getElementById('subnav_9').style.display = "none";
	document.getElementById('subnav_10').style.display = "none";
	document.getElementById('subnav_11').style.display = "none";
	document.getElementById('menu-sensing-solutions').className = '';
	document.getElementById('menu-filters-lasers').className = '';
	document.getElementById('menu-about-us').className = '';
	document.getElementById('menu-contact-us').className = '';
	//alert('clear');
	/*if(!running){
		var menu_arr = Array('menu-sensing-solutions', 'menu-filters-lasers', 'menu-about-us', 'menu-contact-us');
		for(var i = 0; i < menu.lists.length; i++)
		{
			if($(menu_arr[i]).className == 'selected'){
				//alert(menu.lists[i].parentNode.id);
			Effect.BlindUp(menu.lists[i].parentNode.id, {duration:0.3, afterFinish:function(){running=false}});
			$(menu_arr[i]).className = '';
			}
			menu.lists[i].parentNode.style.height = '21px';
		}
		stopList();
	}*/
}
function moveList2()
{
	var finished = true;
	
	for(var i = 0; i < menu.lists.length; i++)
	{
		if(menu.selectedMenu == menu.lists[i].parentNode.id)
		{			
			menu.lists[i].parentNode.style.zIndex = 10;
			if(menu.lists[i].parentNode.offsetTop < 120)
			{
				menu.lists[i].parentNode.style.top = (menu.lists[i].parentNode.offsetTop + 1) + 'px'; // If the limit has not been reached, add one						
				finished = false;
			} 
			
		}
		else
		{	
			menu.lists[i].parentNode.style.zIndex = 1;		
			if(menu.lists[i].parentNode.offsetTop > 100)
			{
				menu.lists[i].parentNode.style.top = (menu.lists[i].parentNode.offsetTop - 1) + 'px'; // If the limit has not been reached, subtract one			
				finished = false;
			}
			
		}
	}	
	if(finished){
		stopList();
	}
}
function stopList()
{
		running=false;
}
 function setNav(){
		moveList(page);
}

function InsertHomePageFlash(path)
{
  document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="945" height="384" id="home_header_flash_file" align="middle"><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + path + '" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><embed src="' + path + '" quality="high" bgcolor="#000000" wmode="transparent" width="945" height="384" name="home_header_flash_file" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

function InsertSubPageFlash(path)
{
  document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="945" height="244" id="sub_header" align="middle"><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + path + '" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><embed src="' + path + '" quality="high" bgcolor="#000000" wmode="transparent" width="945" height="244" name="sub_header" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}
function showThirdSub (thisObj){
	
	var ul = thisObj.getElementsByTagName('span');
	
	ul[0].style.display = 'block';
	
}
function hideThirdSub(thisObj){
	
	var ul = thisObj.getElementsByTagName('span');
	
	ul[0].style.display = 'none';
	
}