function imagePopUp(obj,w,h)
{
var imgPath = obj.src;
var newWindow = window.open("","", "status=0, TOP=200, LEFT=200, HEIGHT="+h+",WIDTH="+w);
newWindow.document.write("<html><head><title>Preview</title></head><body style='padding:0;margin:0;'>");
newWindow.document.write("<img src="+imgPath+" style='cursor:pointer' onclick='window.close()' alt='Закрыть изображение'>");
newWindow.document.write("</body></html>");
newWindow.document.close();
}

function getElementPosition(offsetTrail, ol, ot){
        var offsetLeft = ol;
        var offsetTop = ot;
        while(offsetTrail) {
        	offsetLeft += offsetTrail.offsetLeft;
                offsetTop += offsetTrail.offsetTop;
                offsetTrail = offsetTrail.offsetParent;
        }
        return { left:offsetLeft, top:offsetTop }
}

function showtip (v, evt, ch, ol, ot) {
	if (document.getElementById(v)) {

       var winWidth = document.body.clientWidth;
       var evt = evt || window.event;
       var o = evt.target || evt.srcElement;
       var div = document.getElementById(v);
       var coords = getElementPosition(o,ol,ot);

	document.getElementById("chislo").innerHTML = '<span>' + ch + '</span>';
	var w = 200;
	document.getElementById(v).style.top=(coords.top + o.offsetHeight) + 'px';
	     if((winWidth - coords.left) < w) 
 		document.getElementById(v).style.left = (coords.left  - 10 - (w - (winWidth - coords.left)))+ 'px';
	    else
       	             document.getElementById(v).style.left = coords.left + 'px';
	document.getElementById(v).style.visibility='visible';
	return false;
	}
}

function hidetip (v) {
	if (document.getElementById(v)) {
		document.getElementById(v).style.visibility='hidden';
		return false;
	}
}
