function getXmlHttp(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function addbox (id, ses, count) {
   var xmlhttp = getXmlHttp();
   var current_date = new Date();
   var div = document.getElementById('box');

   xmlhttp.open('GET', 'ajax/add_box.php?id='+id+'&ses='+ses+'&count='+count+'&date='+current_date, true);
   xmlhttp.onreadystatechange = function() {
   if (xmlhttp.readyState == 4)
   {
    if(xmlhttp.status == 200)
    {
   div.innerHTML = xmlhttp.responseText;
   var pokupka = document.getElementById('pokupka'+id);
   if(pokupka!=undefined)
   {
   pokupka.innerHTML = "<center><img border=\"0\" src=\"images/box_a.jpg\"><br><font color=\"#225289\">Товар в<br>корзине<font></center>";
   }

    }
   }
 }
xmlhttp.send(null);
}
function showLink(url)
{
var msgWindow;
msgWindow=window.open('http://rscoots.012345.com.ua/foto_big.php?id='+url,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=10,height=10");
if (msgWindow != null && msgWindow.opener == null) msgWindow.opener=window;
msgWindow.focus();
}

function addfoto () {
  var count = document.getElementById('countfoto').value;
  document.getElementById('countfoto').value = eval(count+'+1');

  var newDiv = document.createElement('div');
  newDiv.innerHTML = '<input name=\"userfile'+eval(count+'+1')+'\" type=\"file\" style=\"width=100%\">';
  add_foto.appendChild(newDiv);
}

function showbig (id) {
  document.getElementById('tablefoto'+document.getElementById('fotoid').value).bgColor= 'FFFFFF';
  document.getElementById('fotobig').src= 'foto.php?id='+id+'&r=l';
  document.getElementById('fotoid').value= id;
  document.getElementById('tablefoto'+id).bgColor= 'C81124';
}

function sub(id, i, coun) {
if(document.getElementById('subb').value != id)
 {
if(document.getElementById('subb').value != 0)
{
  document.getElementById('divv'+document.getElementById('subb').value).style.backgroundImage = 'url(images/left_menu_2.png)';
  moveew(document.getElementById('subb').value);
}
  document.getElementById('subb').value = id;
  document.getElementById('divv'+id).style.backgroundImage = 'url(images/left_menu_1.png)';
  move(id, i, coun);
 }
 else
 {
  document.getElementById('subb').value = 0;
  document.getElementById('divv'+id).style.backgroundImage = 'url(images/left_menu_2.png)';
  moveew(id);
 }
}

function move(idw, iii, coun) {
 if(iii<=(coun*27)-4)
 {
  iii=iii+9;
  document.getElementById('submenu'+idw).style.height = iii;
  testt = setTimeout('move('+idw+', '+iii+', '+coun+')', 1);
 }
}

function moveew(ide) {
 var ii = parseInt(document.getElementById('submenu'+ide).style.height);
 if(ii>=9)
 {
  ii=ii-9;
  document.getElementById('submenu'+ide).style.height = ii;
  test = setTimeout('moveew('+ide+')', 1);
 }
}

function topmenuup(id) {
document.getElementById('top_menu_'+id+'').src = 'images/top_menu_'+id+'_a.png';
}

function topmenu(id) {
document.getElementById('top_menu_'+id+'').src = 'images/top_menu_'+id+'.png';
}

function galerfoto(w, h, logo) {
var oknoWidth=800; var oknoHeight=640;
if (self.innerWidth)
    oknoWidth = self.innerWidth;
else if (document.documentElement && document.documentElement.clientWidth)
    oknoWidth = document.documentElement.clientWidth;
else if (document.body)
    oknoWidth = document.body.clientWidth;

    if (self.innerHeight)
    oknoHeight = self.innerHeight;
else if (document.documentElement && document.documentElement.clientHeight)
    oknoHeight = document.documentElement.clientHeight;
else if (document.body)
    oknoHeight = document.body.clientHeight;
   var scrollt = document.body.scrollTop;
   var scrolll = document.body.scrollLeft;
var galer = document.getElementById('galer');
if(galer!=undefined)
{galer.style.left = eval('('+oknoWidth+'/2)-('+w+'/2)+'+scrolll);
galer.style.top = eval('('+oknoHeight+'/2)-('+h+'/2)+'+scrollt);
galer.style.display = '';
//galer.style.width = eval(oknoWidth+'-317');

galer.innerHTML  = '<center><table border="0" id="table1" cellpadding="0" bgcolor="#A1ABCF"><tr><td align="center"><a onclick="hidegaler()" class="box"><img stule="cursor:pointer" src="images/galer/'+logo+'" border="0"><br>Закрыть окно</a></td></tr></table></center>';
}

}

function hidegaler() {var galer = document.getElementById('galer');
if(galer!=undefined)
{galer.style.display = 'none';
}
}

function voting_up (l, t)
{
document.getElementById('voting_galka').style.left= l;
document.getElementById('voting_galka').style.top= t;
document.getElementById('voting_galka').style.display = '';
}

function voting_down ()
{
document.getElementById('voting_galka').style.display = 'none';
}

function show_trening (id)
{
  if(document.getElementById('trener'+id).style.display == 'none')
  {
   document.getElementById('trener'+id).style.display = '';
  }
  else
  {
   document.getElementById('trener'+id).style.display = 'none';
  }
}
