function changeMidPic(inId,inSrcId) {
	var tObj;
	var srcStr;
		tObj = document.getElementById('iMin_' + inId + '_' + inSrcId);
		srcStr = tObj.src;
	var iMid = document.getElementById('iMid_' + inId);
	if (iMid) {
		iMid.src = srcStr;
	};
	
};
function shimg(tPicPath,tHeight,tWidth, tHeadStr) {
	var divObj = document.getElementById('mg-showimg');
	var headObj = document.getElementById('mg-showimg-head');
	var bodyObj = document.getElementById('mg-showimg-body');
  
	  //do preload image
		imgPreloader = new Image();
		// once image is preloaded, resize image container
		imgPreloader.onload=function(){
			resizeAndMoveDiv(divObj, imgPreloader.width, imgPreloader.height);
			window.setTimeout('setInnerHTML("' + bodyObj.id + '","<img src=\'' + tPicPath + '\' width=\'' + imgPreloader.width + '\' height=\'' + imgPreloader.height + '\'>")',10);
		}
		imgPreloader.src = tPicPath;
	if (tHeight==0 || tWidth==0){
		imgPicPath = '/images/px.gif';
		tWidth = 100;
		tHeight= 100;
	}
	else{
		imgPicPath = tPicPath;
	}
	headObj.innerHTML='<img hspace=0 align=right src=/images/zamknij_okno.gif alt="zamknij" style="cursor:hand">';
	headObj.innerHTML += tHeadStr
	bodyObj.innerHTML = '<img src="' + imgPicPath + '">';
	divObj.style.display='block';
	resizeAndMoveDiv(divObj, tWidth, tHeight);
	 hideObjects('OBJECT');
}
function setInnerHTML(objId, str){
	var obj = document.getElementById(objId);
	obj.innerHTML = str;
}
function hideObjects(tagName){
	var tobj = document.getElementsByTagName(tagName);
	if (tobj){
		for (i=0; i<tobj.length; i++) {
			tobj[i].style.visibility ='hidden';	
		}	
		
	}
}
function showObjects(tagName){
	var tobj = document.getElementsByTagName(tagName);
	if (tobj){
		for (i=0; i<tobj.length; i++) {
			tobj[i].style.visibility ='visible';	
		}	
		
	}
}

function resizeAndMoveDiv(tdiv, twidth, theight){
  var myWidth = 0, myHeight = 0; //window dimension
   var scrOfX = 0, scrOfY = 0;
   //scroll
  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;
  }
  
  
  //size
  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;
  }
	tdiv.style.width = twidth + 20 + 'px';
	tdiv.style.height = theight + 40 + 'px';
	tdiv.style.top=(scrOfY+((myHeight)/2) - (theight/2) - 35) + 'px';
	tdiv.style.left=(scrOfX+((myWidth)/2) -(twidth/2) - 5) + 'px';
}



function hideDiv(obj){
	obj.style.display = 'none';	
	showObjects('OBJECT');
}

function toggle(item){
	obj= document.getElementById(item);
	visible = (obj.style.display!='none');
	if (visible){
		obj.style.display='none';
	}
	else {
		obj.style.display='block';
	}	
}


window.onload = function(){
		var objBody = document.getElementsByTagName('body').item(0);
		
		
		//shimg div
		var shimgObj = document.createElement('div');
		shimgObj.setAttribute('id','mg-showimg');
		shimgObj.onclick = function() { hideDiv(this); return false; }
		objBody.appendChild(shimgObj);
		
		//shimg header div
		var shimgHeaderObj = document.createElement('div');
		shimgHeaderObj.setAttribute('id','mg-showimg-head');
		shimgObj.appendChild(shimgHeaderObj);
		
		//shimg body div
		var shimgBodyObj = document.createElement('div');
		shimgBodyObj.setAttribute('id','mg-showimg-body');
		shimgObj.appendChild(shimgBodyObj);
		
		
}


