   var request = null;
   var key=1;
   var oldbig=''; 
   var texts=Array();
   var keystop=0;
   var agent = navigator.userAgent.toLowerCase();
   
   function createRequest() {
     try {
       request = new XMLHttpRequest();
     } catch (trymicrosoft) {
       try {
         request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (othermicrosoft) {
         try {
           request = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (failed) {
           request = null;
         }
       }
     }

     if (request == null)
       alert("Ошибка асинхронной передачи данных!");
   }

   function getB1(play) {
    createRequest();
	var url = "play.php?dummy=" + new Date().getTime() + "&play=" + play;
	request.open("GET", url, true);
    request.onreadystatechange = updatePage;
    request.send(null);
	}

  function updatePage() {
	  if (request.readyState == 4) {
		var newTotal = request.responseText;
		var text='';
	  }
}  
	
function init() {
    // quit if this function has already been called
    if (arguments.callee.done) {
//--------------------------------------------------------------
		key=1;
		 if (agent.indexOf("msie") <= -1){
			if (agent.indexOf("chrome") > -1) {  setTimeout("Tablas.controls.play()",2020); setTimeout("Tablas_hover.controls.play()",3030);}
			else  { setTimeout("document.Tablas_hover.controls.play()",2020); setTimeout("document.Tablas.controls.play()",3030);}
		}
		if(oldbig==''){
			oldbig=document.images[12].src;
		}
		setTimeout("aplay()",1000);
		astart();
//	alert ('Загрузка страницы завершена');
//--------------------------------------------------------------
	return;
	}

    // flag this function so we don't do the same thing twice
    arguments.callee.done = true;

    // kill the timer
    if (_timer) clearInterval(_timer);

    // do stuff
};

/* for Mozilla/Opera9 */
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
    document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
    var script = document.getElementById("__ie_onload");
    script.onreadystatechange = function() {
        if (this.readyState == "complete") {
            init(); // call the onload handler
        }
    };
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            init(); // call the onload handler
        }
    }, 10);
}

/* for other browsers */
window.onload = init;
 
 function astart(){
 if (agent.indexOf("msie") <= -1){
	if (agent.indexOf("chrome") > -1) {  setTimeout("Tablas.controls.play()",1000); setTimeout("Tablas_hover.controls.play()",2000);}
	else  { setTimeout("document.Tablas.controls.play()",1000); setTimeout("document.Tablas_hover.controls.play()",2000);}
 }
	if(keystop==0) setTimeout("aplay()",2010);
}

 function aplay(){
	if(keystop==1){
		getB1('1');
		keystop=0;
	}
	else astop();
 }
 
function astop(){
 getB1('0');
 keystop=1;
 }

 function atablas(){
  if(key==1 && keystop==0){
	if (agent.indexOf("msie") > -1)document.Tablas.controls.play();
	else{	
		if (agent.indexOf("chrome") > -1)  {Tablas_hover.controls.stop(); Tablas.controls.play();}
		else {document.Tablas_hover.controls.stop(); document.Tablas.controls.play();}
	}
 }
 }
 
 function atablas_hover(big){
//  document.getElementById("first").src="images/"+big+"_big.png";
//  document.images["first"].src="images/"+big+"_big.png";
//	document["first"].src="images/"+big+"_big.png";
	var texts='';
	if(big=='ge') texts='Раздел автоматика General E…';
	if(big=='nik') texts='Счетчики электроэнергии';
	if(big=='led_liht') texts='Светотехника';
	if(big=='lampa') texts='Лампы';
	if(big=='korobka') texts='Кабель провод';
	if(big=='kabelk2') texts='Низковольтная продукция АсКо';
	if(big=='vikl') texts='Розетки Выключатели';
	if(big=='kabelk') texts='Кабель-канал, гофра труба …';
	if(big=='acko') texts='Коробки монтажные, распред…';
	if(big=='rubilnik') texts='Электрощиты';
	if(oldbig!=''){
		document.images[12].src="images/"+big+"_big.png";
		clearText(document.getElementById('text_str'));
 		replaceText(document.getElementById('text_str'), texts);
	}
 if(key==1 && keystop==0){
	if (agent.indexOf("msie") > -1) document.Tablas_hover.controls.play();
	else{	
		if (agent.indexOf("chrome") > -1) {Tablas.controls.stop(); Tablas_hover.controls.play();}
		else {document.Tablas.controls.stop(); document.Tablas_hover.controls.play();}
	}
 }
}

function atablas_hover1(){
//  document.getElementById("first").src=oldbig;
//  document.images["first"].src=oldbig;
//	document["first"].src=oldbig;
	if(oldbig!=''){
		document.images[12].src=oldbig;
		clearText(document.getElementById('text_str'));
		replaceText(document.getElementById('text_str'), oldtext);
	}
}

// запись текста в html	
function replaceText(el, text) {
  if (el != null) {
    clearText(el);
    var newNode = document.createTextNode(text);  // принимает строку текста, которая станет содержимым создаваемого объекта  и возвращает ссылку на созданный объект
	el.appendChild(newNode);					  // помещает вновь созданный элемент на Web-страницу принимает и возвращает ссылку на добавляемый элемент
  }
}

function clearText(el) {
  if (el != null) {
    if (el.childNodes) {
      for (var i = 0; i < el.childNodes.length; i++) {
        var childNode = el.childNodes[i];
        el.removeChild(childNode);
      }
    }
  }
}

function getText(el) {
  var text = "";
  if (el != null) {
    if (el.childNodes) {
      for (var i = 0; i < el.childNodes.length; i++) {
        var childNode = el.childNodes[i];
        if (childNode.nodeValue != null) {
          text = text + childNode.nodeValue;
        }
      }
    }
  }
  return text;
}

