function browseShortcut(event)
{
	if (!document.getElementById) return;
	if (window.event) event = window.event;
	if (event.ctrlKey)
	{
		var code = event.keyCode ? event.keyCode : event.which ? event.which : null;
		var id = '';
		switch (code)
		{
			case 37:
				id = 'browse_prev';
				break;
			case 38:
				id = 'browse_up';
				break;
			case 39:
				id = 'browse_next';
				break;
			case 40:
				id = 'browse_down';
				break;
		}
		if (id)
		{
			var link = document.getElementById(id);
			if (link && link.href) document.location = link.href;
		}
	}			
}

document.onkeydown = browseShortcut;

function tr0()
{
	this.className = 'tr0';
}
function tr1()
{
	this.className = 'tr1';
}
function tr2()
{
	this.className = 'tr2';
}
function initMouseOver()
{
	var c = document.getElementsByTagName('tr');
	for (var i = 0; i < c.length; i++)
	{
		if (c[i].className == "tr0" || c[i].className == "tr1")
		{
			c[i].onmouseover = tr2;
			c[i].onmouseout = c[i].className == "tr0" ? tr0 : tr1;
		}
	}
}
function initBody()
{
	initMouseOver();
}
function openPicture(url, x, y)
{
	if (x && y)
		window.open(url, 'submit', 'width=' + x + ',height=' + y);
	else
		window.open(url, 'submit', 'width=120,height=60');
}
function openWindow(url)
{
	window.open(url, 'submit', 'width=320,height=180');
}
function exURL(url, target)
{
	var j = url.indexOf("javascript:") == 0;
	var b = window.location.href.indexOf("&back=");
	b = "&back=" + escape((b == -1) ? window.location.href : window.location.href.substr(0, b));

	if (url.indexOf("/?a=") == 0) url = "http://infostore.org" + url + b;
	else if (url.indexOf("?a=") == 0) url = "http://infostore.org/" + url + b;

	if (target == '_blank' && !j)
		window.open(url);
	else
		window.location = url;
}
function exCancel(event, cancel_default)
{
	if (event)
	{
		if (cancel_default && event.preventDefault)
			event.preventDefault();

		if (event.stopPropagation)
                	event.stopPropagation();
		else
			event.cancelBubble = true;
	}

	return true;
}
function isA(e)
{
	while(e)
	{
		if (e.tagName == 'A') return true;
		e = e.parentNode;
	}
	return false;
}
function goURL(url, event)
{
	if (!event)
		event = window.event;

	if (isA(event ? (event.target ? event.target : event.srcElement) : null))
	{
		return true;
	}
	else
	{
		if (event.shiftKey)
		{
			exURL(url, '_blank');
			exCancel(event, true);
		}
		else
		{
			exURL(url, '_self');
			exCancel(event, false);
		}
		return false;
	}
}
