// -*- java -*-

// new window parameters
var chunk_window_params = 'width=400,height=400,resizable=no,scrollbars=no,toolbar=no,location=no,status=no,menubar=no';

/*
 * handle all clicks here
 */
function transformLinksChunk(doc)  //{{{
{
	 doc.onclick = function(e) 
		 {
				/*
				 * get target element from event
				 */
				e = e || doc.parentWindow.event;
				var link = e.target || e.srcElement;
				
				/*
				 * navigate up tree until link is found
				 */
				while (link && 
							 link.tagName &&
							 "a" != link.tagName.toLowerCase()
							 ) 
					{
						 link = link.parentNode;
					}

				/*
				 * make sure link was found
				 */
				if (link &&
						link.tagName &&
						"a" == link.tagName.toLowerCase() &&
						link.getAttribute('rel')
						) 
					{
						 return handleLinkChunk(link);
					}
		 }
	 
	 return true;
}
//}}}

/*
 * what to do with link
 */
function handleLinkChunk(link) //{{{
{
	 var rel = link.getAttribute("rel");
	 
	 if (rel) 
		 {
				/*
				 * new tab/window, so open first
				 * and then make it the target
				 * to avoid IE not setting the referrer with window.open
				 */
				if ("_" == rel.substring(0, 1) ||
						"new" == rel || 
						"newwindow" == rel) 
					{
						 window.open('', 
												 rel, 
												 'newwindow' == rel ? chunk_window_params : ''
												 );
					}
				
				link.target = rel;
		 }
	 
	 return true;
}
//}}}

/*
 * hide link to frameset
 * unless not in frameset
 */
function hideLink(doc) //{{{
{
	 if (top.framesetLoaded) 
		 {
				var p = doc.getElementById('frameset_p');
				if (p) 
					{
						 p.className = 'hide_frameset_links';
					}
		 }
}
//}}}

