/////////////////////////////////////////////////////////////////////

// http://www.javascripter.net/faq/index.htm
//	http://www.ksu.ksu.edu/tools/browser_type/browser_type.html

setForce = 0;

function bigimage(tag, zoom)
{

//	return;
	lay  = document.getElementById('floatlayer');
	if (!lay)
	{
		lay = document.createElement('div');
		lay.innerHTML			=	'<a href="" onClick="bigimage();return false;">Bezárás</a>' +
									'<div>' + 
									'<img id="floatimage" alt="nincs" onMouseOut="bigimage();">'
									'</div>';
		lay.id					= 'floatlayer';
		lay.className			= 'big-image';
		lay.style.visibility	= 'hidden';
		lay.style.position		= 'absolute';
		lay.style.top			= '10px';
		lay.style.left			= '10px';
		lay.style.zIndex		= 0;
		document.body.appendChild(lay);
	}
	if (!tag || (lay.style.visibility   == 'visible'))
	{
		lay.style.visibility	= 'hidden';
	}
	else
	{
		img						= document.getElementById('floatimage');
		img.src					= tag.src;
		if (0 < navigator.userAgent.toLowerCase().indexOf("msie"))
		{
//			alert(document.documentElement.clientHeight);
			
			var windowH			= document.documentElement.clientHeight;  // document.body.offsetHeight;
			var windowW			= document.documentElement.clientWidth;  // document.body.offsetWidth;
			var scrollY			= window_scrollY();
			var scrollX			= window_scrollX();
			var imgH			= img.height;
			var imgW			= img.width;
			var areaH			= windowH * zoom / 100;
			var areaW			= windowW * zoom / 100;
			zoom				= ((windowH / windowW) < (imgH / imgW))
									? areaH / imgH
									: areaW / imgW;
			img.height			= imgH * zoom;
			var divH			= lay.clientHeight;
			var divW			= lay.clientWidth;
			lay.style.top		= scrollY + ((windowH - divH) / 2); //  - 20
			lay.style.left		= scrollX + ((windowW - divW) / 2);
		}
		else
		{
			var windowH			= window.innerHeight;
			var windowW			= window.innerWidth;
			var scrollY			= window.scrollY;
			var scrollX			= window.scrollX;
			var imgH			= img.height;
			var imgW			= img.width;
			var areaH			= windowH * zoom / 100;
			var areaW			= windowW * zoom / 100;
			zoom				= ((windowH / windowW) < (imgH / imgW))
									? areaH / imgH
									: areaW / imgW;
			img.height			= imgH * zoom;
			var divH			= lay.clientHeight;
			var divW			= lay.clientWidth;
			lay.style.top		= scrollY + ((windowH - divH) / 2) + 'px';//16
			lay.style.left		= scrollX + ((windowW - divW) / 2) + 'px';
		}
//		alert(
//		'document.body.scrollWidth: ' + document.body.scrollWidth +	'\n'+
//		'document.documentElement.clientHeight: ' + document.documentElement.clientHeight +	'\n'+
//		'document.body.scrollHeight: ' + document.body.scrollHeight  +	'\n'+
//		'document.documentElement.clientWidth: ' + document.documentElement.clientWidth
//		);
		lay.style.visibility	= 'visible';
	}
}

function window_scrollY()
{
	if (typeof window.scrollY != "undefined" )
	{
	//	NN6+ FireFox, Mozilla etc.
		return window.scrollY;
	}
	else if (typeof window.pageYOffset != "undefined")
	{
	//	NN4 still in NN6 + but NN6 and Mozilla added scrollY
		return window.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
	//	document.compatMode == "CSS1Compat" that is IE6 standards mode
		return document.documentElement.scrollTop;
	}
	else if (document.body && document.body.scrollTop) {
	//	document.compatMode != "CSS1Compat" that is quirks mode IE 6 or IE < 6 and Mac IE
		return document.body.scrollTop;
	}
	return 0;
}

function window_scrollX()
{
	if (typeof window.srcollX != "undefined")
	{
	//	"NN6+ FireFox, Mozilla etc."
		return window.scrollX;
	}
	else if (typeof window.pageXOffset != "undefined")
	{
	//	NN4 code still in NN6 + but scrollX was added
		return window.pageXOffset;
	}
	else if (document.documentElement && document.documentElement.scrollLeft)
	{
	//	document.compatMode == "CSS1Compat" that is IE6 standards mode"
		return document.documentElement.scrollLeft;
	}
	else if (document.body && document.body.scrollLeft)
	{
	//	document.compatMode != "CSS1Compat" that is quirks mode IE 6 or IE < 6 and Mac IE
		return document.body.scrollLeft;
	}
	return 0;
}

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
function showImage(tag, setForce)
{
//	parent.showBigImage(tag.href, setForce);
//	bigimage(tag);
}

function showBigImage(url, stateForce)
{
    if(stateForce)
    {
       setForce = 1;
    }
    x = document.getElementById("BIGIMAGE");
    x.innerHTML = close;
	x.innerHTML = '<a href="" onClick="closeBigImage(1);return false;">Bezárás</a><div id="imgaround" class="big-place"><img id="BIGIMAGESRC" width="450" onMouseOut="closeBigImage(0);"></div>';
//	x.innerHTML = \'<a href="" onClick="closeBigImage(1);return false;">Bezárás</a><div id="imgaround" class="big-place"><img id="BIGIMAGESRC" onMouseOut="closeBigImage(0);"></div>\';
//	x.height	= window.innerHeight;
    x.style.visibility = 'visible';
	x = document.getElementById("BIGIMAGESRC");
	x.src		= url;
//	x.height	= window.innerHeight;
}

function closeBigImage(force)
{
	if(setForce && force == 0)
	{
		return;
	}
	x = document.getElementById("BIGIMAGE");
	x.innerHTML = close;
	x.innerHTML = '<img id="BIGIMAGESRC" style="width:1;height:1;">';
	document.getElementById("BIGIMAGE").style.visibility='hidden';
}

