var ie = (document.getElementById && document.all);
// =========================================================================
function ShowImage(SenderObj,SenderEvent)
{
//	alert(SenderObj.href);	
	
	over = document.getElementById("overlay");
	if (over)	
	{	
		BodyObj = document.getElementsByTagName("body");
		BodyObj[0].removeChild(over);	
	}
	over = document.createElement('div');	
	over.setAttribute("id","overlay");
	BodyObj = document.getElementsByTagName("body");
	BodyObj[0].appendChild(over);
	
	
	r = getPageSize();
	over.style.height = r[1] +"px";
//	return false;
	
	ImageDivObj = document.getElementById("FullImageDiv");
	if (ImageDivObj)	
	{	
		BodyObj = document.getElementsByTagName("body");
		BodyObj[0].removeChild(ImageDivObj);	
	}
	
	ImageDivObj = document.createElement('div');	
	ImageDivObj.setAttribute("id","FullImageDiv");	
	ImageDivObj.className = "h";
	ImageDivObj.innerHTML = PrepareTable();
	
	BodyObj = document.getElementsByTagName("body");
	BodyObj[0].appendChild(ImageDivObj);
	
	
	
	
	ImageObj = document.createElement('img');
	ImageObj.onclick = DestroyFullImage;
	ImageObj.onload = SetImagePosition;	
	ImageObj.setAttribute("id","FullImage");
	ImageObj.setAttribute("alt","");
	ImageObj.setAttribute("title","Kliknij aby zamknąć - Click to close");
	ImageObj.setAttribute("src",SenderObj.href);
//	ImageObj.setAttribute("height",'800px');	
//	ImageObj.setAttribute("width",'600px');
//	ImageObj.className = "ukryte";
	
	tmp = document.getElementById("FullImageTd");
	
	tmp.appendChild(ImageObj);	
	
	
	if (ie)		
	{
		left1  = (document.documentElement.offsetWidth /2)  - 300;
		top1 = 120;
	}	
	else
	{
		left1  = (window.innerWidth /2)  - 300;
		top1  = 120;
	}
	if(top1 < 45)
		top1 = 45;
	ImageDivObj.style.left = left1 + 'px';
	ImageDivObj.style.top = top1 + 'px';
	ImageDivObj.className = "v";
	return false;
}
//----------------------------------------------------------------------------------------
function PrepareTable()
{
	retval = "";
	
	retval += "<table class='fullimg'>";
	
	
	retval += "<tr>";
	retval += "<td class='lt'></td>";	
	retval += "<td class='t'></td>";	
	retval += "<td class='rt'></td>";	
	retval += "</tr>";
	
	retval += "<tr>";
	retval += "<td class='l'></td>";	
	retval += "<td class='img' id='FullImageTd'></td>";	
	retval += "<td class='r'></td>";	
	retval += "</tr>";
	
	retval += "<tr>";
	retval += "<td class='lb'></td>";	
	retval += "<td class='b'></td>";	
	retval += "<td class='rb'></td>";	
	retval += "</tr>";
	
	
	retval += "</table>";
	
	return retval;	
	
}
// ----------------------------------------------------------------------------------------
function SetImagePosition()
{
	ImageDivObj = document.getElementById("FullImageDiv");
	
	if (ie)
	{
		left1  = (document.documentElement.offsetWidth /2)  - (ImageDivObj.offsetWidth /2);
		top1 = (document.documentElement.offsetHeight /2)  - (ImageDivObj.offsetHeight /2);
	}	
	else
	{
		left1  = (window.innerWidth /2)  - (ImageDivObj.offsetWidth /2);
		top1  = (window.innerHeight /2)  - (ImageDivObj.offsetHeight /2);
	}
	top1 = top1 + document.documentElement.scrollTop;
	if(top1 < 45)
		top1 = 45;
	ImageDivObj.style.left = left1 + 'px';
	ImageDivObj.style.top = top1 + 'px';
	//ImageDivObj.offsetWidth
}
// ----------------------------------------------------------------------------------------
function DestroyFullImage()
{
	ImageDivObj = document.getElementById("FullImageDiv");
	if (ImageDivObj)	
	{	
		BodyObj = document.getElementsByTagName("body");
		BodyObj[0].removeChild(ImageDivObj);	
	}	over = document.getElementById("overlay");
	if (over)	
	{	
		BodyObj = document.getElementsByTagName("body");
		BodyObj[0].removeChild(over);	
	}
}
//----------------------------------------------------------------------------------------
function getPageSize()
{
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


