﻿// JScript 文件

//function document.onkeydown()
//{
//if(event.keyCode==13)
//{
//if(document.getElementById("searchtype").value=="goods"){
//window.location="/search2.aspx?keystr="+document.getElementById("keystr").value;
//}
//}
//}
function tosearch()
{
var key = document.getElementById("keystr").value;
var reg  = /\s/g;     
key = key.replace(reg,"");

if (document.getElementById("searchtype").attributes("serclass").value == "goods")
{
window.open("http://search.0575eshop.com/search-----"+key+"-.aspx");}
else {
  
window.open("http://search.0575eshop.com/searchshop----"+key+".aspx");
}
}
function xialatishi(aa) {
    document.getElementById("gotosearch").focus();
document.getElementById("divsearchkey").innerHTML="";
aa = removeAllSpace(aa);
if(aa!=""){
    var res = setopkey(8, aa, document.getElementById("searchtype").attributes("serclass").value);
if(res!=""){
var ul = document.createElement("ul");
ul.id="add_2";
document.getElementById("divsearchkey").appendChild(ul);

var resl = res.split('|');
for(i=0;i< resl.length;i++){
var li = document.createElement("li");
li.innerHTML=resl[i];
li.onmouseover = moverxiala;
li.onmouseout = moutxiala;
li.onclick = mclick;
ul.appendChild(li);
  
}
var lastdiv=document.createElement("div");
lastdiv.innerHTML="<span style=\"padding-right:5px;\"><a href=\"javascript:void(0)\" onclick=\"removers();\">关闭</a></span>";
lastdiv.style.cssText = " solid; width:390px; height:18px; background-color:#ffffff; text-align:right; line-height:18px;border-right: solid 1px #eaeff9;border-left: solid 1px #eaeff9;border-bottom: solid 1px #eaeff9;"; document.getElementById("divsearchkey").appendChild(lastdiv);
lastdiv.id="add_1";
}
}
}
function removers()
{ 
 var rr=document.getElementById("add_2");
 var rr2=document.getElementById("add_1");
 rr.style.display="none";
 rr2.style.display="none";
}
function setopkey(count,key,stype)
{
return doajaxstring("/ajax/searchtsbykey.ashx?stype="+stype+"&cont="+count+"&key="+escape(key));
}
function moverxiala()
{
    this.style.background = "#ffff99";
    this.style.cursor = "pointer";
    this.style.LineHight = "20px";
}
function moutxiala()
{
this.style.background="#ffffff";
}
function mclick()
{
if(this.innerHTML!=""){
document.getElementById("keystr").value=this.innerHTML;
tosearch();
}
}

function removeAllSpace(str){
var localString = "";
for(var index = 0; index<str.length; index++)
if(str.charCodeAt(index)!= 32){
localString += str.charAt(index);
};
return localString;
}
function keydownsearch(evt) 
{ 
evt = (evt) ? evt : ((window.event) ? window.event : "") 
keyCode = evt.keyCode ? evt.keyCode : (evt.which ? evt.which : evt.charCode); 
if (keyCode == 13) {
    tosearch()
} 
}

