//instantiate vars
var strActiveSubnav = '';
var hideSubnavTimeout;

//initialize global nav -- called from document onload event
function initGlobalNav(){
	hideAll(); //hack for IE5/Mac
	document.getElementById('globalNavholder').style.visibility = 'visible';
}

//show a subnav div -- called from onmouseover event of navitem
function showSubnav(navitem){
	hideAll();
	strActiveSubnav = navitem;
	document.getElementById('divNav'+strActiveSubnav+'On').style.visibility = 'visible';
	document.getElementById('divTopNav'+strActiveSubnav+'On').style.visibility = 'visible';
	document.getElementById('divSubnav'+strActiveSubnav).style.visibility = 'visible';
}

//begin hiding subnav divs -- called from onmouseout event of navitem
function hideSubnav(state){
	clearTimeout(hideSubnavTimeout);
	strActiveSubnav = '';
	if(state == 'force'){
		hideSubnav2();
	}else{
		hideSubnavTimeout = setTimeout('hideSubnav2()',200);
	}
}

//hide subnav divs -- called from hideSubnav(state)
function hideSubnav2(){
	if(strActiveSubnav == ''){
		hideAll();
	}
}

//hides all subnav divs
function hideAll(){
	for(i=1;i<4;i++){
		document.getElementById('divNav'+i+'On').style.visibility = 'hidden';
		document.getElementById('divTopNav'+i+'On').style.visibility = 'hidden';
		document.getElementById('divSubnav'+i).style.visibility = 'hidden';
	}
}

function pageInit(){
	initGlobalNav();
}

// End Dropdowns

function hideDiv(){
	document.getElementById('homebuton').style.visibility = 'hidden';
}

function showDiv() { 
	hideDiv();
	document.getElementById('homebuton').style.visibility = "visible";
} 

function togglehideall() {
		document.getElementById('subswapc1').style.display = "none";
		document.getElementById('subswapb2').style.display = "none";
		document.getElementById('subswapv3').style.display = "none";
		document.getElementById('subswapd4').style.display = "none";
	}

function toggle(objName){
	    if (document.getElementById(objName).style.display == '') {
			togglehideall();
			document.getElementById(objName).style.display = "none";
			}
	    else {
			togglehideall();
			document.getElementById(objName).style.display = "";
			}
    }
	
function MemMsg(memID) {
	SX = Math.round((screen.availWidth - 500) / 2);
	SY = Math.round((screen.availHeight - 500) / 2);
	var win=window.open('/business/membership_contact_msg.asp?memID='+memID+'','mywindow','width=500,height=500,toolbar=no,scrollbars=yes,resizable=yes,menubar=no,location=no,status=no,screenX='+SX+',left='+SX+',screenY='+SY+',top='+SY);
	if(win.focus) win.focus();
}
	
// Rollovers and Preload

var iPath = '/vimages/nav_';
var iExt = 'gif';
var suffix = new Array('on', 'off');

function preLoad()
{
  if(document.images)
  {
    var argLen = arguments.length;
    for(var i = 0; i < argLen; i++)
    {
      var arg = arguments[i];
      var sufLen = suffix.length;
      for(j = 0; j < sufLen; j++)
      {
        var suf = suffix[j]
        self[arg + '_' + suf] = new Image();
        self[arg + '_' + suf].src = iPath + arg + '_' + suf + '.' + iExt;
      }
    }
  }
}

function preLoadOther()
{
  if(document.images)
  {
    var argLen = arguments.length;
    for(var i = 0; i < argLen; i++)
    {
      var arg = arguments[i];
      self[arg] = new Image();
      self[arg].src = iPath + arg;
    }
  }
}

function rollOver(iName, iState)

{
  if(document.images && self[iName + '_' + iState])
  {
    document.getElementById(iName).src = self[iName + '_' + iState].src;
  }
}

function EmailFormat(eName,eAddress,eText) {
		var ToName = eName;
		var ToAddress = eAddress;
		var ToDisplayText = eText;
		document.write("<a href=\"mailto:"+eName+"@"+ToAddress+"\">"+eText+"</a>");
	}

//Onload events

function onLoad()
{
  pageInit();
  preLoad('visitors', 'business', 'chamber', 'subvisitors', 'subbusiness', 'subchamber', 'rtt', 'ticon', 'cicon', 'members');
 preLoadOther("hbut_business_off.jpg","hbut_business_on.jpg","hbut_chamber_off.jpg","hbut_chamber_on.jpg","hbut_visitor_off.jpg","hbut_visitor_on.jpg","banner_business.jpg","banner_chamber.jpg","banner_visitors.jpg","homeimage3.jpg","tbanner.jpg","tbanner_main.jpg");
};