function ShowImage (url, resX, resY, title, uid) {
	maxX=screen.availWidth;
	maxY=screen.availHeight-40;
	scrollbars=0;
	if (resX>maxX) {reX=maxX;leftC=0;scrollbars=1;}else {reX=parseInt(resX)+5;leftC=(maxX-resX)/2;}
	if (resY>maxY) {reY=maxY;reX+=20;topC=0;scrollbars=1;}else {reY=resY;topC=(maxY-resY)/2;}
	w=window.open('', 'ph_'+uid, 'width=' + reX + ',height=' + reY+',status=0,toolbar=0,resizable=1, top='+topC+', left='+leftC+',scrollbars='+scrollbars);
	if (title!=""){title1=title;}else{	title1="";}
	lead_url=url.substr(0,1);

	if (lead_url=="."){
		url=""+url.substr(1);
	}
	w.document.open();
	w.document.write('<html><head><title>' + title1 + '</title></head>');
	w.document.write('<body style="margin:0px;padding:1px;" bgcolor="#ffffff" onKeyPress="if (event.keyCode==27) window.close();">');
	w.document.write('<center><a onclick="javascript:window.close();">');
	w.document.write('<img border=0 align=center src="'+url+'" alt="'+title+' \n\nДля закрытия окна, кликните по картинке" width="'+resX+'" height="'+resY+'"></a>');
	if (title!=""){
		w.document.write('<br />'+title+'');
	}
	w.document.write('</center></body></html>');
	w.document.close();
	if (w!=null){w.focus();};
}

function ShowImageOnPage(url, resX, resY, title, orig_img_id){
	img=SelectById(orig_img_id);
	if (img){
		img.src=url;
		img.alt=title;
		img.width=resX;
		img.height=resY;

	}else{
		ShowImage(url, resX, resY, title);
	}
}

function SE(domain,addr){
	em=addr+"@"+domain;
	document.write("<a href=\"mailto:"+em+"\">"+em+"</a>");
}

var object_select_type="";
if (document.getElementById) {
	object_select_type = "byelementid";
} else if (document.all){
	object_select_type = "all";
} else if (document.layers){
	object_select_type = "layers";
}


function SelectById(id){
	if (object_select_type=="byelementid"){
		return document.getElementById(id);
	}
	if (object_select_type=="all"){
		return document.all[id];
	}
	if (object_select_type=="layers"){
		return document.layers[id];
	}
}


    function show(ob) 
    { 
      var okno = "scrollbars=1,fullscreen=0,status=0,toolbar=0,"+ 
                 "top=0,left=0,width=600,height=460,resizable=1"; 
      var Win=window.open("", null, okno); 
      Win.document.open(); 
      var i; 
      var s = ""; 
      for (i in ob) s += "<B>"+i+"</B>"+" = "+ob[i]+"<BR>"; 
      Win.document.write(s); 
      Win.document.close(); 
    } 


function _get_obj_leftpos(obj){
	var left = obj.offsetLeft;
	while( (obj = obj.offsetParent) != null ){
		left += obj.offsetLeft;
	}
	return left;
}

function _get_obj_toppos(obj){
	var top = obj.offsetTop;
	while( (obj = obj.offsetParent) != null ){
		top += obj.offsetTop;
	}
	return top;
}

function ShowBlock(a_id,div_id,show,focus){
	item_div=SelectById(div_id);

	if (show){
		item_a=SelectById(a_id);

		left_pos=_get_obj_leftpos(item_a);
		top_pos=_get_obj_toppos(item_a);


		var height_a = parseInt( item_a.style.height ) ? parseInt( item_a.style.height ) : item_a.offsetHeight;

		item_div.style.top    = top_pos + height_a*2 + "px";
		item_div.style.left   = left_pos + "px";

		item_div.style.display="";

		var width = parseInt( item_div.style.width ) ? parseInt( item_div.style.width ) : item_div.offsetWidth;

		var negpad = true;
//		alert(left_pos+" "+width+ " "+ document.body.clientWidth);
		if ( (left_pos + width) >= document.body.clientWidth )
		{
//			new_left_pos =  left_pos - (document.body.clientWidth -  left_pos - width) ;
			left_pos =  document.body.clientWidth - width;

			negpad  = false;
		}
//		left_pos += ( negpad ) ? -2 : 2;
//		alert(left_pos);
		item_div.style.left   = left_pos + "px";
		item_div.style.zIndex = 100;

		item_div.style.display="";
		if (focus){
		    SelectById(focus).focus();
		}
	}else{
		item_div.style.display="none";

	}
}
