// need to check the browser
function browsercheck(){
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=browsercheck()

// A unit of measure that will be added when setting the position of a layer.
var px = bw.ns4||window.opera?"":"px";

// to head off loading rollover errors
var ready = 0;
var index = 0;

// number of menu items starting at zero
var mNumber = 4;

// menu layout 0 = across, 1 = down
var mLayout=0

// width of each menu item
var mWidth = 100;

// pixels between each menu item
var mSpace = 0;

// left position of first menu item
var mLeft = 265;

// top position of menu items
var mTop = 40;

// menu bgColor of the bottom mouseover div
var mBgColor = '#000000';

// menu bgColor to change to
var mBgColorHover = '#ff0000';

// position the mouseover line div will stop at when going up
var mHeight = 21;
// var mouseID = '';

// thank you Thomas Brattli at www.bratta.com
// ie = document.all ? 1 : 0;
// ns = document.layers ? 1 : 0;

// load "off" states whenever
home0 = new Image();
site0 = new Image();
contact0 = new Image();
investor0 = new Image();
homebase0 = new Image();
search0 = new Image();
img00 = new Image();
img10 = new Image();
img20 = new Image();
img30 = new Image();
img40 = new Image();

if ((document.location.href.indexOf('index.shtml') > 0) || ((document.location.href.indexOf('html') < 0) && (document.location.href.indexOf('cgi') < 0))) {
	index = 1;
	ixmyhb0 = new Image();
	turnkey0 = new Image();
	customer0 = new Image();
	solid0 = new Image();
	ixmyhb0.src = "img/ix_my_homebase_0.gif";
	turnkey0.src = "img/turnkey_solutions_0.gif";
	customer0.src = "img/customer_driven_0.gif";
	solid0.src = "img/solid_foundation_0.gif";
	home0.src = "img/nav/home_x_0.gif";
	site0.src = "img/nav/site_x_0.gif";
	contact0.src = "img/nav/contact_x_0.gif";
	investor0.src = "img/nav/investor_x_0.gif";
	homebase0.src = "img/nav/homebase_x_0.gif";
	search0.src = "img/nav/search_x_0.gif";
	img00.src = "img/nav/company_x_0.gif";
	img10.src = "img/nav/products_x_0.gif";
	img20.src = "img/nav/partners_x_0.gif";
	img30.src = "img/nav/careers_x_0.gif";
	img40.src = "img/nav/support_x_0.gif";
} else {
	homebase0.src = "img/nav/homebase_0.gif";
	home0.src = "img/nav/home_0.gif";
	site0.src = "img/nav/site_0.gif";
	contact0.src = "img/nav/contact_0.gif";
	investor0.src = "img/nav/investor_0.gif";
	search0.src = "img/nav/search_0.gif";
	img00.src = "img/nav/company_0.gif";
	img10.src = "img/nav/products_0.gif";
	img20.src = "img/nav/partners_0.gif";
	img30.src = "img/nav/careers_0.gif";
	img40.src = "img/nav/support_0.gif";
}

std_dsl0 = new Image(); std_dsl0.src = "img/nav/internet_access_dsl_0.gif";
bus_dsl0 = new Image(); bus_dsl0.src = "img/nav/business_lan_dsl_0.gif";
vpn0 = new Image(); vpn0.src = "img/nav/vpn_0.gif";
fire0 = new Image(); fire0.src = "img/nav/firewall_security_0.gif";
host0 = new Image(); host0.src = "img/nav/web_hosting_0.gif";
ecomm0 = new Image(); ecomm0.src = "img/nav/ecommerce_0.gif";
email0 = new Image(); email0.src = "img/nav/business_email_0.gif";
domain0 = new Image(); domain0.src = "img/nav/domain_services_0.gif";
colo0 = new Image(); colo0.src = "img/nav/colocation_0.gif";
bur0 = new Image(); bur0.src = "img/nav/online_backup_0.gif";

function imgState(which, state) {
	if (!ready) return false;
	document[which].src =  eval(which + state + '.src');
	return true;
}

// rollovers shunted till ready
function preloadImgs() {
	home1 = new Image(); home1.src = "img/nav/home_1.gif";
	site1 = new Image(); site1.src = "img/nav/site_1.gif";
	contact1 = new Image(); contact1.src = "img/nav/contact_1.gif";
	investor1 = new Image(); investor1.src = "img/nav/investor_1.gif";
	homebase1 = new Image(); homebase1.src = "img/nav/homebase_1.gif";
	search1 = new Image(); search1.src = "img/nav/search_1.gif";
	img01 = new Image(); img01.src = "img/nav/company_1.gif";
	img11 = new Image(); img11.src = "img/nav/products_1.gif";
	img21 = new Image(); img21.src = "img/nav/partners_1.gif";
	img31 = new Image(); img31.src = "img/nav/careers_1.gif";
	img41 = new Image(); img41.src = "img/nav/support_1.gif";
	std_dsl1 = new Image(); std_dsl1.src = "img/nav/internet_access_dsl_1.gif";
	bus_dsl1 = new Image(); bus_dsl1.src = "img/nav/business_lan_dsl_1.gif";
	vpn1 = new Image(); vpn1.src = "img/nav/vpn_1.gif";
	fire1 = new Image(); fire1.src = "img/nav/firewall_security_1.gif";
	host1 = new Image(); host1.src = "img/nav/web_hosting_1.gif";
	ecomm1 = new Image(); ecomm1.src = "img/nav/ecommerce_1.gif";
	email1 = new Image(); email1.src = "img/nav/business_email_1.gif";
	domain1 = new Image(); domain1.src = "img/nav/domain_services_1.gif";
	colo1 = new Image(); colo1.src = "img/nav/colocation_1.gif";
	bur1 = new Image(); bur1.src = "img/nav/online_backup_1.gif";
	if ((document.location.href.indexOf('index.shtml') > 0) || ((document.location.href.indexOf('html') < 0) && (document.location.href.indexOf('cgi') < 0))) {
		turnkey1 = new Image(); turnkey1.src = "img/turnkey_solutions_1.gif";
		customer1 = new Image(); customer1.src = "img/customer_driven_1.gif";
		solid1 = new Image(); solid1.src = "img/solid_foundation_1.gif";
		ixmyhb1 = new Image(); ixmyhb1.src = "img/ix_my_homebase_1.gif";
	}
	return (ready = true);
}

function checkMouse(e) {
//	if (!ready) return;
//	var x = 0;
//	var y = 0;
//	if (ie) {
//		x = window.event.clientX;
//		y = window.event.clientY;
//	} else {
//		x = e.pageX;
//		y = e.pageY;
//	}
//	var within = false;
//	for(i = 0; i <= mNumber; i++) {
//		if (y < oTopMenu[i][1].y + oTopMenu[i][0].y && y > oTopMenu[i][0].y && x > oTopMenu[i][0].x && x < oTopMenu[i][0].x + mWidth) {
//			within = true;
//		}
//	}
//	if (!within && mouseID == '') {
//		mouseID = setTimeout("allUp(-1)", 500);
//	}
}

// constructor
function makeNewsMenu(obj,nest){
	nest=(!nest) ? "":'document.'+nest+'.'
   	this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+"document.layers." +obj):0;
	this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.evnt.offsetHeight
	this.moveIt=b_moveIt;this.bgChange=b_bgChange;
	this.slideUp=b_slideUp; this.slideDown=b_slideDown;
	this.clipTo=b_clipTo;
    this.obj = obj + "Object"; 	eval(this.obj + "=this")
}

// methods
function b_moveIt(x,y) {
	this.x=x;
	this.y=y;
	this.css.left=this.x+px;
	this.css.top=this.y+px;
}

function b_bgChange(color) {
	this.css.backgroundColor=color;
	this.css.bgColor=color;
	this.css.background=color;
}

function b_clipTo(t,r,b,l) {
	if(bw.ns4) {
		this.css.clip.top=t;
		this.css.clip.right=r;
		this.css.clip.bottom=b;
		this.css.clip.left=l;
	} else {
		this.css.clip="rect("+t+"px "+r+"px "+b+"px "+l+"px)";
	}
}

function b_slideUp(ystop,moveby,speed,fn,wh) {
//	if (mouseID != '') {
//		clearTimeout(mouseID);
//		mouseID = '';
//	}
//	if(!this.slideactive) {
		if(this.y>ystop) {
			this.moveIt(this.x,this.y-25);
			eval(wh);
			setTimeout(this.obj+".slideUp("+ystop+","+moveby+","+speed+",'"+fn+"','"+wh+"')",speed);
		} else {
			this.slideactive=false;
			this.moveIt(0,ystop);
			eval(fn);
//			imgState('img' + fn.substring(9, 10), 0);
		}
	}
//}

function b_slideDown(ystop,moveby,speed,fn,wh) {
//	if (mouseID != '') {
//		clearTimeout(mouseID);
//		mouseID = '';
//	}
//	if(!this.slideactive) {
		if(this.y<ystop) {
			this.moveIt(this.x,this.y+10);
			eval(wh);
			setTimeout(this.obj+".slideDown("+ystop+","+moveby+","+speed+",'"+fn+"','"+wh+"')",speed);
		} else {
			this.slideactive=false;
			this.moveIt(0,ystop);
			eval(fn);
		}
	}
//}



// Initiating the page, making cross-browser objects
function newsMenuInit() {
	oTopMenu=new Array();
	zindex=10;
	for(i=0;i<=mNumber;i++) {
		oTopMenu[i]=new Array();
		oTopMenu[i][0]=new makeNewsMenu('divTopMenu'+i);
		oTopMenu[i][1]=new makeNewsMenu('divTopMenuBottom'+i,'divTopMenu'+i);
		oTopMenu[i][2]=new makeNewsMenu('divTopMenuText'+i,'divTopMenu'+i);
		oTopMenu[i][1].moveIt(0,mHeight);
		oTopMenu[i][0].clipTo(0,mWidth,mHeight+3,0);
		if(!mLayout) {
			oTopMenu[i][0].moveIt(i*mWidth+mLeft+(i*mSpace),mTop);
		} else {
			oTopMenu[i][0].moveIt(mLeft,i*mHeight+mTop+(i*mSpace));
			oTopMenu[i][0].css.zIndex=zindex--;
		}
		oTopMenu[i][0].css.visibility="visible";
	}
}

function allUp(ignore) {
	if (!ready) return false;
	for(i = 0; i <= mNumber; i++) {
		if(i != ignore) {
			if (oTopMenu[i][1].timerId != '') {
				clearTimeout(oTopMenu[i][1].timerId);
				oTopMenu[i][1].timerId = '';
			}
			oTopMenu[i][1].slideUp(mHeight, 10, 40, 'oTopMenu[' + i + '][0].clipTo(0,101,oTopMenu[' + i + '][1].y,0)', 'oTopMenu[' + i + '][0].clipTo(0,101,oTopMenu[' + i + '][1].y,0)');
			/* this will roll it up right away
			if (oTopMenu[i][1].y > mHeight) {
				oTopMenu[i][1].moveIt(oTopMenu[i][1].x, mHeight);
			} else {
				oTopMenu[i][1].moveIt(0, mHeight);
				oTopMenu[i][0].clipTo(0,101,oTopMenu[i][1].y,0);
				if (ie) {
					imgState('img'+i,0);
				}
			}
			*/
		}
	}
//	mouseID = '';
}

//Moves the menu
function topMenu(num){
	if(oTopMenu[num][1].y==mHeight) oTopMenu[num][1].slideDown(oTopMenu[num][2].scrollHeight+20,10,40,'oTopMenu['+num+'][0].clipTo(0,mWidth,oTopMenu['+num+'][1].y+3,0)','oTopMenu['+num+'][0].clipTo(0,mWidth,oTopMenu['+num+'][1].y+3,0)')
	else if(oTopMenu[num][1].y==oTopMenu[num][2].scrollHeight+20) oTopMenu[num][1].slideUp(mHeight,10,40,'oTopMenu['+num+'][0].clipTo(0,mWidth,oTopMenu['+num+'][1].y+3,0)','oTopMenu['+num+'][0].clipTo(0,mWidth,oTopMenu['+num+'][1].y+3,0)')
}

// Moves the menu
function downMenu(num) {
	if(oTopMenu[num][1].y == mHeight) {
		allUp(num);
		oTopMenu[num][1].slideDown(oTopMenu[num][2].scrollHeight+20,10,40,'oTopMenu['+num+'][0].clipTo(0,mWidth,oTopMenu['+num+'][1].y+3,0)','oTopMenu['+num+'][0].clipTo(0,mWidth,oTopMenu['+num+'][1].y+3,0)');
		openmenu = num;
	}
}

function upMenu(num) {
	if(num < 0) return false;
	if(oTopMenu[num][1].y == oTopMenu[num][2].scrollHeight + 20) {
		oTopMenu[num][1].slideUp(mHeight,10,40,'oTopMenu['+num+'][0].clipTo(0,mWidth,oTopMenu['+num+'][1].y+3,0)','oTopMenu['+num+'][0].clipTo(0,mWidth,oTopMenu['+num+'][1].y+3,0)');
	}
}

//Changes background onmouseover
function menuOver(num) {
	oTopMenu[num][1].bgChange(mBgColorHover)
}
function menuOut(num) {
	oTopMenu[num][1].bgChange(mBgColor)
}

// - - - - -
onload=newsMenuInit;
if (document.all) {
	document.onmousemove = checkMouse;
} else {
	document.captureEvents(Event.MOUSEMOVE);
	document.onMouseMove = checkMouse;
}


