function setBGColour( mySelection, myBGColour )
{
	mySelection.style.backgroundColor = myBGColour;
}

function setClass( mySelection, myClass )
{
	mySelection.className = myClass;
}

function showPopup( popupDivID )
{
	var scroll = findWindowScrollXY();
	var scrollX = scroll[0];
	var scrollY = scroll[1];
	
	var winHeight = 0, winWidth = 0;
	// find window height and width
	if( typeof( window.innerHeight ) == 'number' ) {
		//Non-IE
		winHeight = window.innerHeight;
		winWidth = window.innerWidth;
	} else if( document.documentElement &&  document.documentElement.clientHeight ) {
		//IE 6+ in 'standards compliant mode'
		winHeight = document.documentElement.clientHeight;
		winWidth = document.documentElement.clientWidth;
	} else if( document.body && document.body.clientHeight ) {
		//IE 4 compatible
		winHeight = document.body.clientHeight;
		winWidth = document.body.clientWidth;
	}
	
	// set visibility, position and width of popup div
	var popupDiv = document.getElementById( popupDivID );
	popupDiv.style.visibility='visible';
	popupDiv.style.display='block';
	popupDiv.style.top = 40 + scrollY + 'px';
	popupDiv.style.left = scrollX + 'px';
	popupDiv.style.width = winWidth + 'px';
	
	// set visibility and position of background div
	var popupBG = document.getElementById('PopupBG');
	popupBG.style.visibility='visible';
	popupBG.style.display='block';
	popupBG.style.top = scrollY + 'px';
	popupBG.style.left = scrollX + 'px';
//	popupBG.style.height = document.body.offsetHeight + 'px';
	if(document.body.offsetHeight > winHeight) popupBG.style.height = document.body.offsetHeight + 'px';
	else popupBG.style.height = winHeight + 'px';

	// add transparent iframe to position underneath menu div and over windowed elements such as select lists
	// this fixes a bug in IE6 where 'windowed' elements don't follow z-index rules as expected
	if(typeof document.body.insertAdjacentHTML != 'undefined') {
		var ie6fix = document.getElementById('IE6FixIframePopup');
		if(ie6fix == null) {
			document.body.insertAdjacentHTML('beforeEnd', '<iframe id="IE6FixIframePopup" class="IE6FixIframe" src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
			ie6fix = document.getElementById('IE6FixIframePopup');
		}
		ie6fix.style.top = popupBG.style.top;
		ie6fix.style.left = popupBG.style.left;
		ie6fix.style.width = '100%';
		ie6fix.style.height = popupBG.style.height;
		ie6fix.style.visibility = 'visible';
		ie6fix.style.display = 'block';
	}

	var popupMain = document.getElementById(popupDivID + 'Main');
	// if popup is too tall for window...
	if(popupMain.offsetHeight > (winHeight - 80)) {
		// ...adjust content width to allow for scrollbar...
		var contentDiv = document.getElementById(popupDivID + 'Content');
		contentDiv.style.marginLeft = '10px';
		contentDiv.style.marginRight = '10px';
		// ...and reduce popup height
		contentDiv.style.width = contentDiv.offsetWidth - 20 + 'px';
		popupMain.style.height = winHeight - 80 + 'px';
		popupMain.style.overflow = 'scroll';
	}

	// remove scrollbars
	document.body.style.overflow='hidden';
	document.getElementsByTagName('html')[0].style.overflow = 'hidden';
	// scroll back to original window position (Firefox)
	window.scroll(scrollX,scrollY);
}

function hidePopup( popupDivID )
{
	document.getElementById( popupDivID ).style.visibility='hidden';
	document.getElementById( popupDivID ).style.display='none';
	document.getElementById('PopupBG').style.visibility='hidden';
	document.getElementById('PopupBG').style.display='none';
	if(typeof document.body.insertAdjacentHTML != 'undefined') {
		var ie6fix = document.getElementById('IE6FixIframePopup');
		if(ie6fix != null) {
			ie6fix.style.visibility = 'hidden';
			ie6fix.style.display = 'none';
		}
	}
	document.body.style.overflow='auto';
	document.getElementsByTagName('html')[0].style.overflow = 'auto';
}

function open_window(url,width,height)
{
	param = 'toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width='+width+',height='+height+',left=0,top=0'
	NewWin  = window.open(url,'Help' + String.fromCharCode(97 + Math.round(Math.random() * 25)) ,param);
	NewWin.focus();
}

function enterPressed(e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return false;

	if (keycode == 13) return true;
	return false;
}

function textBoxBtnClick(e, btnID)
{
	if(enterPressed(e))
		__doPostBack(btnID,'CLICK');
}

function findPosX(obj)
{
	var curleft = 0;
	if(obj.offsetParent)
			while(1) 
			{
				curleft += obj.offsetLeft;
				if(!obj.offsetParent)
					break;
				obj = obj.offsetParent;
			}
	else if(obj.x)
			curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if(obj.offsetParent)
			while(1)
			{
				curtop += obj.offsetTop;
				if(!obj.offsetParent)
					break;
				obj = obj.offsetParent;
			}
	else if(obj.y)
			curtop += obj.y;
	return curtop;
}

function findWindowScrollXY() {
  var scrX = 0, scrY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrY = window.pageYOffset;
    scrX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrY = document.body.scrollTop;
    scrX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrY = document.documentElement.scrollTop;
    scrX = document.documentElement.scrollLeft;
  }
  return [ scrX, scrY ];
}
