﻿<!--//
if(typeof($d) == "undefined")
{
    $d=function(id){return document.getElementById(id);}
}

function loadNavigator(name){
    var arrItems = new Array();
    arrItems[0] = new Array("找产品","请输入要查找的门店关键词","/ProductList.shtml");

    this.name = name;
    this.arrItem = arrItems;//数组
    this.currentIndex=0;   //当前显示第几个    this.txtObj=null;
    this.btnObj=null;
    this.count=0;
}




loadNavigator.prototype.initEvents=function()
{
    var currentObj = this;
    if(this.txtObj)
    {
        this.txtObj.onkeypress=function(e){
            var iKeyCode = window.event?event.keyCode:e.which;
            if(iKeyCode==13)
            {
               currentObj.doSearch();
               return false;
            }
            return true;
        }
    }
    if(this.btnObj)
    {
        this.btnObj.onclick=function(){
            currentObj.doSearch();
            return false;
            }
    }
}

loadNavigator.prototype.doSearch=function()
{
if( trim(this.txtObj.value)=="" || this.txtObj.value.length>20  || trim(this.txtObj.value)=="请输入产品关键字")
        {
            alert("请输入您要搜索的内容，且长度在20个字符内！");
            this.txtObj.select();
            return false;
        }

    var pars= "&t="+ getValue("t");
     if(trim( getValue("t"))=="")
        pars="";
    var searchUrl = this.arrItem[this.currentIndex][2] +"?k="+ encodeURIComponent(this.txtObj.value) +pars;
    window.location.href=searchUrl;
    //alert(searchUrl);
}

loadNavigator.prototype.pressKeyCode=function(e,obj)
{
if( trim(this.txtObj.value)=="" || this.txtObj.value.length>20  || trim(this.txtObj.value)=="请输入产品关键字")
        {
            alert("请输入您要搜索的内容，且长度在20个字符内！");
            this.txtObj.select();
            return false;
        }
  var iKeyCode = window.event?e.keyCode:e.which;
    if(iKeyCode==13)
    {
        this.doSearch(e);
        return false;
    }
    return true;
}

if(navigator.userAgent.toLowerCase().indexOf("msie")>=0)
{
    window.attachEvent("onload",function(){
        var divObj = $d("divNav") ;
        for(var i=0 ; i <divObj.getElementsByTagName("li").length;i ++)
        {
            var curLink = divObj.getElementsByTagName("li")[i].getElementsByTagName("a")[0].href.toUpperCase();
            var page=  window.location.pathname.toUpperCase() =="/" ? "/index.shtml".toUpperCase() : window.location.pathname.toUpperCase();
            //alert(curLink +"|"+ page);
            if(curLink.indexOf(page.toUpperCase())!=-1)
            {
                var curPageLi = divObj.getElementsByTagName("li")[i];
                var nextPageLi= divObj.getElementsByTagName("li")[i+1];
                
                if(curPageLi)
                curPageLi.className="on";
                if(nextPageLi)
                nextPageLi.className="";
            }
        }
       
        });
       window.attachEvent("onload",function(){
            var loadNavi = new loadNavigator("loadNavi");
            loadNavi.txtObj=$d("txtKey");
            loadNavi.btnObj=$d("btnSearch");
            loadNavi.initEvents();
       });
}
else
{
    window.addEventListener("load",function(){
       
        },false);
       window.addEventListener("load",function(){
            var loadNavi = new loadNavigator("loadNavi");
            loadNavi.txtObj=$d("txtKey");
            loadNavi.btnObj=$d("btnSearch");
            loadNavi.initEvents();
       },false);
}

loadNavigator.prototype.createHtmlLink=function(tabIndex)
{
    if(!this.div)
    {
        alert("加载导航搜索栏必须要有一个容器!");
        return;
    }
    this.currentIndex = tabIndex;
    var sTemp="",sCss="";
        for(var i=0 ; i < this.arrItem.length ; i++)
        {
            if (i==this.arrItem.length-1)
            {
                 sCss = i == this.currentIndex ? "on no" :"";
            }
            else
            {
                sCss = i == this.currentIndex ? "on" :"";
            }
            
            sTemp +="<li class=\""+ sCss +"\"><a href=\"javaScript:"+ this.name +".setIndex("+ i +")" +"\">"+this.arrItem[i][0]+"</a></li>";
        }
this.div.innerHTML = sTemp;
    this.initEvents();
}

loadNavigator.prototype.setIndex=function(tabIndex)
{
    this.createHtmlLink(tabIndex);
}

//-->
