function openAddBasket(h) {
 tmpstr='';
 count=document.getElementById('totalextra').value;
 for (i=1; i<=count; i++)
 {
  if (document.getElementById('extra'+i).checked) tmpstr+=document.getElementById('extra'+i).value+"_";
 }
 if (tmpstr!='') tmpstr=tmpstr.substring(0,tmpstr.length-1);
 
  var rw=Math.round(Math.random()*100000000);
  var myWin=open("/_basket.php?id="+h+"&extras="+tmpstr,rw,"width=350,height=300;resize=false; left="+Math.round(screen.width/2-250)+"; top="+Math.round(screen.height/2-135)+";");
}
function openAddBasket_corp(h,sale) {
 tmpstr='';
 count=document.getElementById('totalextra').value;
 for (i=1; i<=count; i++)
 {
  if (document.getElementById('extra'+i).checked) tmpstr+=document.getElementById('extra'+i).value+"_";
 }
 if (tmpstr!='') tmpstr=tmpstr.substring(0,tmpstr.length-1);
 
  var rw=Math.round(Math.random()*100000000);
  var myWin=open("/_basket_corp.php?id="+h+"&sale="+sale+"&extras="+tmpstr,rw,"width=350,height=300;resize=false; left="+Math.round(screen.width/2-250)+"; top="+Math.round(screen.height/2-135)+";");
}



function openSendFriend(h) {
  var rw=Math.round(Math.random()*100000000);
  var myWin=open("/_sendfriend.php?id="+h,rw,"width=450,height=600;resize=false; left="+Math.round(screen.width/2-250)+"; top="+Math.round(screen.height/2-135)+";");
}

function is_number(str)
{
 for (var i=0; i<str.length; i++) if (isNaN(parseInt(str.charAt(i)))) return 0;
 return 1;
}


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, link, descr)
{
document.write('<div id="spot_imgs'+i+'" style="position:absolute; visibility:visible; left:0px; top:0px;">');
document.write('<a href="'+link+'"><img border="0" style="cursor: pointer;" src="'+dir+'_images/spot.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";
}


function clearcookie ()
{
document.cookie="bsk=; path=/; expires=1;";
document.cookie="extrabsk=; path=/; expires=1;";
document.cookie="bsk_corp=; path=/; expires=1;";
document.cookie="extrabsk_corp=; path=/; expires=1;";
}


function findPosX_m(id){
	var obj=document.getElementById(id);
	var curleft = 0;
	obj = obj.offsetParent;
	while (obj.offsetParent){
		curleft += obj.offsetLeft
		obj = obj.offsetParent;		
	}  
	return curleft;
}

function findPosY_m(id){
	var curtop = 0;
	var obj=document.getElementById(id);
	obj = obj.offsetParent;
	while (obj.offsetParent){
		curtop += obj.offsetTop;
		obj = obj.offsetParent;
	}  

	return curtop;
}
//var basedir="/";
var scr=basedir+'_scripts/img.html';

function showImage(img)
{

wnnn=window.open(scr+'?'+escape(img),'win','resizable,width=400,height=200,screenX=0,screenY=0,top=0,left=0');
wnnn.focus();
}




function showImageGal(parent_id, prior)
{
 title=document.title; 
 params="width=300,height=300,scrollbars=0, resizable=0";
 wndgal=window.open('../_showimg.php?title='+title+'&parent_id='+parent_id+'&prior='+prior,"",params);

}