

function init(){
	if(!document.all && !document.getElementById)
		return;
	if(document.body.style)
		document.body.style.visibility = "visible";
	if(!document.getElementById)
		return;
	makeMenu();
	rollOvers();
	if(gE("circleMenu"))
		window.oCircle = new circleMenu("oCircle", "circleMenu", 165, 115, 460, 90, 24, Math.PI/16);
	if(getObject("subNav"))
		window.oSubContent	=	new oDhtml("subNav", "", 1);
	positionH2Images()
	animateInputs();
};

function makeMenu(){
	aLI = document.getElementsByTagName("LI");
	for(var i=0; i<aLI.length; i++){
		if(aLI[i].className == "mainMenu"){
			var o = window["oMenu" + i] =	new oDhtml("menu" + i);
			o.write(aLI[i].innerHTML);
			if(!location.search){
				o.setProperties(0, 100, 140, 30, 'visible');
				o.slideTo(0, 100 + 30 * i - 1, 40 * (i + 1), "slower");			
			}else{
				o.setProperties(0, 100 + 30 * i - 1, 140, 30, 'visible');
			};
			o.setZIndex(999);
		};
	};
	var aA = document.getElementsByTagName("A");
	for(i=0; i< aA.length; i++){
		if(aA[i].href == location.href.toString()){
			aA[i].className = aA[i].className.replace(/Off\b/,'On');
		};
	};
	if(location.search){
		o = new oDhtml("menuLine");
		o.setProperties(140, (brow.ieBox && !brow.mac) ? 128 : 131, 30, 100, "visible");
		o.css.borderTop = "1px solid #666";
	};	
};

function rollOvers(){
	var aImg = document.getElementsByTagName("IMG");
	for(var i=0; i< aImg.length; i++){
		if(aImg[i].src.indexOf("_off") != -1){
			window["overImage" + i] = new Image();
			window["overImage" + i].src = aImg[i].src.replace(/_off\b/,'_on');
			aImg[i].onmouseover = function(){this.src = this.src.replace(/_off_/,'_on_')};
			
			aImg[i].onmouseout = function(){this.src = this.src.replace(/_on_/,'_off_')};
		};
	};
};
function gE(sId){
	return document.getElementById(sId);
};

var aColours = new Array("#fff", "#ECF7F7", "#DAEFEF", "#C6E7E7", "#DAEFEF");

function positionH2Images(){
	var aImages = document.getElementsByClassName("h2Image")
	for(var i=0; i<aImages.length; i++){
		aImages[i].style.left = "552px";
		aImages[i].style.top = parseInt(document.getElementsByTagName("H2")[i].offsetTop) + parseInt(gE("content").offsetTop) - 12 + "px";
		aImages[i].style.visibility = "visible";
	};
};

function animateInputs(){
	var aForm = [] 
	var aInput = document.getElementsByTagName("INPUT")
	for(var i=0; i<aInput.length; i++){
		if(aInput[i].type == "text" || aInput[i].type == "checkbox"){
			aInput[i].onfocus = function focused(){
				animateBackground(this.id, 0, 1);
			}
			aInput[i].onblur = function focused(){
				animateBackground(this.id, 1, 0);
			};
		};
	};
	var aTextarea = document.getElementsByTagName("TEXTAREA")
	for(i=0; i<aTextarea.length; i++){
		aTextarea[i].onfocus = function focused(){
			animateBackground(this.id, 0, 1);
		}
		aTextarea[i].onblur = function focused(){
			animateBackground(this.id, 1, 0);
		};
	};
};

function animateBackground(nId, nInc, bFocus){
	gE(nId).style.backgroundColor = (bFocus) ? aColours[nInc] : aColours[aColours.length - nInc - 1];
	if(nInc++ < aColours.length - 1)
		setTimeout("animateBackground('" + nId + "', " + nInc +", " + bFocus +")", 50);
};

window.onscroll = function(){
	if(window.oSubContent){
		if(oSubContent.h < doc.windowHeight - 50){
			var nTop = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : (document.body) ? document.body.scrollTop : 0;
			nTop = (nTop < 120) ? 120 : nTop +20;
			var sEndScroll = (nTop > 120) ? "scrollEnd()" : "";
			oSubContent.slideTo(oSubContent.x, nTop, 2000, "faster", sEndScroll);
		};
	};
};

function scrollEnd(){
	oSubContent.slideBy(0, -12, 160, 'slower');
	setTimeout("oSubContent.slideBy(0, 12, 140, 'faster')", 170);
	setTimeout("oSubContent.slideBy(0, -6, 80, 'slower')", 315);
	setTimeout("oSubContent.slideBy(0, 6, 50, 'faster')", 400);
};

function popupWin(sUrl, nWidth, nHeight){
	getObject("popup").src = sUrl;
	getObject("popup").style.left = 770 - nWidth + "px";
	getObject("popup").style.width = nWidth + "px";
	getObject("popup").style.height = nHeight + "px";
	getObject("popup").style.visibility = "visible";
	return false;
};

function killPopup(){
	getObject("popup").style.visibility = "hidden";
	getObject("popup").style.left = "-400px";
	getObject("popup").src = "about:blank";
};

function pop(sUrl, nWidth, nHeight){
	//	use popupWin() where possible
	window.open(sUrl, "win" + nWidth + nHeight, "width=" + nWidth + ",height=" + nHeight + ",left=" + (screen.availWidth - nWidth) / 2 + ",top=" + (screen.availHeight - nHeight) / 2 + ",scrollbars=yes");
	return false;
};


if(document.layers){
	var nOrigWidth = innerWidth;
	var nOrigHeight = innerHeight;
	window.onresize = function(){
		if(innerWidth != nOrigWidth || innerHeight != nOrigHeight)
			location.reload();
	};
};