var yt=new Image();
yt.src="images/soc/yt.png";
var yt_a=new Image();
yt_a.src="images/soc/yt_a.png";

var b=new Image();
b.src="images/soc/b.png";
var b_a=new Image();
b_a.src="images/soc/b_a.png";

var inn=new Image();
inn.src="images/soc/in.png";
var inn_a=new Image();
inn_a.src="images/soc/in_a.png";

var t=new Image();
t.src="images/soc/t.png";
var t_a=new Image();
t_a.src="images/soc/t_a.png";

var fb=new Image();
fb.src="images/soc/fb.png";
var fb_a=new Image();
fb_a.src="images/soc/fb_a.png";

var new_2_1 =new Image();
new_2_1.src = "images/new_2_1.png";
var new_2_1_50 =new Image();
new_2_1_50.src = "images/new_2_1_50.png";

var new_1 =new Image();
new_1.src = "images/new_1.png";
var new_1_50 =new Image();
new_1_50.src = "images/new_1_50.png";

var new_1_pix =new Image();
new_1_pix.src = "images/new_1_pix.png";
var new_1_pix_50 =new Image();
new_1_pix_50.src = "images/new_1_pix_50.png";

var new_1_pix1 =new Image();
new_1_pix1.src = "images/new_1_pix1.png";
var new_1_pix1_50 =new Image();
new_1_pix1_50.src = "images/new_1_pix1_50.png";






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 refresh() {
   var current_date = new Date();
   var kcaptcha = document.getElementById('kcaptcha');
    kcaptcha.innerHTML = '<img src=\"kcaptcha/index.php?d='+current_date+'312\">';
}

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 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 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 scrollt = document.body.scrollTop;
var scrolll = document.body.scrollLeft;

   document.getElementById('box_page').style.zIndex = '10';
   document.getElementById('box_page').style.display = '';
//   document.getElementById('box_page').style.top = '119px';
//   document.getElementById('box_page').style.left = eval('(('+oknoWidth+'/2)-501)');

   document.getElementById('box_block').style.zIndex = '15';
   document.getElementById('box_block').style.display = '';
   document.getElementById('box_block').style.top = '165px';
   document.getElementById('box_block').style.top =  eval('(('+oknoHeight+'/2)-300)+'+scrollt+'');
   document.getElementById('box_block').style.left = eval('(('+oknoWidth +'/2)-478)');
//alert(scrollt);

//   document.getElementById('new_2_1').src = new_2_1_50.src;
//   document.getElementById('new_1').src = new_1_50.src;
//   document.getElementById('new_1_pix').style.background = "url(images/new_1_pix_50.png)";
//   document.getElementById('new_1_pix1').style.background = "url(images/new_1_pix1_50.png)";



    
   var xmlhttp = getXmlHttp();
   var dt = new Date();
   var current_date = dt.getUTCHours()+dt.getUTCMinutes()+dt.getUTCSeconds()+dt.getUTCMilliseconds(); 

   document.getElementById('test').innerHTML = "Загрузка...";
   xmlhttp.open('GET', 'http://'+location.host+'/index.php?go=Galereya&in=tovar&id='+id+'&date='+current_date, 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('new_2_1').src = new_2_1.src;
//   document.getElementById('new_1').src = new_1.src;
//   document.getElementById('new_1_pix').style.background = "url(images/new_1_pix.png)";
//   document.getElementById('new_1_pix1').style.background = "url(images/new_1_pix1.png)";



}

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 scrollt = document.body.scrollTop;
var scrolll = document.body.scrollLeft;
if(box_block!=undefined)
{

//     document.getElementById('box_block').style.top = scrollt;

   document.getElementById('box_block').style.left =  eval('(('+oknoWidth+'/2)-478)');
   document.getElementById('box_page').style.top = scrollt;
}
}

function new_b_pix(id) {

  document.getElementById('m'+document.getElementById('whu_activ').value).style.border = '1px solid #EAEAEA';
  document.getElementById('whu_activ').value = id;
  
  document.getElementById('m'+id).style.border = '1px solid #FF0000';
  document.getElementById('os_pix').src = 'images/galereya/'+id;
  whu_activ
  
  
}
function pix_scroll(napravlenie, id, scroll) {
  step = 4;
  
  if(napravlenie=="left"){document.getElementById(id).scrollLeft -= step;}
  else{document.getElementById(id).scrollLeft += step;}
  
  scroll -= step;
  if(scroll >= step)
  {
  setTimeout('pix_scroll("'+napravlenie+'", "'+id+'", '+scroll+')', 10);
  }
  
}


function addbigpixgal (foto) {

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 scrollt = document.body.scrollTop;
var scrolll = document.body.scrollLeft;

   document.getElementById('box_page').style.zIndex = '10';
   document.getElementById('box_page').style.display = '';
//   document.getElementById('box_page').style.top = '119px';
//   document.getElementById('box_page').style.left = eval('(('+oknoWidth+'/2)-501)');

   document.getElementById('box_block').style.zIndex = '50';
   document.getElementById('box_block').style.display = '';
   document.getElementById('box_block').style.top = '165px';
   document.getElementById('box_block').style.top =  eval('(('+oknoHeight+'/2)-425)+'+scrollt+'');
   document.getElementById('box_block').style.left = eval('(('+oknoWidth +'/2)-478)');
//alert(scrollt);

//   document.getElementById('new_2_1').src = new_2_1_50.src;
//   document.getElementById('new_1').src = new_1_50.src;
//   document.getElementById('new_1_pix').style.background = "url(images/new_1_pix_50.png)";
//   document.getElementById('new_1_pix1').style.background = "url(images/new_1_pix1_50.png)";


   document.getElementById('test').innerHTML = '<table width="535px" border="0" cellspacing="0" cellpadding="0"><tr><td width="10"><img src="images/gal_1.png" width="10" height="10" /></td><td style="background:url(images/gal_2.png)"><img src="images/gal_2.png" width="1" height="10" /></td><td width="10"><img src="images/gal_3.png" width="10" height="10" /></td></tr><tr><td width="10" style="background:url(images/gal_4.png)">&nbsp;</td><td style="background-color:#FFF"><img style="cursor: pointer;" onclick="hidebox();" src="images/fotogaler/'+foto+'"></td><td width="10" style="background:url(images/gal_5.png)">&nbsp;</td></tr><tr><td width="10"><img src="images/gal_6.png" width="10" height="10" /></td><td style="background:url(images/gal_7.png)"><img src="images/gal_7.png" width="1" height="10" /></td><td width="10"><img src="images/gal_8.png" width="10" height="10" /></td></tr><tr><td colspan="3" align="center"><a style="cursor: pointer;" onclick="hidebox();"><font color="#FFF"><b>Закрыть окно</b></font></a></td></table>';
    

}


function ch_link_name(val, val_old) {
  

   if(val!=val_old)
   {
   var xmlhttp = getXmlHttp();
   var current_date = new Date();

   xmlhttp.open('GET', 'http://'+location.host+'/ajax/ch_link_name.php?link_name='+val+'&date='+current_date, true);
   xmlhttp.onreadystatechange = function()
   {
    if (xmlhttp.readyState == 4)
    {
     if(xmlhttp.status == 200)
     {

     if(xmlhttp.responseText!='0')
     {
      alert('Название "'+val+'" уже используется для другой страницы');
     }

     }
    }
   }
   xmlhttp.send(null);
   }
}
