/* -------------------------- */
/*   XMLHTTPRequest Enable    */
/* -------------------------- */
var ci=0;
function createObject() {
  if (typeof XMLHttpRequest === 'undefined') {
    XMLHttpRequest = function() {
      try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
        catch(e) {}
      try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
        catch(e) {}
      try { return new ActiveXObject("Msxml2.XMLHTTP"); }
        catch(e) {}
      try { return new ActiveXObject("Microsoft.XMLHTTP"); }
        catch(e) {}
      throw new Error("This browser does not support XMLHttpRequest.");
    };
  }
  return new XMLHttpRequest();
}
var http = createObject();

/* -------------------------- */
/*        SEARCH              */
/* -------------------------- */
function searchNameq(event,lib) {

    var keycode;
	    if(!event) var event = window.event;
	    if (event.keyCode) keycode = event.keyCode; // IE
	    else if(event.which) keycode = event.which; // all browsers
//	    alert("keycode: "+keycode);

if (keycode==38 || keycode==40) {



if (keycode==40) {
try {
ii=ci+1;
document.getElementById('aa'+ii).style.background='#ccc';
document.getElementById('stxt').value=document.getElementById('aa'+ii).title;
if (ci>0) document.getElementById('aa'+ci).style.background='#fff';
ci++;
} catch(e){}
}
if (keycode==38) {
try {
ii=ci-1;
document.getElementById('aa'+ii).style.background='#ccc';
document.getElementById('stxt').value=document.getElementById('aa'+ii).title;
if (ci>0) document.getElementById('aa'+ci).style.background='#fff';
ci--;
} catch(e){}
}

} else {
searchq = document.getElementById('stxt').value;
ln=searchq.length;
if (ln>0) {
searchq=encodeURIComponent(searchq);

nocache = Math.random();

http.open('get', '/in-search.php?stxt='+searchq+'&lib='+lib+'&nocache = '+nocache);
http.onreadystatechange =  searchNameqReply;
http.send(null);
}
}
function searchNameqReply() {
if(http.readyState == 4 && http.status==200){
//alert(http.text);
var response = http.responseText;

if (response) {
document.getElementById('search-result').innerHTML = response;
document.getElementById('search-result').style.display = "block";
} else {
document.getElementById('search-result').style.display = "none";
//}
}
}
}
}
function do_src(v) {
document.getElementById('stxt').value=v;
}
function getBrowserInfo() {
 var t,v = undefined;
 if (window.opera) t = 'Opera';
 else if (document.all) {
  t = 'IE';
  var nv = navigator.appVersion;
  var s = nv.indexOf('MSIE')+5;
  v = nv.substring(s,s+1);
 }
 else if (navigator.appName) t = 'Netscape';
 return {type:t,version:v};
}
 
function bookmark(a){
 var url = window.document.location;
 var title = window.document.title;
 var b = getBrowserInfo();
 if (b.type == 'IE' && 7 > b.version && b.version >= 4) window.external.AddFavorite(url,title);
 else if (b.type == 'Opera') {
  a.href = url;
  a.rel = "sidebar";
  a.title = url+','+title;
  return true;
 }
 else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
 else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
 return false;
}
function s_enter() {
if (document.getElementById('stxt').value=='Искать термин...') searchq = document.getElementById('stxt').value='';
}
function s_blur() {
if (document.getElementById('stxt').value=='') searchq = document.getElementById('stxt').value='Искать термин...';
document.getElementById('search-result').style.display = "none";

}
function showo() {
if (document.getElementById('other').style.display == "block") {
document.getElementById('other').style.display = "none";
} else {
document.getElementById('other').style.display = "block";
}


}
