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 scrOfY;
}

function prew(url){
	// --- iztiiram pirmo div elementu
	document.getElementById('d1').innerHTML="";	
	// --- ieguustam poziicijasdutus
	var yy = getScrollXY();	
	// --- pzicioneejam abus div elementus	  
	document.getElementById('d1').style.top = yy+30+"px";
	document.getElementById('d2').style.top = yy+30+"px";	
	// --- paraadam otro div elementu un nosleepjam pirmo	
	document.getElementById('d1').style.display="none";
	document.getElementById('d2').style.display="block";	
	// --- izpildam otro div elementu
	document.getElementById('d1').innerHTML='<img id="prw" onload="prew2()" src="' + url + '" onClick="hide();"><div style="border-top: 1px solid #444; text-align: center; background-color: #ddd; padding: 2px"><a href="javascript: hide()" style="text-decoration: none; color: #000">aizvērt</a></div>';
}
function prew2(){
	document.getElementById('d2').style.display="none";
	document.getElementById('d1').style.display="block";
}
function hide(){
	document.getElementById('d1').style.display="none";
	document.getElementById('d2').style.display="none";
	document.getElementById('d1').innerHTML="";
}