var W3CDOM = (document.getElementById && document.getElementsByTagName);
var mouseOvers = new Array();
var mouseOuts = new Array();

// init top menu
function topOversInit()
{
	if (!W3CDOM) return;
	var nav = document.getElementById('top-links');
	var imgs = nav.getElementsByTagName('img');
	for (var i=0;i<imgs.length;i++)
	{
		imgs[i].onmouseover = mouseGoesOver;
		imgs[i].onmouseout = mouseGoesOut;
		var suffix = imgs[i].src.substring(imgs[i].src.lastIndexOf('.'));
		mouseOuts[i] = new Image();
		mouseOuts[i].src = imgs[i].src;
		mouseOvers[i] = new Image();
		mouseOvers[i].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('.')) + "-x" + suffix;
		imgs[i].number = i;
	}
}

function mouseGoesOver()
{
	this.src = mouseOvers[this.number].src;
}

function mouseGoesOut()
{
	this.src = mouseOuts[this.number].src;
}


function showImg(imgFile, width, height, selImg, selPos, lang, imgCount, captionLen) {
	y = 0
	width=width+20
	height=height+35+(selImg!="")*20 + Math.floor(captionLen/(width/7.5))*15

	if(height > screen.availHeight-30)
  { ah = screen.availHeight-30
  	sbars=1
	width=width+14
  }
  else 
  { ah=height;
  	sbars=0
    if (screen.availHeight-height > 100)
    {  y = (screen.availHeight-height)/5
  }
  }

  x = (screen.width/3)-(width/3)
  if (x < 0) {x=0;}

  ustawienia="width="+width+",height="+ah
			+",top="+y+",left="+x
			+",resizable=1,status=0,scrollbars="+sbars
  windowName=window.open("show-image.php?file=" + imgFile + "&selection_image="+selImg+"&selection_position="+selPos + "&lang=" + lang,"larguier"+imgCount,ustawienia)
  windowName.focus()
}
