var ie = (navigator.appName == 'Microsoft Internet Explorer') && document.documentElement.clientWidth;

// limits page width for ie
function makelimit ()
{
	document.getElementsByTagName ('body') [0].style.width = ((document.documentElement.clientWidth < 1000) ? '1000px' : '100%');
}

// menu highlight function
function menu_highlight ()
{
	var classes = new Array;
	classes = this.className.split (' ');
	classes.push('active');
	this.className = classes.join(' ');
}

// menu cancel function
function menu_cancel ()
{
	var classes = new Array;
	classes = this.className.split (' ');
	for (var i=0; i<classes.length; i++)
		if (classes[i] == 'active')
		{
			classes.splice (i, 1);
			break;
		}
	this.className = classes.join(' ');
}

// initializes the page
function initpage ()
{
	// checking page width
	if (ie)
	{
		window.onresize = makelimit;
		makelimit ();
	}

	// replacing menu items with "submenu" class to be openable
	var list = document.getElementById ('menu').getElementsByTagName ('td');
	for (var i=0; i<list.length; i++)
	{
		list[i].onmouseover = menu_highlight;
		list[i].onmouseout = menu_cancel;
	}
}

// opens picture in new window
function showpicture (url, name, sizex, sizey)
{
	var picwindow = window.open ('', 'pic', 'width='+sizex+',height='+sizey+',location=0,toolbar=0,status=0,resizable=0');
	picwindow.document.write (
		"<html><head><title>'"+name+"'</title><style>html,body,img{margin:0;padding:0}</style></head><body>"+
		"<img src='"+url+"' title='"+name+"'>"+
		"</body></html>");
	picwindow.focus ();
}

// shows picture in special block
function showpictureinblock (url)
{
	var block = document.getElementById('picblock');
	var pic = block.getElementsByTagName('img')[0];
	pic.src='';
	pic.src=url;
	block.style.display = 'block';
}

