function showBig(source,height,width){
  all = getPageSize();
  cWidth = all[0];
  cHeight = all[1];
  wWidth = all[2];
  wHeight = all[3];
  scrollTop = all[4];
  scrollLeft = all[5];

  div = document.createElement('div');
  hider = document.createElement('div');
  hider.className = 'showerHider';
  hider.style.height = cHeight + "px";
  div.className = 'showerBig';
  if ((height+50) > wHeight){
    curHeight = wHeight - 50;
    top = 10 + scrollTop;
  }else{
    curHeight = height;
    top = (wHeight - height) / 2 + scrollTop;
  }
  if (width > wWidth){
    curWidth = wWidth;
    left = 0  + scrollLeft;
  }else{
    curWidth = width;
    left = (wWidth - width) / 2 + scrollLeft;
  }
  div.style.width = curWidth + "px";
  div.style.height = (curHeight + 25) + "px";
  div.style.top = top + "px";  
  div.style.left = left + "px";
  div.innerHTML = "<img src='"+source+"' styl='width:"+curWidth+"px;height:"+curHeight+"px;' /><div class='showerHideButton' onclick='showerClose();'><img src='/all/showerclose.gif'></div>"; 
  document.body.appendChild(hider);
  document.body.appendChild(div);
}

function showerWheel(){
  all = getPageSize();
  cWidth = all[0];
  cHeight = all[1];
  wWidth = all[2];
  wHeight = all[3];
  scrollTop = all[4];
  scrollLeft = all[5];
  
  div.style.top = top + "px";  
  div.style.left = left + "px";
}

function showerClose(){
  document.body.removeChild(div);
  document.body.removeChild(hider);
  div = null;
}

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 if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
		xScroll = document.documentElement.scrollWidth;
		yScroll = document.documentElement.scrollHeight;
	} else { // Explorer Mac...would also work in 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;
	}
	
	pageScrollTop = self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
	pageScrollLeft = self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);

	return [pageWidth,pageHeight,windowWidth,windowHeight,pageScrollTop,pageScrollLeft];
}

function showImage(n,c,w){
  cur_image += n;
  go_to = "";
  if (cur_image == 0){
    document.getElementById('image').src="/imgprev/"+w+".jpg";
  }else{
    go_to += "<a href='/division/"+par+"/"+el+"/' onclick='return showImage(-1,"+c+","+w+");'>&laquo; предыдущее</a>";
    document.getElementById('image').src="/imgprev/"+w+"_"+cur_image+".jpg";
  }
  go_to += "{"+(cur_image+1)+" из "+c+"}";
  if (cur_image+1 != c){
    go_to += "<a href='/division/"+par+"/"+el+"/"+(cur_image+1)+"/' onclick='return showImage(1,"+c+","+w+");'>следующее &raquo;</a>";
  }
  document.getElementById("goto_panel").innerHTML = go_to;
  return false;
}

document.body.onmousewheel = showerWheel;
