function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

var Tin = new Object();
Tin.active = null;
Tin.pending = null;
Tin.hideTime = 500;
Tin.topOffset = 29;
Tin.leftOffset = 0;
Tin.timeouts = new Object();

if( document.getElementById ){
	old_addEvent(window, 'onload', buildMenu);
	old_addEvent(window, 'onload', sidebarMenu);
	old_addEvent(window, 'onload', infoBoxes);
	//window.addEvent('domready', buildMenu);
	//window.addEvent('domready', sidebarMenu);
	//window.addEvent('domready', infoBoxes);

	var domain = document.domain;
	var proto = location.protocol;
	if( proto == "file:" ){
		document.writeln( '<link media="all" rel="stylesheet" type="text\/css" href="/nav/css/menu.css" \/>' );
	} else {
		document.writeln( '<link media="all" rel="stylesheet" type="text\/css" href="'+proto+'//www.americantinceilings.com/nav/css/menu.css" \/>' );
	}
	if( document.all ) Tin.topOffset = 28;
}

function getId(id){ return document.getElementById(id); }

function buildMenu(){
	var nav = getId('nav');
	var navItems = nav.getElementsByTagName('DIV');
	for(var i=0; i< navItems.length; i++){
		var navItem = navItems[i];
	
		navItem.onmouseover = showDropMenu;
		navItem.onmouseout  = pendingHideDropMenu;
		
		var subNav = getId('subNav_'+ navItem.id.split("_")[1] );
		if( subNav ){
			subNav.onmouseover = stopHideDropMenu;
			subNav.onmouseout =  pendingHideDropMenu;
		}
	}
}

function showDropMenu(){
	var navName = this.id.split("_")[1];
	if( navName == Tin.pending ) Tin.pending = null;
	var subMenu = getId('subNav_'+navName);
	
	if( Tin.active && ( navName != Tin.active ) ){
		Tin.active.style.display = 'none';
		Tin.active = null;
	}
	if( !subMenu ) return;
	Tin.active = subMenu;
	subMenu.style.display = 'block';
	subMenu.style.left =  findPosX( this )  + Tin.leftOffset + 'px';
	subMenu.style.top = findPosY( this ) + Tin.topOffset + 'px';
}

function pendingHideDropMenu(){
	var navName = this.id.split("_")[1];
	Tin.pending = navName;
	Tin.timeouts[navName] = window.setTimeout("hideDropMenu('"+navName+"')", Tin.hideTime);

}

function hideDropMenu( navName ){
	if( navName != Tin.pending ) return;
	var subMenu = getId('subNav_'+navName);
	if( subMenu ) subMenu.style.display = 'none';
}

function stopHideDropMenu(){
	var navName = this.id.split("_")[1];
	if( navName == Tin.pending ){
		clearTimeout( Tin.timeouts[navName] );		
		Tin.pending = null;
	}
}


function sidebarMenu(){
	if( !document.getElementById('sidebar')) return;
	var sidebar = getId('sidebar');
	var blks = sidebar.getElementsByTagName('DIV');
	for( var i = 0; i < blks.length; i++ ){
			blks[i].onmouseover = sidebarOver;
			blks[i].onmouseout = sidebarOut;
			blks[i].onclick = divClick;
	}
}

function sidebarOver(){ 
	this.className = 'over';
	window.status = this.getElementsByTagName('A')[0].href;
}
function sidebarOut(){ this.className = ''; window.status = null;}

function divClick(){
	location.href= this.getElementsByTagName('A')[0].href;
}


function infoBoxes(){
	var content =  getId('content');
	var divs = content.getElementsByTagName('DIV');
	for( var i = 0; i < divs.length; i++ ){
		var box = divs[i];
		if( box.className == 'info' ){
			box.onmouseover = infoPanelOver;
			box.onmouseout = infoPanelOut;
			box.onclick = divClick;
		}
	}
}
domainM = "americantinceilings.com";
function infoPanelOver(){
	this.className = 'info over';
	window.status = this.getElementsByTagName('A')[0].href;
}

function infoPanelOut(){ this.className = 'info'; window.status = null; }


function showCostWizard(){
	var domain = document.domain;
	var proto = location.protocol;
	var src;
	if( proto == "file:" ){
		src = "/costEstimator/costWizard.html";
	} else {
		src = proto+"//"+domain+"/costEstimator/costWizard.html"
	}
	
	
	var wizard = document.getElementById('cost_wizard');

	if( wizard.src != src ) wizard.src = src;

	WinXY = getWindowSize();
	ScrollXY = getScrollXY();

	var left = ( ScrollXY[0] + (( WinXY[0] / 2 ) - 300 ) ) < 0 ? 0 : ( ScrollXY[0] + (( WinXY[0] / 2 ) - 300 ) );
	var top =  ( ScrollXY[1] + (( WinXY[1] / 2 ) - 133 ) ) < 0 ? 0 : ( ScrollXY[1] + (( WinXY[1] / 2 ) - 133 ) );
	wizard.style.left = ScrollXY[0] + left + 'px';
	wizard.style.top =  ScrollXY[1] + top + 'px';
	wizard.style.display = 'block';
}



