
function attachEventListener(target, eventType, functionRef, capture)
{
	if (typeof target.addEventListener != 'undefined')
	{
		target.addEventListener(eventType, functionRef, capture);
	}
	else if (typeof target.attachEvent != 'undefined')
	{
		target.attachEvent('on' + eventType, functionRef);
	}
	else
	{
		eventType = 'on' + eventType;

		if (typeof target[eventType] == 'function')
		{
			var oldListener = target[eventType];

			target[eventType] = function()
			{
				oldListener();

				return functionRef();
			}
		}
		else
		{
			target[eventType] = functionRef;
		}
	}
	
	return true;
}



function addLoadListener(fn)
{
	if (typeof window.addEventListener != 'undefined')
	{
		window.addEventListener('load', fn, false);
	}
	else if (typeof document.addEventListener != 'undefined')
	{
		document.addEventListener('load', fn, false);
	}
	else if (typeof window.attachEvent != 'undefined')
	{
		window.attachEvent('onload', fn);
	}
	else
	{
		var oldfn = window.onload;
		if (typeof window.onload != 'function')
		{
			window.onload = fn;
		}
		else
		{
			window.onload = function()
			{
				oldfn();
				fn();
			};
		}
	}
}

function report ( id, title, url, format, access ) {
   document.getElementById('linkbox').src = encodeURI('http://www.nla.gov.au/app/logger/logger.php?project=eresources&url='+url+'&id='+id+'&format='+format+'&title='+title+'&access='+access+'&rnd='+Math.random()) ;
}

function loguser (id, ip) { 
   if (id.length > 0) {
	   document.getElementById('linkbox').src = encodeURI('http://www.nla.gov.au/app/logger/authlogs.php?project=eresources&id='+id+'&ip='+ip+'&rnd='+Math.random()) ;
   }
}

function logquery (q) { 
   if (q.length > 0) {
	   document.getElementById('linkbox').src = encodeURI('http://www.nla.gov.au/app/logger/querylogs.php?project=eresources&q='+q+'&rnd='+Math.random()) ;
   }
}

/*
Due to the login DIV being absolutely positioned it's height can grow
and overlap the content.  This script checks the height of the DIV &
adjusts the position of the container DIV to avoid any overlap
*/


addLoadListener(checkHeight)

function checkHeight()
{
	if (typeof document.getElementById == 'undefined') { return; }

	var login = document.getElementById('login');
	var loginHeight = login.clientHeight;	
	
	if (loginHeight > 140) {
		var containerPos = document.getElementById('container');
		pixels = loginHeight-140
		containerPos.style.marginTop = pixels + "px";
	}
}
