
var uTimeOutId;
var hTimeOutId;
var onNav;
var navObject;
var overNav;
var urlResults;
var selTimeOutId;

navHover = function() {
   // only load these things if menus are in play
  if(document.getElementById)
  {
   valid = document.getElementById("popNav");
   if(valid)
   {
	var navItems = document.getElementById("popNav").getElementsByTagName("li");
	for (var i=0; i<navItems.length; i++) {
		navItems[i].onmouseover=function() {
			this.className+=" navHover";
		}
		navItems[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" navHover\\b"), "");
		}
	}
   }
	var dropItems = document.getElementsByName("dropNav");
	
	for (var i=0; i<dropItems.length; i++) {
		navItems = dropItems[i].getElementsByTagName("li");
		for(var j=0; j<navItems.length; j++)
		{
			navItems[j].onmouseover=function() {
				this.className+=" navHover";
			}
			navItems[j].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" navHover\\b"), "");
			}		
		}
	}


	var boxItems = document.getElementsByTagName("li");
	if(boxItems)
	{
		for(var i=0; i<boxItems.length; i++)
		{
			if(boxItems[i].className == "popBoxTriggerItem")
			{
				boxItems[i].onmouseover=function() {
					this.className+=" navHover";
				}
				boxItems[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" navHover\\b"), "");
				}
			}
		}
	}
    }

}
if (window.attachEvent) window.attachEvent("onload", navHover);


function subNavOver(id)
{
	if(uTimeOutId)
          {
                clearTimeout(uTimeOutId);
                uTimeOutId = "";
          }
}

function subNavNotOver(id)
{
	uhlNav(id);
}

function hlNav(id)
{
	if(hTimeOutId)
	{
		clearTimeout(hTimeOutId);
		hTimeOutId = "";
	}
	hTimeOutId = setTimeout("hlNavNow('" + id + "')", 150);
}

function hlNavNow(id)
{
	if(overNav != "")
        {
   	  uhlNavNow(overNav);
	  if(uTimeOutId)
          {
          	clearTimeout(uTimeOutId);
		uTimeOutId = "";
	  }
        }
	if(id == onNav)
	{
	 	return;
	}	

	if(hTimeOutId)
	{
		clearTimeout(hTimeOutId);
		hTimeOutId = "";
	}

        var nobj = document.getElementById("topNav_" + id);
        if(nobj)
        {
		nobj.className = "offTabOver";
        }
	var idnum = tabList[id];

        // var lobj = document.getElementById("tabLabel_" + id);
	var lobj = document.getElementById("tabLabel_" + idnum);	
        if(lobj)
        {
		// lobj.className = "offTabOver";
		lobj.className = "menuLabel_offTab";	
        }
        var oobj = document.getElementById("subNav_" + onNav);
	if(oobj)
	{
	oobj.className = oobj.className.replace(new RegExp(" subbarover\\b"), " subbarnotover");
	}
        var sobj = document.getElementById("subNav_" + id);
	if(sobj)
	{
	sobj.className = sobj.className.replace(new RegExp(" subbarnotover\\b"), " subbarover");
	}
	overNav = id;
}

function uhlNav(id)
{
	if(hTimeOutId)
	{
		clearTimeout(hTimeOutId);
		hTimeOutId = "";
	}
	else
	{
 	       uTimeOutId = setTimeout("uhlNavNow('" + id + "')", 500);
	}
}

function uhlNavNow(id)
{
	if(id == onNav)
	{
	 	return;
	}	

        var nobj = document.getElementById("topNav_" + id);
        if(nobj)
        {
                if(id != onNav)
                {
			nobj.className = "offTab";
			var lobj = document.getElementById("tabLabel_" + id);
			if(lobj)
			{
			   lobj.className = "offTab";
			}
                }
        var oobj = document.getElementById("subNav_" + onNav);
	if(oobj)
	{
	oobj.className = oobj.className.replace(new RegExp(" subbarnotover\\b"), " subbarover");
	}
        var sobj = document.getElementById("subNav_" + id);
	if(sobj)
	{
	sobj.className = sobj.className.replace(new RegExp(" subbarover\\b"), " subbarnotover");
	}

        }
	overNav = "";
}

function hitUrl(url)
{
	var client = new HTTPClient();
        client.init(url)
        client.asyncGET();
}

function collapser(id, set, sp, menu)
{
	var obj = document.getElementById("collapse_" + id);
	if(obj)
	{
		if(obj.style.display == "none")
		{
	      		obj.style.display = "block";
			var iObj = document.getElementById("img_" + id);
			if(iObj)
			{
				iObj.src = "/cobrand/" + sp + "/images/arrow_down.gif";
			}
			if(set)
			{
				script = '/home/home/menuPref.cgi?pID=' + id + '&pCase=on&pMenuSet=' + menu;
				hitUrl(script);
			}
		}
		else
		{
		      obj.style.display = "none";
		      var iObj = document.getElementById("img_" + id);
		      if(iObj)
		      {
			iObj.src = "/cobrand/" + sp + "/images/arrow_right.gif";
		      }
			if(set)
			{
				script = '/home/home/menuPref.cgi?pID=' + id + '&pCase=off&pMenuSet=' + menu;
				hitUrl(script);
			}
		}	
	}
}

function imageSwap(id, src)
{
	if (document.getElementById)
	{
	   document.getElementById(id).src = src;
	}
}


var checkMailStatus = {
  onLoad: function(data)
  {
	if(data > 0)
        {
		newMail(data);	
        }
  }
}


// for web mail icon display/update
function makeSound(which)
{
	if (document.getElementById)
	{
		soundContainer = document.getElementById('wmsounds');
		if(soundContainer)
		{
			soundContainer.innerHTML = "<embed hidden=\"true\" src=\"/sounds/" + which + "\" autostart=\"true\"/>";
		}
	}
} // makeSound

function startPing()
{
	ping = parseInt(ping);
	newMailCount = parseInt(newMailCount);

	if (window.setInterval)
		if (ping && (newMailCount == 0))
		{
			pingInterval = window.setInterval('checkForNewMail()', 1000*60*ping);
		}
} // startPing

function stopPing()
{
	if (window.setInterval && window.clearInterval)
		if (ping)
			window.clearInterval(pingInterval);
} // stopPing

function checkForNewMail()
{
	if (document.getElementById)
	{
		mailIcon = document.getElementById('mailStatus');
		if (mailIcon)
		{
			url = "/home/nos/chkm.cgi/" + user + "/" + domain + "/" + myEncode(junkFolder);
			var client = new HTTPClient();
			client.init(url)		
			client.asyncGET(newMail);
		}
	}
} // function checkForNewMail

function myEncode(str)
{
	if (escape)
		return escape(str);
	else
		return encodeURI(str);
} // function myEncode


var newMail = {
  onLoad: function(data)
  {
		if (data.match(/[^0-9\s]/)) {
			stopPing();
		}
		else if(parseInt(data) > 0)
		{
			var src = '/cobrand/' + signupPath + '/images/newMail.gif';	
			imageSwap('mailStatus', src);

			if(pingAlert != 'none')
				makeSound(pingAlert);
			stopPing();
		}
  },

  onError: function() {
		stopPing();
  }
} 


// old commonlib-2 functions
var submitCount = 0;


function startSiteBuilder(url)
{
        window.open(url, "templates", "toolbar,scrollbars,resizable,width=640,height=480");
}


function startMiva(url)
{
        window.open(url, "miva", "toolbar,scrollbars,status,resizable,width=750,height=550");
}

function startCompose()
{
	window.open('/home/mail/new/mbox_compose.cgi?pFolder=', '_blank', 'status=yes,menu=yes,scrollbars=yes,resizable=yes,width=750,height=520');
	return false;
} // function startCompose

function jumpTo(dest)
{
        var x;
        x = dest.options[dest.selectedIndex].value
        location.href=x;
}

function submitOnce()
{
        if (submitCount == 0)
        {
                submitCount++;
                return true;
        }
        else
        {
                return false;
        }
}

function hideSelects()
{
        if(selTimeOutId)
        {
                clearTimeout(selTimeOutId);
                selTimeOutId = "";
        }
	hideSelectsNow();
}

function hideSelectsNow()
{
    if(window.attachEvent)
    {
	for(var i = 0; i < document.forms.length; i++)
        	for(var e = 0; e < document.forms[i].length; e++)
                	if(document.forms[i].elements[e].tagName == "SELECT")
			{ 
				document.forms[i].elements[e].style.visibility="hidden"; 
			}
	if(onSubNav == "fileManager")
	{
		ob = document.getElementById('folderTree');
		if(ob)
		{
			ob.style.visibility="hidden"; 	
		}
	}
    }
}

function showSelects()
{
        if(selTimeOutId)
        {
		return;
        }
        selTimeOutId = setTimeout("showSelectsNow()", 100);
}

function showSelectsNow()
{
    if(window.attachEvent)
    {
	for(var i = 0; i < document.forms.length; i++)
        	for(var e = 0; e < document.forms[i].length; e++)
                	if(document.forms[i].elements[e].tagName == "SELECT")
			{ 
				document.forms[i].elements[e].style.visibility="visible"; 
			}
	if(onSubNav == "fileManager")
	{
		ob = document.getElementById('folderTree');
		if(ob)
		{
			ob.style.visibility="visible"; 	
		}
	}
    }
    selTimeOutId = "";
}

function falsify()
{
	return;
}

