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 chvoting(id)
{
  var old = document.getElementById('questions').value;
  document.getElementById('questions').value = id;
  document.getElementById('vott'+old).src = 'images/vot.jpg';
  document.getElementById('vott'+id).src = 'images/vot_a.jpg';
}


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://'+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, file) {
  document.getElementById('tablefoto'+document.getElementById('fotoid').value).bgColor= 'FFFFFF';
  document.getElementById('fotobig').src= 'images/tovar/l'+file+'';
  document.getElementById('fotopix').value= file;
  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 opr_wh()
{
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 box_block = document.getElementById('box_block');
var scrollt = document.body.scrollTop;
var scrolll = document.body.scrollLeft;
if(box_block!=undefined)
{

     box_block.style.top = eval(scrollt+'+(('+oknoHeight+'/2)-('+document.getElementById('addbigfoto').height+'/2)-300)');
     box_block.style.left = eval(scrolll+'+(('+oknoWidth+'/2)-('+document.getElementById('addbigfoto').width+'/2)-300)');
     document.getElementById('box_page').style.top = scrollt;
    document.getElementById('box_page').style.left = scrolll;
}
}

function addbigpix (id) {

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;

    newImg = new Image(); 
    newImg.src = id; 

var box_block = document.getElementById('box_block');
var scrollt = document.body.scrollTop;
var scrolll = document.body.scrollLeft;



     box_block.style.top = eval(scrollt+'+(('+oknoHeight+'/2)-300)');
     box_block.style.left = eval(scrolll+'+(('+oknoWidth+'/2)-300)');


   document.getElementById('box_page').style.zIndex = '10';
   document.getElementById('box_page').style.display = '';
   document.getElementById('box_block').style.zIndex = '20';
   document.getElementById('box_block').style.display = '';
    document.getElementById('box_page').style.top = scrollt;
    document.getElementById('box_page').style.left = scrolll;


   var xmlhttp = getXmlHttp();
   var current_date = new Date();
   xmlhttp.open('GET', 'index.php?go=Trening&in=trener&id='+id, true);
   xmlhttp.onreadystatechange = function() {
   if (xmlhttp.readyState == 4)
   {
    if(xmlhttp.status == 200)
    {
     document.getElementById('test').innerHTML = xmlhttp.responseText;
    }
   }
  }
  xmlhttp.send(null);


}

function hidebox () {
   document.getElementById('addbigfoto').src = 'images/1x1.gif';
   document.getElementById('box_block').style.zIndex = '-10';
   document.getElementById('box_block').style.display = 'none';
   document.getElementById('box_page').style.zIndex = '-10';
   document.getElementById('box_page').style.display = 'none';
   document.getElementById('test').innerHTML = "";
}

function ceni (div) {
  
  if(document.getElementById(''+div+'').style.display == 'none') {
    document.getElementById(''+div+'').style.display = '';
  }
  else
  {
    document.getElementById(''+div+'').style.display = 'none';
  }
  
}

function chabout (i) {

  document.getElementById('top_page_menu_'+document.getElementById('text_id').value).className = 'top_page_menu';
  document.getElementById('text_'+document.getElementById('text_id').value).style.display = 'none';
  document.getElementById('top_page_menu_'+i).className = 'top_page_menu';
  document.getElementById('text_'+i).style.display = '';
  document.getElementById('text_id').value = i;
  document.getElementById('top_page_menu_'+i).className = 'top_page_menu_a';


}
