// browser check

is = new Object()
is.agent = navigator.userAgent.toLowerCase()
is.op = (is.agent.indexOf("opera") != -1)
if (is.op) {
	is.op7 = (is.op && is.agent.indexOf("opera 7") != -1)
	is.op8 = (is.op && is.agent.indexOf("opera 8") != -1)
} else {
	is.ie7 = (is.agent.indexOf("msie 7") != -1)
	is.ie6 = (is.agent.indexOf("msie 6") != -1)
	is.ie55 = (is.agent.indexOf("msie 5.5") != -1)
	is.ie5 = (!is.ie55 && is.agent.indexOf("msie 5") != -1)
	is.ns7 = (is.agent.indexOf("netscape/7") != -1)
	is.ns6 = (is.agent.indexOf("netscape/6") != -1)
	is.moz = (!is.ns7 && !is.ns6 && is.agent.indexOf("gecko") != -1)
	is.ffox = (is.agent.indexOf("firefox") != -1)
}
is.ie = (is.ie5 || is.ie55 || is.ie6 || is.ie7)
is.ns = (is.ns6 || is.ns7 || is.moz || is.ffox)
is.dom = (is.ie || is.ns || is.op7 || is.op8)

//window.focus()

if (!is.dom && !is.op) {
	alert("You are not using a standards compliant browser or are using an older browser.\r\nYou may not be able to view ITP.net in it's entirety and will not be able to use certain functions as intended or not at all.\r\n\r\nPlease upgrade you browser to one of the latest versions of either Internet Explorer, Netscape, Mozilla or Opera.")
}


// cell rollover functions with submenu

var menuArray = new Array("")

function cellOver(eObj,wCell,sText,wClass) {
  var wLink = wCell.id
	x = eval(wLink.length - 4)
	wLink = wLink.substr(0,x)
	var wLayer = document.getElementById(wLink + "Layer")
	/*if (wClass == 1) {
		if (eObj != wLink) {
			wCell.className = "lnover"
		}
	}
	else if (wClass == 2) {
		if (eObj != wLink) {
			wCell.className = "sublnover"
		}
	}
	else if (wClass == 3) {
		if (eObj != wLink) {
			wCell.className = "subsublnover"
		}
	}
	else if (wClass == 4) {
		if (eObj != wLink) {
			wCell.className = "subsublnover"
		}
	} */
	if (wLayer) {
		wLayer.style.visibility = "visible"
		if (is.ie) {
			allSelect = document.body.getElementsByTagName("SELECT")
			for(i = 0; i < allSelect.length; i++) {
				if(allSelect[i].getAttribute("nohide") != 1) {
					allSelect[i].style.visibility = "hidden"
				}
			}
		}
	}
	for(i = 1; i <= menuArray.length; i++) {
		if (menuArray[i] != wLink) {
			wLayer = document.getElementById(menuArray[i] + "Layer")
			if (wLayer) wLayer.style.visibility = "hidden"
		}
	}
	setStatus(sText)
}	

function cellOut(eObj,wCell,sText,wClass,setToggle) {
  var wLink = wCell.id
	x = eval(wLink.length - 4)
	wLink = wLink.substr(0,x)
	var wLayer = document.getElementById(wLink + "Layer")
	if (wClass == 1) {
		if (eObj != wLink) {
			wCell.className = "lnoff"
		}
	}
	else if (wClass == 2) {
		if (eObj != wLink) {
			wCell.className = "sublnoff"
		}
	}
	else if (wClass == 3) {
		if (eObj != wLink) {
			wCell.className = "subsublnoff"
		}
	}
	else if (wClass == 4) {
		if (eObj != wLink) {
			wCell.className = "subsublnoff"
		}
	}
	if (setToggle == "allow") {
		if (wLayer) wLayer.style.visibility = "hidden"
		if (is.ie) {
			allSelect = document.body.getElementsByTagName("SELECT");
			for(i = 0; i < allSelect.length; i++) {
				if(allSelect[i].getAttribute("nohide") != 1) {
					allSelect[i].style.visibility = "visible"
				}
			}
		}
	}
	setStatus(sText)
}

var chkLoad = 0
function cellLoad(eObj,wClass,eLink) {
	if (eObj) {
		wCell = document.getElementById(eObj + "Cell")
		if (eLink == 1) {
			document.getElementById(eObj).className = "lnlinkson"
			wCell.className = "lnon"
		}
		else if (eLink == 2) {
			document.getElementById(eObj).className = "sublnlinkson"
			wCell.className = "sublnon"
		}
		else if (eLink == 3) {
			document.getElementById(eObj).className = "subsublnlinkson"
			wCell.className = "subsublnon"
		}
		else if (eLink == 4) {
			document.getElementById(eObj).className = "subsublnlinkson"
			wCell.className = "subsublnon"
		}
		if (chkLoad == 0 || eLink >= 3) {
			wCell.style.borderRight = "5px solid " + pageColor
		}
		if (eLink >= 2) chkLoad = 1
		wImg = document.getElementById(eObj + "Img")
		if (wImg) {
			if (wImg.getAttribute('wside') == "r") wImg.src = "/pictures/furniture/arrow_r_w.gif"
			if (wImg.getAttribute('wside') == "d") wImg.src = "/pictures/furniture/arrow_d_w.gif"
		}
	}
}

function tableOut(sText,wLink) {
	for(i = 1; i <= menuArray.length; i++) {
		if (menuArray[i] != wLink) {
			wLayer = document.getElementById(menuArray[i] + "Layer")
			if (wLayer) wLayer.style.visibility = "hidden"
		}
	}
	if (is.ie) {
		allSelect = document.body.getElementsByTagName("SELECT")
		for(i = 0; i < allSelect.length; i++) {
			if(allSelect[i].getAttribute("nohide") != 1) {
				allSelect[i].style.visibility = "visible"
			}
		}
	}
	setStatus(sText)
}


// cell click function

function cellClick(cLink,wTarget) {
	if (cLink != '') {
		if (wTarget == '_blank') {
			window.open(cLink)
		}
		else {
			self.location.href = cLink
		}
	}
}


// set status bar text

window.defaultStatus = "Spectrum";

function setStatus(sText) {
  window.status = sText;
  return true;
}


// date

var d = new Date();
var dyArray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var mtArray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec");
dt = d.getDate();
mn = d.getMinutes();
hr = d.getHours();
dy = d.getDay();
mt = d.getMonth();
yr = d.getFullYear();

function writeDate() {
	document.write(dyArray[dy] + ", " + dt + " " + mtArray[mt] + ", " + yr);
}

function writeYear() {
	if (yr != 2001) y = document.write(" " + yr + " ");
}


// cookie

function cookieMaker(wAd,nameAd,wPath) {
	var cookieChk = 'yes'
	var cmt = mt
	var cdt = dt
	var chr = hr
	var cmn = mn
	if(mt < 10) {
		cmt = '0' + mt
	}
	if(dt < 10) {
		cdt = '0' + dt
	}
	if(hr < 10) {
		chr = '0' + hr
	}
	if(mn < 10) {
		cmn = '0' + mn
	}
	var sp = cmt + cdt + chr + cmn
	var cck = cookieChk
	if(cck == 'yes') {
		document.cookie = 'noAd=blank; path=/' + wPath + ';'
	}
	var ck = document.cookie
	osp = ck.substr(ck.indexOf(nameAd + '_x||') + nameAd.length + 4,ck.indexOf('||y_' + nameAd) - ck.indexOf(nameAd + '_x||') - nameAd.length - 4)
 	if(sp - osp >= minTimeOut && (cck == 'no' || (cck == 'yes' && ck.indexOf('d=bl') > 0)))  {
		d.setTime(d.getTime() + (minTimeOut * 60 * 1000))
		document.cookie = wAd + '=' + nameAd + '_x||' + sp + '||y_' + nameAd + '; path=/' + wPath + '; domain=www.itp.net; expires=' + d.toGMTString()
		return true
	}
}


// popup and eyeblaster

function getPopupAd(wPopup){
	setAttr = 'width=' + ppWidth + ',height=' + ppHeight + ',top=' + ppTop + ',left=' + ppLeft
	setAttr += ',titlebar=1,toolbar=0,location=0,menubar=0,scrollbars=0,resizable=0,channelmode=0,directories=0,status=0,maximize=no'
	var ppWin = window.open("", wPopup, setAttr, true)
	ppWin.location = ppURL
	ppWin.focus()
}

function getEyeblasterAd(wLayer) {
	if(is.ie) {
		document.getElementById(wLayer).style.visibility = "visible"
		setTimeout('document.getElementById(\'' + wLayer + '\').style.visibility = "hidden"',maxDisplay * 60 * 1000)
	}
}


// open external sites

function popSite(wPage) {
	openWindow(wPage,600,400,'yes');
}


// window opener

function openWindow(wPage,width,height,resize) {
  window.open(wPage,'window','toolbar=yes,location=no,status=no,menubar=yes,scrollbars=yes,resizable=' + resize + ',channelmode=no,directories=no,width=' + width + ',height=' + height + ',top=10,left=10');
}

function openComparision(wPage) {
  window.open(wPage,'window','toolbar=no,location=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,channelmode=no,directories=no,width=' + (screen.width - 30) + ',height=' + (screen.height - 80) + ',top=10,left=10');
}

// open window

function getSurvey(wId,sWidth,sHeight,sTop,sLeft){
	if (!sTop) sTop = screen.height/2 - sHeight/2
	if (!sLeft) sLeft = screen.width/2 - sWidth/2
	setAttr = 'width=' + sWidth + ',height=' + sHeight + ',top=' + sTop + ',left=' + sLeft
	setAttr += ',titlebar=1,toolbar=0,location=0,menubar=0,scrollbars=1,resizable=0,channelmode=0,directories=0,status=0,maximize=no'
	var sWin = window.open("", "Survey", setAttr, true)
	sWin.location = '/survey/survey.php?id=' + wId
	sWin.focus()
}


// jump window

function jumpTo(wSelect,wWindow) {
	wURL = wSelect.options[wSelect.selectedIndex].value
	if (wURL != '') {
		if (wWindow == 'new') {
			window.open('http://www.' + wURL)
		}
		else {
			document.location.href = wURL
		}
	}
}
