function print_spot_img (i,x,y)
{
if (document.all) {iex=0; iey=0;} else {iex=0; iey=0;}
document.getElementById("spot_imgs"+i).style.left=(getAbsX(x)-4-iex)+"px";
document.getElementById("spot_imgs"+i).style.top=(getAbsY(y)-5-iey)+"px";
}


function print_spot_divs (i, dir, imnum, descr)
{
document.write('<div id="spot_imgs'+i+'" style="position:absolute; visibility:visible; left:0px; top:0px;">');
document.write('<img border="0" style="cursor: pointer;" src="'+dir+'_images/spot'+imnum+'.gif" onmouseover="showDiv('+i+',\''+descr+'\');" onmouseout="hideDiv();" alt="" /></a>');
document.write('</div>');
}

function findPosX(){
	var obj=document.getElementById("mapid");
	var curleft = 0;
	obj = obj.offsetParent;
	while (obj.offsetParent){
		curleft += obj.offsetLeft
		obj = obj.offsetParent;		
	}  
	return curleft;
}

function findPosY(){
	var curtop = 0;
	var obj=document.getElementById("mapid");
	obj = obj.offsetParent;
	while (obj.offsetParent){
		curtop += obj.offsetTop;
		obj = obj.offsetParent;
	}  

	return curtop;
}

function getCrd(e) {
var X;
var Y;

   if (document.all) {
      X = event.clientX;
      Y = event.clientY;
   } else {
      X = e.clientX + window.scrollX;
      Y = e.clientY + window.scrollY;
   }
var left=findPosX();
var top=findPosY();

X=X-left;
Y=Y-top;

document.getElementById("x_coord").value=X;
document.getElementById("y_coord").value=Y;

putSpot(X,Y);
}

function getAbsX(val) {
var left=findPosX();
val=left+parseInt(val);
return val;
}

function getAbsY(val) {
var top=findPosY();
val=top+parseInt(val);
return val;
}

function putSpot(x,y) {
document.getElementById("spot_img").style.left=(getAbsX(x)-4)+"px";
document.getElementById("spot_img").style.top=(getAbsY(y)-5)+"px";
}

function check_new_m(form)
{
 if (form.name.value=='') { alert("Недопустимое название"); return 0;}
 return 1;
}
function hideDiv() {
document.getElementById("spot_info").style.visibility='hidden';
}

function showDiv(num, val) {
document.getElementById("spot_info").style.left=(parseInt(document.getElementById("spot_imgs"+num).style.left)+17)+"px";
document.getElementById("spot_info").style.top=document.getElementById("spot_imgs"+num).style.top;
document.getElementById("spot_info").innerHTML="<table cellspacing=0 cellpadding=0 style='border:1px solid #002B72; font-family: tahoma; font-size:10px; color:#002B72;' bgcolor=#FFFFFF><tr><td height='26' style='padding-left:5px; padding-right:5px;'>"+val+"</td></tr></table>";
document.getElementById("spot_info").style.visibility='visible';
document.getElementById("spot_info").style.zIndex=2;
document.getElementById("spot_info").style.width="150px";
}
