var isbtn0=new Image;
var isbtn1=new Image;
var isbtn2=new Image;
isbtn0.src="/i/2.0/submit.gif";
isbtn1.src="/i/2.0/submit1.gif";
isbtn2.src="/i/lbox/images/loading.gif";

var img = new Image();
function mon(ttr) { ttr.style.backgroundImage = "url("+img.src+")"; }
function moff(ttr) { ttr.style.backgroundImage = "none"; }

function ShowSearchProv(surl)
{ if (window.external && ("AddSearchProvider" in window.external))
{ document.write('<div style="padding: 0 0 5px 0;"><a onclick="javascript:window.external.AddSearchProvider(&quot;'+surl+'/opensearch.xml&quot;);return false;" href="#"><img border="0" style="" src="'+surl+'/i/osearch.gif" width="159" height="26"></a></div>'); } }

function cbclik(obj, val ) { 
if(obj.form.catonly.value==val) obj.form.catother.value=1;
else obj.form.catother.value=0;  
if(obj.form.catonly.value!='x') obj.form.submit(); }

function ShowUl(mid, CatName) {  
if(document.getElementById("ul_"+mid))
{if(document.getElementById("ul_"+mid).style.display == "none")	document.getElementById("ul_"+mid).style.display = "block";
else document.getElementById("ul_"+mid).style.display = "none";
} else alert("нету "+"ul_"+mid);  }

function ReCheck(cbox){
if(document.getElementById(cbox)) 
 {document.getElementById(cbox).checked = !document.getElementById(cbox).checked;
  BoxCheck(cbox);}
else alert("нету "+cbox);  
}

function BoxCheck(cbox){
var ch = false;
if(cbox == 'all_check')
{
if(document.getElementById('all_check')) ch = !document.getElementById('all_check').checked;
if(document.getElementById('cat_check')) document.getElementById('cat_check').checked = ch;
if(document.getElementById('pro_check')) document.getElementById('pro_check').checked = ch;
if(document.getElementById('sel_check')) document.getElementById('sel_check').checked = ch;
if(document.getElementById('reg_check')) document.getElementById('reg_check').checked = ch;
} else 
{
if(document.getElementById('all_check')) document.getElementById('all_check').checked = 
  !( (document.getElementById('cat_check') && document.getElementById('cat_check').checked ) 
   || (document.getElementById('pro_check') && document.getElementById('pro_check').checked )   
   || (document.getElementById('sel_check') && document.getElementById('sel_check').checked )   
   || (document.getElementById('reg_check') && document.getElementById('reg_check').checked )   
  )
}
}

function showImageBySrc(src) {
w = newWin('ShowPhoto', 'about:blank', 200, 200);
w.moveTo(100,50);
doc = w.document.open();
doc.writeln('<html><body style="margin:0;padding:20px; font-size: 12px; font-family: Verdana;" onload="i=document.getElementById(\'im\');self.resizeTo(i.width+50,i.height+110);"><center><a style="text-decoration: none; color: #aaa;" href="#" onclick="self.close()" alt="закрыть" title="закрыть"><img src="'+src+'" id="im" border="0" /><br /><br />закрыть</a></center></body></html>');
doc.close();}

function newWin(name, url, width, height, args) {
win=open(url, name,'resizable=yes,width=' + width + ',height=' + height + ',' + args);
win.focus();
return win; }

function OpenURL(openurl, winname) { window.open(openurl, winname); }
function OpenHuksy(openurl) { OpenURL('http://www.huksy-partners.ru/det/?refid=20207', "kidspartners"); }

/*************************************/

document.write('<DIV class="hint" id="mess"></DIV>');

function hideMessage()
{
	with(document.getElementById('mess')){
		innerHTML = "";
		style.visibility = "hidden";
	}
}
function getBodyScrollTop()
{
 return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}
function createMessage(text, time_to_show)
{
	var mtop = getBodyScrollTop()+250;
	with(document.getElementById('mess'))
	{
		style.visibility = "visible";
		innerHTML = text;
		style.top = mtop+'px';
	}
	if(time_to_show > 0) setTimeout("hideMessage()", time_to_show);
}
///////////////////////////////////////////////
var ajTgt = "";
var req = false;
function gajx(action, target)
{
 ajTgt = target;	
 if(target != 'fortrans')
    createMessage("<div class='hcaption'>Минуточку...</div><div class='hbody'><p><img src='/i/lbox/images/loading.gif'></p></div>", 0);
 req=false;
 try { req=new ActiveXObject('Msxml2.XMLHTTP'); } 
 catch (e) 
  {try { req=new ActiveXObject('Microsoft.XMLHTTP');  } 
   catch (e) 
     { if(window.XMLHttpRequest) // Mozilla
        { req=new XMLHttpRequest(); } 
     }
  }
 if (req)
  {req.onreadystatechange = ajxrsp; 
   req.open("GET", '/ajaxpage?'+action, true); 
   req.send(null);
  }
}
function ajxrsp()
{
 var curElm;	
 var i,j;
 var idArr = new Array();
 var retArr = new Array();
 idArr = ajTgt.split(',');

 if(!req) alert('!req');
 
 if (req.readyState == 4)
  {if (req.status == 200) 
     {
      retArr = req.responseText.split('|-split-|');	
      for(var i=0; i<idArr.length; i++) 
        {
         curElm = document.getElementById(idArr[i]);
         if(curElm) curElm.innerHTML = retArr[i];
        }
      hideMessage();
     }
   else createMessage("Ошибка: "+ req.status+":\n" + req.statusText, 2000);
  } 
}
////////////////////////////////////////////////
function to_cart(i_prod_id)
{
	createMessage("<div class='hcaption'>Минуточку...</div><div class='hbody'><p><img src='/i/lbox/images/loading.gif'></p></div>", 0);
    req=false;
    try { 
        req=new ActiveXObject('Msxml2.XMLHTTP');
    } catch (e) {
        try {
            req=new ActiveXObject('Microsoft.XMLHTTP'); // IE
        } catch (e) {
            if(window.XMLHttpRequest){ // Mozilla
               req=new XMLHttpRequest();
            }
        }
    }
    if (req){
       req.onreadystatechange = readystate; 
       req.open("GET", '/ajaxcart/add'+i_prod_id, true); 
       req.send(null);
    }
}
function readystate() 
{
    if (req.readyState == 4){
        if (req.status == 200) { // OK
        document.getElementById('pokcnt').innerHTML = req.responseText;
        createMessage("<div class='hcaption'>Товар добвлен в список покупок</div><div class='hbody'><p>Всего в списке: <a href='/mylist/'>"+req.responseText+'</a></p><p>Вы можете сравнить свои покупки, показать их друзьям или опубликовать на форуме</p></div>', 3000);
        if(document.getElementById('sppok'))
          {
           document.getElementById('sppok').innerHTML = "(в списке: <a href='/mylist/'>"+req.responseText+"</a>)";
          }
        } else {
        	createMessage("Ошибка: "+ req.status+":\n" + req.statusText, 2000);
        }
    }
}  