//GENERIC FUNCTIONS
function captureObj(objID){
	if(document.layers){
		showBrowserPop();
	}else{
		if(document.getElementById){
			capObj = document.getElementById(objID);
		}else{
			capObj = document.all[objID];
		}
	}
	return capObj;
}

try { eval(pgTitle.length); 	}catch(exception){ pgTitle="Welcome"; }
try{ eval(scriptPath.length); 	}catch(exception){ scriptPath="../generic_scripts/"; }
try{ eval(imagePath.length); 	}catch(exception){ imagePath="images/"; }

document.write("<title>BB Technologies :: "+pgTitle+"</title>");
self.status = "BB Technologies :: " + pgTitle;

function setHTML(objID,htmlCont){
	actObj = captureObj(objID);
	actObj.innerHTML = htmlCont;
}

function remSpaces(lbl){
	aLbl = lbl.split(" ");
	return aLbl.join("");
}

function remPlix(lbl){
	sPlix = lbl.split("'");
	aLbl = sPlix.join("");

	dPlix = aLbl.split('"');
	aLbl = dPlix.join("");
	return aLbl;
}

function setActiveStyle(objID){
	actObj = captureObj(objID);

	if(NS){
		clickPath = actObj.href.toString();
		clickParams = clickPath.substring(21,clickPath.length-1);
		actObj.className += "active";
		actObj.parentNode.className += "active";
		tglSubMnu(clickParams);
	}else{
		actObj.click();
		actObj.className += "active";
	}
}

function doNothing(){}

var genTools = true;
function toolButton(lnk){
	switch(lnk){
		case "calendar":
			popCalendar();
			break;
		case "clock":
			cWidth = 170;
			cHeight = 220;
			cLeft = (screen.width/2)-(cWidth/2);
			cTop = (screen.height/2)-(cHeight/2);
			cDims = cWidth+","+cHeight+","+cLeft+","+cTop
			handleLink('N','','links/clock/RoundClock.html',cDims);
			break;
		case "colourpick":
			cWidth = 215;
			cHeight = 90;
			cLeft = (screen.width/2)-(cWidth/2);
			cTop = (screen.height/2)-(cHeight/2);
			cDims = cWidth+","+cHeight+","+cLeft+","+cTop
			handleLink('N','','links/notepad/colourpicker.html',cDims);
			break;
		case "calculator":
			showCalculator();
			break;
		case "notepad":
			cWidth = 316;
			cHeight = 460;
			cLeft = (screen.width/2)-(cWidth/2);
			cTop = (screen.height/2)-(cHeight/2);
			cDims = cWidth+","+cHeight+","+cLeft+","+cTop
			handleLink('N','','links/notepad/Notepad.html',cDims);
			break;
		case "refresh":
			document.location.reload();
			break;
	}
}

function setForPrint(){
	mnContent = captureObj('maincontent');
	mnContent.style.overflowY = "visible";
}

function resetFromPrint(){
	mnContent = captureObj('maincontent');
	mnContent.style.overflowY = "auto";
}

function preloadImages(){
	if(document.images){
		noImgs = document.images.length;
		for(io=0; io<noImgs; io++){
			imgObj = document.images[io];
			if(imgObj.readyState != "complete"){
				imgObj.src = imgObj.src;
			}
		}
	}
}

function controlMouseClicks(){
	if(NS){
		document.body.addEventListener("oncontextmenu",nocontextmenu, false);
		init();
	}else{
		document.body.oncontextmenu = nocontextmenu;
	}
}

function nocontextmenu(){
	window.event.cancelBubble = true;
	window.event.returnValue = false;
	return false;
}

//NETSCAPE SCROLLER
var strtScrollPos = 0;
var hghtText = 0;
var scrollHeight = 0; //The height of the scroll track minus the height of the scroll button and margins
var scrolling = false;
var scrollButton;
var scrollText;
var scrollDiv;

function whereIsNamedItem(iName){
	nmdItems = document.getElementsByName(iName);
	nmdItem = nmdItems[0];
	cumHeight = nmdItem.offsetTop;

	scButTop = (cumHeight/hghtText)*scrollHeight;
	if(scButTop > scrollHeight){
		scButTop = scrollHeight;
	}

	scrollButton.style.top = scButTop;
	scrollText.style.top = 0-cumHeight+16;
}

function startScroll(e){
	scrolling = true;
}

function releaseScroll(){
	scrolling = false;
	reset();
}

function handleScroll(me){
	if(scrolling){
		newPos = me.pageY - 80;
		if(newPos > -1 && newPos < scrollHeight){
			scrollButton.style.top = newPos;
			scrollText.style.top = 0-((newPos/scrollHeight)*hghtText);
		}
	}
}

function reset(){
	document.releaseEvents(Event.MOUSEMOVE);
}

function init(){
	document.captureEvents(Event.MOUSEUP);
	document.captureEvents(Event.MOUSEMOVE);
	document.onmouseup=releaseScroll;
	document.onmousemove=handleScroll;
	scrollButton = document.getElementById('scrollbar');
	scrollText = document.getElementById('scrollingcontent');
	scrollDiv = document.getElementById('scroller');

	bodyHght = document.body.offsetHeight;
	mnContHght= captureObj('maincontent').style.height;
	mnContHghtPX = mnContHght.substring(0,mnContHght.length-2);

	diffBody = screen.height - bodyHght;
	diffMnCont = bodyHght - mnContHghtPX;
	diffScroll = captureObj('maintext').offsetTop;

	hghtText = scrollText.offsetHeight - qlHeight;
	scrollHeight = qlHeight-21;
}