var Boxick=
{
	//All nodes that have this tag name and class name will bring up a pop-up box:
	tagName: 'a',
	className: 'boxick',

	//The width of the pop-up box:
	width: 300,

	//The height of the pop-up box (if the pop-up is a textbox -- as opposed to an IFRAME -- this value is ignored and the height will be determined by content instead):
	height: 300,

	//This function enables pop-up boxes in the document. Parameter: 'method' = 'mouseover' or 'click', default is 'click'
	enable: function(method)
	{
		//Look at each node called Boxick.tagName in the document. If it is of class Boxick.className, attach the Boxick.show function to it as a click event handler.
		var links=document.getElementsByTagName(Boxick.tagName);
		for(var i=0; i<links.length; i++)
		{
			var link=links[i];
			var classes=link.className.split(' ');
			var hasClass=false;
			for(var ii=0; ii<classes.length; ii++) if(classes[ii]==Boxick.className) hasClass=true;
			if(hasClass)
			{
				if(method=='mouseover')
				{
					link.onmouseover=Boxick.show;
					link.onmouseout=Boxick.hide;
				}
				else link.onclick=Boxick.show;
			}
		}
		
		//Attach an event handler to BODY, for hiding open pop-ups when the user clicks away:
		document.body.onclick=Boxick.hide;
	},

	hide: function()
	{
		//If a pop-up box is open, close it:
		if(document.getElementById('boxick'))
		{
			document.getElementById('boxick').parentNode.removeChild(document.getElementById('boxick'));
		}
	},

	show: function(e)
	{
		//Close any previously open pop-up boxes:
		Boxick.hide();
		
		//Capture the event object:
		 var event=window.event || e;	
		
		//Extend the event object so that the 'target' property contains a reference to the link clicked:
		if (!event.target) event.target=event.srcElement
		
		//Find the element the event was assigned to (as opposed to the element the event occured on):
		var target=event.target
		while(target.tagName.toLowerCase()!=Boxick.tagName & target.className!=Boxick.className)
		{
			target=event.target.parentNode;
		}

		//Create the div that will function as a pop-up box:
		var div=document.createElement('div');
		div.id='boxick';
		if(event.type=='mouseover') div.className='boxick_mouseover';
		else div.className='boxick_click';

		//If the link has a 'boxick' attribute, then its contents will be the contents of the pop-up:
		var isIframe=false;
		if(target.getAttribute('boxick')!=null & target.getAttribute('boxick')!='')
		{
			div.innerHTML='<div id="boxick_inside">'+target.getAttribute('boxick')+'</div>';
		}
		else //if not, then the pop-up's contents will be an IFRAME and the URL wil be the link's HREF attribute:
		{
			if(target.getAttribute('href')!=null & target.getAttribute('href')!='')
			{
				div.innerHTML='<iframe id="boxick_inside" frameborder="0" height="'+Boxick.height+'" width="'+Boxick.width+'" src="'+target.getAttribute('href')+'"></iframe>';
				isIframe=true;
			}
		}

		//Obtain coordinates of where the user clicked, in pixels, relative to the body element:
		var X, Y;
		if (document.all)
		 {
			X = event.clientX + document.documentElement.scrollLeft;
			Y = event.clientY + document.documentElement.scrollTop;
		 }
		else
		 { 
			X = event.pageX;
			Y = event.pageY;
		 } 

		//Determine offsets:
		if(event.type=='mouseover')
		{
			verticalOffset=20;
			horizontalOffset=10;
		}
		else
		{
			verticalOffset=-10;
			horizontalOffset=-15;
		}

		//Determine if the pop-up is left-aligned or right-aligned:
		if(document.body.offsetWidth<(X+Boxick.width))
		{
			horizontalOffset=-Boxick.width-horizontalOffset;
			div.style.backgroundPosition='top right';
		}

		//Size and position the div:
		div.style.position='absolute';
		div.style.width=Boxick.width+'px';
		if(isIframe) div.style.height=Boxick.height+'px';
		div.style.left = (X+horizontalOffset)+'px';
		div.style.top = (Y+verticalOffset)+'px'; 
		
		//Add the div as the last child of the offset parent element:
		if(div.innerHTML!='') document.body.appendChild(div);

		//Clicks on the pop-up's inner envelope will not bubble outside it:
		document.getElementById('boxick_inside').onclick=Boxick.nohide;

		//Set focus to the pop-up's inner envelope:
		document.getElementById('boxick_inside').focus();

		//Stop the event from bubbling:
		 if (event.stopPropagation)  event.stopPropagation();
		 else event.cancelBubble=true;

		//Return false to stop the link from navigating away:
		return false;
	},
	
	nohide: function(e)
	{
		//Capture the event object:
		 var event=window.event || e;

		//Stop the event from bubbling:
		 if (event.stopPropagation)  event.stopPropagation();
		 else event.cancelBubble=true;
	}

};