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,picId) {
	var divObj = document.getElementById('mg-showimg');
	var headObj = document.getElementById('mg-showimg-head');
	var bodyObj = document.getElementById('mg-showimg-body');
	var footObj = document.getElementById('mg-showimg-foot');
	var imgObj = document.getElementById('shimg_' + picId);
	var title = "";
	if (imgObj) {
		title = imgObj.title;
		if (title.length==0 && imgObj.alt.length>0) {title=imgObj.alt;}
	}
	  //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);
			//window.setTimeout('resizeFootDiv("' + title + '","'+imgPreloader.width+')',10);
			resizeFootDiv(footObj,title, imgPreloader.width);
		}
		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=img/zamknij_okno.gif alt="zamknij" style="cursor:hand">';
	headObj.innerHTML += 'powiększenie zdjęcia: <b>' + tHeadStr + '</b>';
	bodyObj.innerHTML = '<img src="' + imgPicPath + '">';
	bodyObj.style.height=tHeight + 'px';
	divObj.style.display='block';
	resizeAndMoveDiv(divObj, tWidth, tHeight);
	resizeFootDiv(footObj,title, tWidth);
}
function resizeFootDiv(footObj,str, thisWidht) {
		//alert(thisWidht);
		if (str.length>0) {
			footObj.innerHTML = str;
			footObj.style.width= (thisWidht -10) + 'px';
			footObj.style.display='';
		}
		else {
			footObj.innerHTML = '';
			footObj.style.display='none';
		}
}

function setInnerHTML(objId, str){
	var obj = document.getElementById(objId);
	obj.innerHTML = str;
}

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';	
}

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);
		
		//shimg header div
		var shimgFootObj = document.createElement('div');
		shimgFootObj.setAttribute('id','mg-showimg-foot');
		shimgObj.appendChild(shimgFootObj);
		
		
		
}

