/* Tools
---------------------- */
function getById(el)
{
	return document.getElementById(el);
}

function getByTag(par,el)
{
	var par = (par == '') ? document.body : par;
	if (!par) return new Array();
	return par.getElementsByTagName(el);
}

function addClass(obj,newClass)
{
	if(!obj.className.match(new RegExp(newClass)))
		obj.className+=(obj.className.length>0? " ": "") + newClass;
}
	

function setLinks(linkTags)
{
	var linkCollection = [];
	for (var j = 0; linkTags[j]; j++)
	{
		linkCollection[j] = getByTag('',linkTags[j]);
		for (var i = 0; linkCollection[j][i]; i++) {
			if(/bookmark|external|corporate|sponsor|download/.test(linkCollection[j][i].getAttribute('rel')))
			{
				linkCollection[j][i].onclick = function(e) {
					if (!e) var e = window.event;
					if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey)
						return true;
					window.open(this.href);
					return false;
				}
			}
			else if(/print/.test(linkCollection[j][i].getAttribute('rel'))) {
				linkCollection[j][i].onclick = function() {
					if(window.print()) window.print();
					return false;
				}
			}
			else if(/zoom/.test(linkCollection[j][i].getAttribute('rel'))) {
				new Zoom(linkCollection[j][i]);
			}
		}
	}
}


/* Init
-------------------- */
var init = function()
{
	if (arguments.callee.done) return;
	arguments.callee.done = true;
	if (_timer) {
		clearInterval(_timer);
		_timer = null;
	}

	if(!document.getElementsByTagName) return;
		
	addClass(getById('wrapper'),'scripted');
	setLinks(['a','area']);
}

if (/WebKit/i.test(navigator.userAgent))
{ // sniff
	var _timer = setInterval(function() { if (/loaded|complete/.test(document.readyState)) { init(); } }, 10);
}
else if (document.addEventListener)
{
	document.addEventListener("DOMContentLoaded", init, false);
}
else
{	
	/*@end @*/
	window.onload = init;
}
