function buy(i)
{
 n=1;
 sendRPC('vtorbu.php?id='+i+'&n='+n+'&rnd='+Math.random());
}

function sendRPC(url)
{
//alert(url);
var newScript=document.createElement('script');
newScript.src=url;
newScript.type="text/javascript";
document.body.appendChild(newScript);
}

function tobask(n,sum,txt)
{
 //alert('tobask('+n+','+sum+')');
 alert(txt);
 if(!(n>0 && sum>0)) bsk0();
 else {
 bsk1();
 setinner('shtukas',n);
 setinner('sumsum',sum);
 }
}

function sh_hide(i,j)
{
if(document.getElementById(i))
  {
  v=document.getElementById(i).style.display;
  nn=see;
  if(v=="block") n="none";
  else {n="block";nn=hide;}
  document.getElementById(i).style.display=n;
  if(document.getElementById(j)) document.getElementById(j).title=nn;
  }
}

function spch(i)
{
document.write(sspch(i));
}

function spcw(i)
{
document.write(sspcw(i));
}

function spchw(i,j)
{
document.write(sspchw(i,j));
}

function sspch(i)
{
return '<div class=spacer style="height:'+i+'px"></div>';
}

function sspcw(i)
{
return '<div class=spacer style="width:'+i+'px"></div>';
}

function sspchw(i,j)
{
return '<div class=spacer style="height:'+i+'px;width:'+j+'px"></div>';
}

function bbttww()
{
document.write('<tr><td>'+sspch(12)+'</td></tr>'+
		'<tr><td background="i/zel.gif">'+sspcw(11)+'</td>');
}

function tablstat(t,i,b,r)
{
if(r) document.write(
		'<tr><td WIDTH="80%" style="background: url(i/line_for_title.gif);background-repeat:repeat-x;background-position:bottom left;"><b>');

document.write(t+'</td>'+
			'<td WIDTH="50%" style="background: url(i/line_for_title.gif);background-repeat:repeat-x;background-position:bottom left;"align=right><b>'+i+'</td></tr>');
}

function lll(i)
{
document.write('<img src="i/av'+i+'.png"></td><td>'+sspcw(8)+'</td><td class=mi>');
}

function lll1(i,y)
{
document.write('<td>'+sspcw(8)+'</td>'+
			'<td class=cylnkcy>'+i+'</td>'+
			'</tr>');
if(y) document.write(			
			'<tr><td colspan=5><img src="i/btwdot.gif"></td></tr>'+
			'<tr><td>');
}

function tbl1(tt)
{
document.write('<table border=0 cellpadding=0 cellspacing=0><tr><td '+tt+'>');
}

function tbl100(tt)
{
document.write('<table width="100%" border=0 cellpadding=0 cellspacing=0><tr><td '+tt+'>');
}

function chkempt(v,id)
{
 d=v;
 d=trim(d);
 if(d.length==0) off(id);
 else on(id);
}

function click_it(id)
{
 //alert('click_it('+id+')');
 if(document.getElementById(id))
 document.getElementById(id).click();
}

function isnemp(a)
{
 d=getval(a);
 d=trim(d);
 if(d=='') return 0;
 return 1;
 }

function showid(id)
{
 if(document.getElementById(id))
 document.getElementById(id).style.display="block";
}

function hideid(id)
{
 if(document.getElementById(id))
 document.getElementById(id).style.display="none";
}

function idstyle(id,s)
{
 document.getElementById(id).style.display=s;
}

function getstyle(id)
{
 return document.getElementById(id).style.display;
}
	
function on(i)
  {
   document.getElementById(i).disabled=false;
  }
  
  function off(i)
  {
   document.getElementById(i).disabled=true;
  }
  
  function setval(id,v)
{
 document.getElementById(id).value=v;
}

function getval(id)
{
 v=document.getElementById(id).value;
 return v;
}

function setinner(id,t)
{
 z=document.getElementById(id);
 if(z) z.innerHTML=t;
}

function getinner(id)
{
 z=document.getElementById(id);
 if(z) return z.innerHTML;
 return '';
}

 function trim(data) {
    return data.replace(/^\s*(.*?)\s*$/gi, '$1');
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function setCookie(nam,val)
{
 document.cookie = nam+"="+val;
}
