

var decStrings = new Array(30);
var decTimer = null;
var decCount=0;
var justClicked=false;
var justClickedTimer=null;

var opening=null;
var defaultY=0;
var defaultYstr="";
var defaultX=0;
var defaultXstr="";
var bOpenDown=true;
var curDistance=0;
var jump=0;
var openTimer=null;
var tempDist="";

var hoverTimer=null;
var hoverStrS = "";
var hoverStrP = "";

var over=0;

function mOverTop(s)
{
	over=2;
	if (document.getElementById(s).style.visibility == 'visible') return;
	if (hoverTimer)
	{
		self.clearTimeout(hoverTimer);
		hoverTimer=null;
		hoverStrP="";
		hoverStrS="";
	}
	hoverTimer = self.setTimeout("incPanel2()", 150);
	hoverStrS=s;
}

function mOver(p, s)
{
	if (over<2)
		over=2;
	if (hoverTimer)
	{
		self.clearTimeout(hoverTimer);
		hoverTimer=null;
		hoverStrP="";
		hoverStrS="";
	}
	hoverStrP=p;
	hoverStrS=s;
	//hoverTimer = self.setTimeout("incPanelEx2()", 150);
}

function mOut()
{
	if (over>0)
		over--;
	if (over>0) return;
	if (hoverTimer)
	{
		self.clearTimeout(hoverTimer);
		hoverTimer=null;
	}
		hoverStrP="";
		hoverStrS="";
		hoverTimer = self.setTimeout("test()", 50);
}

function test()
{
	self.setTimeout("start()", 50);
}

function incPanelEx2()
{
	noVanish = false;
	if (document.getElementById(hoverStrS).style.visibility == 'visible') return;
	incPanelEx(hoverStrP, hoverStrS);
}

function incPanel2()
{
	noVanish = false;
	if (document.getElementById(hoverStrS).style.visibility == 'visible') return;
	incPanel(hoverStrS);
}

function getNumListedItems(s)
{
	// temp test:
	// notes: set these numbers to return the number of list items in each panel to help determine height:
	switch(s)
	{
	case("psec"): return 6; break;
	case("support"): return 3; break;
	case("services"): return 2; break;
	case("hosting"): return 2; break;
	case("networking"): return 2; break;
	default: return 15; break;
	}
}

function openPanel(bD, s)
{
	// tbd: if openTimer then set the opening panel to default values and clear timer

	if (bD)
	{
		// opening a primary panel downwards
		document.getElementById(s).style.height="0px";
		opening = s;
		defaultY = (getNumListedItems(s)*21);
		defaultYstr = defaultY.toString() + "px";
		jump = defaultY / 10;
		curDistance=jump;
		bOpenDown=true;
	}
	else
	{
		// opening a secondary panel sideways
		opening = s;
		defaultX = parseInt(document.getElementById(s).style.width);
		defaultXstr = document.getElementById(s).style.width;
		document.getElementById(s).style.width="0px";
		defaultYstr = document.getElementById(s).style.height;
		jump = defaultX / 10;
		curDistance=jump;
		bOpenDown=false;
	}
	openTimer = self.setTimeout("panelTick()", 20);
}

function panelTick()
{
	if (bOpenDown)
	{
		curDistance += jump;
		if (curDistance>=defaultY)
		{
			document.getElementById(opening).style.height = defaultYstr;
			//opening=null;
			openTimer=null;
			defaultY=0;
		}
		else
		{
			tempDist = curDistance.toString() + "px";
			document.getElementById(opening).style.height = tempDist;
			openTimer = self.setTimeout("panelTick()", 20);
		}
	}
	else
	{
		curDistance += jump;
		if (curDistance>=defaultX)
		{
			document.getElementById(opening).style.width = defaultXstr;
			opening=null;
			openTimer=null;
			defaultX=0;
		}
		else
		{
			tempDist = curDistance.toString() + "px";
			document.getElementById(opening).style.width = tempDist;
			openTimer = self.setTimeout("panelTick()", 25);
		}
	}
}

function start()
{
	//if (justClicked) return;

	if (hoverTimer)
	{
		self.clearTimeout(hoverTimer);
	}
	hoverTimer=null;
	hoverStrP="";
	hoverStrS="";

	// hide all panels
	document.getElementById("psec").style.visibility='hidden';
	document.getElementById("services").style.visibility='hidden';
	document.getElementById("hosting").style.visibility='hidden';
	document.getElementById("networking").style.visibility='hidden';

	// align the panels according to scrollbar
	/*var offset = 0;
	if (navigator.appName == "Microsoft Internet Explorer")
		offset = 63 - document.body.scrollTop;
	else offset = 63 - window.pageYOffset;
	var offsetstr = offset.toString() + "px";
	document.getElementById("psec").style.top=offsetstr;
	document.getElementById("services").style.top=offsetstr;
	document.getElementById("hosting").style.top=offsetstr;
	document.getElementById("networking").style.top=offsetstr;*/

	var y=63;
	if (self.pageYOffset) // all except Explorer
	{
		y -= self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		y -= document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		y -= top.main.document.body.scrollTop;
	}

	var offsetstr = y.toString() + "px";
	document.getElementById("psec").style.top=offsetstr;
	document.getElementById("services").style.top=offsetstr;
	document.getElementById("hosting").style.top=offsetstr;
	document.getElementById("networking").style.top=offsetstr;
}

function incPanel(s)
{
	if (hoverTimer)
	{
		self.clearTimeout(hoverTimer);
	}
	hoverTimer=null;
	hoverStrP="";
	hoverStrS="";

	//document.getElementById(s).style.height="0px";
	start();
	openPanel(true, s);
	justClicked=true;
	if (justClickedTimer!=null) self.clearTimeout(justClickedTimer);
	justClickedTimer = self.setTimeout("EndClick()", 300);
	self.setTimeout("goVis('"+s+"');", 25);
}

function goVis(s)
{
	document.getElementById(s).style.visibility='visible';
}

function incPanelEx(s, p)
{
	if (hoverTimer)
	{
		self.clearTimeout(hoverTimer);
	}
	hoverTimer=null;
	hoverStrP="";
	hoverStrS="";

	if (p) panelClick(p);
	openPanel(false, s);
	document.getElementById(s).style.visibility='visible';
	justClicked=true;
	if (justClickedTimer!=null) self.clearTimeout(justClickedTimer);
	justClickedTimer = self.setTimeout("EndClick()", 300);
}

function EndClick()
{
	justClicked=false;
	justClickedTimer=null;
}

function decPanel(t)
{
	document.getElementById(t).style.visibility='hidden';
}

function panelClick(p)
{
	return;
	if (p=='psec')
	{
		document.getElementById("firewalls").style.visibility='hidden';
		document.getElementById("firewallwatchguard").style.visibility='hidden';
		document.getElementById("firewallcheckpoint").style.visibility='hidden';
		document.getElementById("antispam").style.visibility='hidden';
		document.getElementById("spyware").style.visibility='hidden';
		document.getElementById("reporting").style.visibility='hidden';
		document.getElementById("antivirus").style.visibility='hidden';
		// tbd: add other 2nd and 3rd tier security panels here
	}
	else if (p=='firewalls')
	{
		document.getElementById("firewallwatchguard").style.visibility='hidden';
		document.getElementById("firewallcheckpoint").style.visibility='hidden';
	}
	else if (p=='networking')
	{
		document.getElementById("hardware").style.visibility='hidden';
		document.getElementById("software").style.visibility='hidden';
	}
	else if (p=='hardware')
	{
			document.getElementById("software").style.visibility='hidden';
			document.getElementById("microsoft").style.visibility='hidden';
			document.getElementById("lotus").style.visibility='hidden';
			document.getElementById("routers").style.visibility='hidden';
			document.getElementById("servers").style.visibility='hidden';
	}
	else if (p=='software')
	{
			document.getElementById("hardware").style.visibility='hidden';
			document.getElementById("microsoft").style.visibility='hidden';
			document.getElementById("lotus").style.visibility='hidden';
			document.getElementById("routers").style.visibility='hidden';
			document.getElementById("servers").style.visibility='hidden';
	}
}

function hover(t)
{
	var s = "";
	var n = -1;
	n = t.src.indexOf("../images");
	if (n != -1)
		s = "../images/navbar/";
	else
		s = "images/navbar/";
	s = s + t.id;
	s = s + "2.gif";
	t.src = s;
}

function leave(t)
{
	var s = "";
	var n = -1;
	n = t.src.indexOf("../images");
	if (n != -1)
		s = "../images/navbar/";
	else
		s = "images/navbar/";
	s = s + t.id;
	s = s + "1.gif";
	t.src = s;
}




// redirection and cookie stuff===========================================
function redirect()
{
	var str = window.location.href;
	var res = -1;

	var l = readCookie("curLoc");
	if (l)
	{
		if (str.substring("home.htm")==-1)
		{
			document.getElementById("main").src = l;
			return;
		}
	}

	res = str.indexOf("?=");
	if (res>0)
	{
		var u = str.substring(res+2);
		if (u.indexOf(".htm")==-1)
			u = u + ".htm";
		document.getElementById("main").src = u;
		createCookie("curLoc", u, 0);
	}
	else
		{
			document.getElementById("main").src = "home.htm";
		}
}

function storeLoc(t)
{
	if (t=="blank.htm")
	{
		eraseCookie("curLoc");
		return;
	}
	createCookie("curLoc", t.href, 0);
}


function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}


function getNumList(s)
{
	var n = -1
	var count=0;
	var ht = document.getElementById(s).innerHTML;	
	n = ht.indexOf("<li>");
	//if (n==-1) return 50; // 50 is an error value to make it obvious

	while (n!=-1)
	{
		ht = ht.substring(n+2);
		count++;
		n = ht.indexOf("<li>");
	}
	return count;
}

function openWindow(lnk, w, h) {
	var win
	win = window.open(lnk, '', 'status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=' + w + ',height=' + h);
	win.focus();
}
