function ajaxClear (div) {
  // прелоадер: подставляет строку в DIV
  $(div).style.display = 'none';
//  $(div).style.pixelTop=-1000;
}

function ajaxUpdate (div, uri, param) {
  $(div).style.display = '';
  // прелоадер: подставляет строку в DIV
  $(div).innerHTML = '<TABLE cellSpacing=1 cellPadding=5 border=0 bgcolor=\"#CDC8A5\" width="150" height="150"><tr><td align=\"center\"><img src="images/ajax.gif" border="0"><br>Загрузка...</td></tr></table>';

  // выполняет запрос к странице uri
  // с переменными param методом get
  // и подставляет результат в DIV
  var ajax = new Ajax.Updater(
    div, // значение атрибута id у DIV’а
    uri, // внешняя страница (скрипт)
    {
      method: 'get',
      parameters: param // переменные разделённые символом &
    }
  );
//  return false;


}

function addfoto () {  var count = eval('document.tovar.countfoto.value');
  document.tovar.countfoto.value = eval(count+'+1');

  var newDiv = document.createElement('div');
  newDiv.innerHTML = '<input name=\"userfile'+eval(count+'+1')+'\" type=\"file\" style=\"width=550px\">';
  add_foto.appendChild(newDiv);
}

function bigfoto (div, id) {
  $(div).innerHTML = '<img src=\"foto.php?id=' + id + '\" border=0 onclick=\"javascript:litlefoto(fototovar'+id+', '+id+')\" alt=\"Уменьшить фотографию\">';
}
function litlefoto (div, id) {
  $(div).innerHTML = '<img src=\"foto.php?id=' + id + '&r=m\" border=0 onclick=\"javascript:bigfoto(fototovar'+id+', '+id+')\" alt=\"Увеличить фотографию\">';
}
function refresh(div, data) {current_date = new Date();
  $(div).innerHTML = '<img src=\"kcaptcha/index.php?d='+current_date+'312\"><br><a href=\"javascript:refresh(kcaptcha)\">Обновить рисунок</a>';
}


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 fforum (uri) {

   document.getElementById('site_forum').innerHTML = 'Загрузка...';

    var xmlhttp = getXmlHttp();
   var current_date = new Date();
   xmlhttp.open('GET', 'http://b2y.ru/phpBB3/', true);
   xmlhttp.onreadystatechange = function() {
   if (xmlhttp.readyState == 4)
   {
    if(xmlhttp.status == 200)
    {
     document.getElementById('site_forum').innerHTML = xmlhttp.responseText;
    }
   }
 }
xmlhttp.send(null);


}

function checkform(f) {
  var errMSG = ""; 
  // цикл ниже перебирает все элементы в объекте f, 
  // переданном в качестве параметра
  // функции, в данном случае - наша форма.            
  for (var i = 0; i<f.elements.length; i++) 
    // если текущий элемент имеет атрибут required
    // т.е. обязательный для заполнения
    if (null!=f.elements[i].getAttribute("required")) 
       // проверяем, заполнен ли он в форме
        if (isEmpty(f.elements[i].value)) // пустой
            errMSG += "  " + f.elements[i].name + "\n"; // формируем сообщение
                                                       // об ошибке, перечисляя 
                                                       // незаполненные поля
        // если сообщение об ошибке не пусто,
        // выводим его, и возвращаем false     
        if ("" != errMSG) {
            alert("Внимание, сообщение  не отправлено.\n Пожалуйста, заполните все поля, помеченные знаком «*»\n");
            return false;
        }
}

function isEmpty(str) {
   for (var i = 0; i < str.length; i++)
      if (" " != str.charAt(i))
          return false;
      return true;
}

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;

//    newImg = new Image(); 
//    newImg.src = id; 

var box_block = document.getElementById('box_block');
var scrollt = document.body.scrollTop;
var scrolll = document.body.scrollLeft;


     document.getElementById('box_block').style.top = Math.round(eval(''+scrollt+'+(('+oknoHeight+'/2)-300)'))+'px';
     document.getElementById('box_block').style.left = Math.round(eval(scrolll+'+(('+oknoWidth+'/2)-220)'))+'px';
     document.getElementById('box_page').style.top = scrollt+'px';
//   document.getElementById('test').innerHTML = getBodyScrollTop()+' - '+getBodyScrollLeft();     
  
     
}

function getBodyScrollTop()
{
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getBodyScrollLeft()
{
  return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

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 addbigpix () {


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;


     document.getElementById('box_block').style.top = Math.round(eval(''+scrollt+'+(('+oknoHeight+'/2)-300)'))+'px';
     document.getElementById('box_block').style.left = Math.round(eval(scrolll+'+(('+oknoWidth+'/2)-220)'))+'px';


   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=Forms&in=fill&id=3&shab=0', true);
   xmlhttp.onreadystatechange = function() {
   if (xmlhttp.readyState == 4)
   {
    if(xmlhttp.status == 200)
    {
     document.getElementById('test').innerHTML = xmlhttp.responseText;
    }
   }
  }
  xmlhttp.send(null);

}

