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 topmenuimg (id) {
  document.getElementById('top_td_'+id).className = 'top_menu_td';
  document.getElementById('top_tdd_'+id).className = 'top_menu_td1';
}

function topmenuimgx (id) {
  document.getElementById('top_td_'+id).className = 'top_menu_td_a';
  document.getElementById('top_tdd_'+id).className = 'top_menu_td1_a';
}



function tababoutx () {
  document.getElementById('table_about').style.display = 'none';
  document.getElementById('table_about').style.zindex = '-10';
  clearTimeout(ta);
}
  
function tababoutq (iddiv, id, lang, url) {
   var xmlhttp = getXmlHttp();
   var current_date = new Date();
   var div = document.getElementById('box');

   xmlhttp.open('GET', url+'/cat_about.php?id='+id+'&lang='+lang, true);
   xmlhttp.onreadystatechange = function() {
   if (xmlhttp.readyState == 4)
   {
    if(xmlhttp.status == 200)
    {
     if(xmlhttp.responseText!="")
     {
     document.getElementById('t_about').innerHTML = xmlhttp.responseText;
     pos = getElementPosition(iddiv+id);
     document.getElementById('table_about').style.left = pos.left+(pos.width/3);
     document.getElementById('table_about').style.top = pos.top+15;
     document.getElementById('table_about').style.display = '';
     document.getElementById('table_about').style.zindex = '10';
//     document.getElementById('t_about').innerHTML = 'top - '+pos.top+'<br>left - '+pos.left+'<br>width - '+pos.width+'<br>height - '+pos.height;
     }
    }
   }
 }
xmlhttp.send(null);
}


function chabout (id) {

for(i=1;i<=5;i++)
{
  document.getElementById('tovar_about'+i).style.display = 'none';
  document.getElementById('menu_tovar_about_'+i).className = 'top_menu_td';
}

  document.getElementById('tovar_about'+id).style.display = '';
  document.getElementById('menu_tovar_about_'+id).className = 'top_menu_td_a';
  
  
  
  
}

function tababout (iddiv, id, lang, url) {
  ta = setTimeout("tababoutq('"+iddiv+"', '"+id+"', '"+lang+"', '"+url+"')", 1000);
}

function CloseOthers(id)
{
	var MenuNum = 20;
	var n;
	for(n=1; n<=MenuNum; n++)
	if(document.all('menu' + n) != null)
	{
		if (id!=n)
		{
			document.all('menu' + n).style.display = 'none';
		}
	}

}

function pos_hot(id) {

  alert(document.all.item("tovar_hit2").length);
  
//  if (document.all("tovar_hit")!=null) {
//  for (i=0; i<document.all("tovar_hit").length; i++) 
//  document.all.tags("P")[i].style.textDecoration="underline";
//  }
  
  
  pos = getElementPosition('tovar_hit'+id);
  document.getElementById('tovar_div_hit'+id).style.left = pos.left+130;
  document.getElementById('tovar_div_hit'+id).style.top = pos.top-23;
}



function getElementPosition(elemId)
{
    var elem = document.getElementById(elemId);
	
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
	
    var l = 0;
    var t = 0;
	
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}


function subcat (id) {
  if(document.getElementById('cat'+id).style.display == 'none')
  {
  document.getElementById('cat'+id).style.display = ''; 
  }
  else
  {
  document.getElementById('cat'+id).style.display = 'none';
  }
}

function subcatvendor (id) {
  if(document.getElementById('vendor'+id).style.display == 'none')
  {
  document.getElementById('vendor'+id).style.display = ''; 
  }
  else
  {
  document.getElementById('vendor'+id).style.display = 'none';
  }
}


function topmenu (id) {
	document.getElementById('top_td').style.bgcolor = '#000000';
	
	
}	
function untopmenu (id) {
	document.getElementById('top_td').bgcolor = '#E5E7E7';
}	
	
	
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://concepthouse.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, file) {
  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('fotopix').value= file;
  document.getElementById('tablefoto'+id).bgColor= 'C81124';
}

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)-30)');
     box_block.style.left = eval(scrolll+'+(('+oknoWidth+'/2)-30)');


   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;


newImg.onload=function(){

  
    box_block.style.top = eval(scrollt+'+(('+oknoHeight+'/2)-('+newImg.height+'/2))-15');
    box_block.style.left = eval(scrolll+'+(('+oknoWidth+'/2)-('+newImg.width+'/2)-15)');
    document.getElementById('addbigfoto').src = id;
  
}
if(newImg.complete)
{
    box_block.style.top = eval(scrollt+'+(('+oknoHeight+'/2)-('+newImg.height+'/2))-15');
    box_block.style.left = eval(scrolll+'+(('+oknoWidth+'/2)-('+newImg.width+'/2)-15)');
    document.getElementById('addbigfoto').src = id;
}
}

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';
}