var tabl1='<table border=0 cellpadding=0 cellspacing=0';
var tabl100_1=tabl1+' width="100%"><tr><td';
var tabl100_10=tabl1+'><tr><td';

function randomNumber (m,n)
{
  m = parseInt(m);
  n = parseInt(n);
  return Math.floor( Math.random() * (n - m + 1) ) + m;
}

function show_stat_pic(i,a)
{
s='<img src="uploads/statti/'+i+'"';
if(a=='') s+='>';
else s+=' title="'+a+'" alt="'+a+'" border=0><br><center>'+a+'</center>';
document.write(s);
}

function show_stat_pic_foo(i,a)
{
s='<img src="uploads/statti/'+i+'"';
if(a!='') s+=' title="'+a+'" alt="'+a+'"';
s+=' hspace=7 style="vertical-align:middle"> ';
document.write(s);
}

function show_stat_pic1(i,a)
{
s='<img src="uploads/statti/pre/'+i+'"';
if(a=='') s+='>';
else s+=' title="'+a+'" alt="'+a+'" border=0><br><center>'+a+'</center>';
document.write(s);
}



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;}
  if(nn==see) nn='&#8594; '+nn; else nn='&#8592; '+nn;
  document.getElementById(i).style.display=n;
  if(document.getElementById(j)) {document.getElementById(j).title=nn;setinner(j,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 chkempt1(v,v1,id)
{
 d=v;
 d=trim(d);
 d1=v1;
 d1=trim(d1);
 if(d1!='' && d!='') on(id);
 else off(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)
{
 if(document.getElementById(id)) document.getElementById(id).value=v;
}

function getval(id)
{
 v='';
 if(document.getElementById(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 cchk()
{
a=getinner('ids');
aa=a.split(',');
total=aa.length;
s='';
if(total>0)
  {
   for(i=0;i<total;i++)
      {
	   if(document.getElementById('i'+aa[i]).checked)
	     {
		  if(s!='') s=s+',';
		  s=s+aa[i];  
		 }
	  }
  }
 setval('chks',s);
 if(s!='') sh=0; else sh=1;
 document.getElementById('hsel').disabled=sh;
 document.getElementById('ksel').disabled=sh;
 document.getElementById('ssel').disabled=sh;
}

 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;
}