// <!--
// determine if browser is capable of image swaps
//20061129-IPD-Added My account tab
var supported = 0;

if ( ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 3)) ||
	 ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) > 3)) )
	 supported = 1;

// load the target page determined by the nav bar below the main sections, add_link, and go_link

var section_count = 5;  // number of sections in top, 
var link_count = 4;     // number of links in total (to change must change the image map)
//var links = new Array ((section_count + 2)* (link_count + 1)); // +2 is used to keep in sync with naming system already established
var links = new Array(32);

//function add_link (section, linknum, url) {
// links[section * linknum] = url;
//}   

function go_link(num, asection) {
	//sections are 2 greater than you'd think - 2=buy, etc..
   document.location=links[4*(asection-2) + num];
}
links[0] = '';
links[1] = '/buy/exchange/post/choosefamily.asp' ;
links[2] = '/buy/excess/browse_step1.asp' ;
links[3] = '/buy/buyerprofile/' ;
links[4] = '/buy/mybuying/current_activity.asp' ;
links[5] = '/recentRFQs.asp' ;
links[6] = '/sell/excess/PostExcess1.asp' ;
links[7] = '/sell/supplierprofile/' ;
links[8] = '/sell/myselling/current_activity.asp' ;
links[9] = '/research/' ;
links[10] = '/research/' ;
links[11] = '/research/' ;
links[12] = '/research/' ;
links[13] = '/community/calendarIndex.asp' ;
links[14] = '/community/' ;
links[15] = '/community/' ;
links[16] = '/community/' ;
links[17] = '/esolutions/' ;
links[18] = '/esolutions/' ;
links[19] = '/esolutions/' ;
links[20] = '/esolutions/' ;
links[21] = '/aboutus/mission.asp' ;
links[22] = '/aboutus/press_release_main.asp' ;
links[23] = '/community/default.asp' ;
links[24] = '/aboutus/contact/default.asp' ;
links[25] = '/registration/login.asp';
links[26] = '/buy/mybuying/current_activity.asp';
links[27] = '/sell/myselling/current_activity.asp';
links[28] = '/myaccount/default.asp';
links[29] = '/aboutus/contact/default.asp';
links[30] = '/aboutus/contact/default.asp';
links[31] = '/aboutus/contact/default.asp';
links[32] = '/aboutus/contact/default.asp';



// update the browser's bottom status bar with specified text
function dispStatus(text)
{
	if (supported) {
		window.status = text;
	}
}



// preload Nav images
var numNav = 9;
var NavImages = new Array(numNav * 2);

function addNav(index, width, height, stat, strImage)
{
	if (supported)
	{
		var on = stat * numNav;
		NavImages[index + on] = new Image(width, height);
		NavImages[index + on].src = strImage;
	}
}
addNav(1, 480,59, 1,'/images/nav_home_on.gif');
addNav(2, 480,59, 1,'/images/nav_buy_on.gif');
addNav(3, 480,59, 1,'/images/nav_sell_on.gif');
addNav(4, 480,59, 1,'/images/nav_research_on.gif');
addNav(5, 480,59, 1,'/images/nav_aboutus_on.gif');
addNav(6, 480,59, 1,'/images/nav_aboutus_on.gif');		//Changed old esolutions
addNav(7, 480,59, 1,'/images/nav_aboutus_on.gif');		//Changed old community to about us
addNav(8, 480,59, 1,'/images/nav_myaccount_on.gif');	//20061119 IPD
addNav(9, 480,59, 1,'/images/nav_contactus_on.gif');	//20061215 IPD


// each rollover Nav has: name=NavX; where X indicates its index
function nav_rollover (index, action)
{
	if (supported) {
		document.images["nav"].src = NavImages[index + (numNav * action)].src;
	}
}


// preload Toolbox images
var numTB = 5;
var TBImages = new Array(numTB * 2);
var TBNames = new Array(numTB * 2);

function addTB(index, width, height, stat, strImage)
{
	if (supported)
	{
		var on = stat * numTB;
		TBImages[index + on] = new Image(width, height);
		TBImages[index + on].src = strImage;
	}
}
addTB(1, 17,17, 1,'/images/toolbox_graybg/tool_home_on.gif');
addTB(1, 17,17, 0,'/images/toolbox_graybg/tool_home_off.gif');
addTB(2, 17,17, 1,'/images/toolbox_graybg/tool_contact_on.gif');
addTB(2, 17,17, 0,'/images/toolbox_graybg/tool_contact_off.gif');
addTB(3, 17,17, 1,'/images/toolbox_graybg/tool_help_on.gif');
addTB(3, 17,17, 0,'/images/toolbox_graybg/tool_help_off.gif');
addTB(4, 17,17, 1,'/images/toolbox_graybg/tool_profile_on.gif');
addTB(4, 17,17, 0,'/images/toolbox_graybg/tool_profile_off.gif');
addTB(5, 17,17, 1,'/images/toolbox_graybg/tool_register_on.gif');
addTB(5, 17,17, 0,'/images/toolbox_graybg/tool_register_off.gif');

function addTBNames(index, width, height, stat, strImage)
{
	if (supported)
	{
		var on = stat * numTB;
		TBNames[index + on] = new Image(width, height);
		TBNames[index + on].src = strImage;
	}
}
addTBNames(1, 47,12, 1,'/images/toolbox_graybg/tool_home_on_2.gif');
addTBNames(1, 47,12, 0,'/images/transpix.gif');
addTBNames(2, 47,12, 1,'/images/toolbox_graybg/tool_contact_on_2.gif');
addTBNames(2, 47,12, 0,'/images/transpix.gif');
addTBNames(3, 47,12, 1,'/images/toolbox_graybg/tool_help_on_2.gif');
addTBNames(3, 47,12, 0,'/images/transpix.gif');
addTBNames(4, 47,12, 1,'/images/toolbox_graybg/tool_profile_on_2.gif');
addTBNames(4, 47,12, 0,'/images/transpix.gif');
addTBNames(5, 47,12, 1,'/images/toolbox_graybg/tool_register_on_2.gif');
addTBNames(5, 47,12, 0,'/images/transpix.gif');


// each rollover ToolBox has: name=TBX; where X indicates its index
function toolbox_rollover (index, action)
{
	if (supported) {
		document.images["TB" + index].src = TBImages[index + (numTB * action)].src;
		document.images["toolbox_name"].src = TBNames[index + (numTB * action)].src;
	}
}



var windowIsOpen = "false";
// open new window
function openWindow(url, w, h) {
  popupWin = OpenPopup(url, 'window', 'resizable=yes,scrollbars=yes,menubar=no,location=no,directories=no,status=no,menubar=no,width=' + w + ',height=' + h);
  windowIsOpen = "true";
}

// determines when moving outside of a primary/secondary nav tab whether to continue with
// the rollover. This serves the purpose of allowing someone on a 'sell' tab to hit the
// secondary nav's on a different tab w/o clicking on that secondary's primary tab 1st.
function checkmove(event){

	if( navigator.appName == "Microsoft Internet Explorer" ){
		if(window.event.clientY >= 75 ){
			return true;
		}else{
			return false;
		}
	}
	else if (navigator.appName == "Netscape"){
		if(event.layerY >= 69){
			return true;
		}
		else{
			return false;
		}
	}else{
		return false;
	}
		

}

//determines when user leaves upper bounds of navigation header
function checkmovetop(event){

	if( navigator.appName == "Microsoft Internet Explorer" ){
		if(window.event.clientY <= 28 ){
			return true;
		}else{
			return false;
		}
	}
	else if (navigator.appName == "Netscape"){
		if( event.layerY <= 19 ){
			return true;
		}
		else{
			return false;
		}
	}else{
		return false;
	}
		

}

//These functions keep track of popup windows and allow editing of open windows

//this function returns handle to parent of popup window.  If it has been closed, opens window with default settings
function GetMainPage()
{
	if (self.name != "InternalPop")
	{
		alert("Calling GetMainPage from non-popup window.");
		return null;
	}
	
	if (window.opener.closed)
	{
		var hw_main = window.open("http://www.metalsuppliersonline.com","Main");
		hw_main.opener = null;
		return hw_main;
	}
	else
	{
		return window.opener;
	}
}

//this will open a and track a single PopUpWindow with opener property
function OpenPopup(strURL, strWinProperties)
{
	var hw_pop = self.opener
	if (hw_pop != null)
	{
		if (!hw_pop.closed)
		{
			hw_pop.close();
		}
	}
	self.opener = window.open(strURL,"InternalPop",strWinProperties);
}

//20061213-IPD-Hide or show div
function pickShowOrHide(divName) {
	var objDivStyle = eval('document.all.' + divName + '.style');
	if (objDivStyle.visibility == 'visible') {
		hideDiv(divName);
	} else {
		showDiv(divName);
	}
}

function showDiv(divName) {
	var objDivStyle = eval('document.all.' + divName + '.style');
	objDivStyle.visibility = 'visible';
}

function hideDiv(divName) {
	var objDivStyle = eval('document.all.' + divName + '.style');
	objDivStyle.visibility = 'hidden';
}
//20061213-IPD-Added function to toggle div visibility
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}


// -->