﻿function ShowPersonal(cur)
	{
	    var personal = document.getElementById('toolpanel');
	    personal.style.top = 20;
	    personal.style.left = event.screenX;
	    personal.style.display = "";
	}
function login(){
	if(document.getElementById("username").value==""){
		alert("用户名不能为空");
		return ;
	}
	urlstr="user/login.aspx?username="+document.getElementById("username").value+"&password="+document.getElementById("password").value+"&random="+(new Date()).getTime();
	result=getresponseText(urlstr);
	alert(result);
}
//热点搜索
function searchHot(str){
    document.getElementById("content").value = str;
    searchData();
}
//热点商圈
function searchBusArea(str){
    searchIndex(0, "ALL", 2, str);
}
//搜索
function searchData(){
	searchIndex(0, "ALL", 1, "");
	var content = document.getElementById("content").value;
	//商家名称搜索不为空时，写入搜索表
	if ((content != null) && (content != "")){
	    var str = getresponseText("indexSearch.aspx?search="+encode64(content)+"&random="+(new Date()).getTime());
	}
}

  function jumpPage(pageIndex){
        var firstChar = document.getElementById("firstChar").value;
        var type = document.getElementById("type").value;
        
        searchIndex(pageIndex, firstChar, type, "");
   }
        
   function setLiClass(firstChar){
        if (firstChar == "ALL"){
            document.getElementById("ALL").className = "cur_type";
        }
        else
        {
            document.getElementById("ALL").className = "";
        }
        
        if (firstChar == "ABCD"){
            document.getElementById("ABCD").className = "cur_type";
        }
        else
        {
            document.getElementById("ABCD").className = "";
        }
        
        if (firstChar == "EFGH"){
            document.getElementById("EFGH").className = "cur_type";
        }
        else
        {
            document.getElementById("EFGH").className = "";
        }
        
        if (firstChar == "IJKL"){
            document.getElementById("IJKL").className = "cur_type";
        }
        else
        {
            document.getElementById("IJKL").className = "";
        }
        
        if (firstChar == "MNOP"){
            document.getElementById("MNOP").className = "cur_type";
        }
        else
        {
            document.getElementById("MNOP").className = "";
        }
        
        if (firstChar == "QRSTU"){
            document.getElementById("QRSTU").className = "cur_type";
        }
        else
        {
            document.getElementById("QRSTU").className = "";
        }
        
        if (firstChar == "VWXYZ"){
            document.getElementById("VWXYZ").className = "cur_type";
        }
        else
        {
            document.getElementById("VWXYZ").className = "";
        }
   }
   

   
   function searchIndex(pageIndex, firstChar, type, busArea){
        //当前页不是首页时，跳转到首页再查询
      thisurl=location.toString();
      if((thisurl.indexOf("index.aspx") < 0) && (thisurl.indexOf("more_company.aspx") < 0)){
          location=baselocation+"/index.aspx?jump=yes&random="+(new Date()).getTime();
      }
       
      //改变热门商家的样式
      setLiClass(firstChar);
      //保存当前的搜索信息
      document.getElementById("firstChar").value = firstChar;
      document.getElementById("type").value = type;
      
	  //刷新iframe
	  document.getElementById("productList").src = "companyList.aspx?enterprise="+getComboValueById('enterprise')+"&trade="+getComboValueById('trade')+"&content="+document.getElementById("content").value+"&busArea="+busArea+"&pageIndex="+pageIndex+"&firstChar="+firstChar+"&type="+type+"&random="+(new Date()).getTime();
/*
      var sqlstr="from v_en_company_short s where status = 1 ";//查询sql语句,from后语句
      var orderName = " order by hot desc ";
      //热门商家
      if (type == 1){
        if (firstChar != "ALL"){
            sqlstr += " and CharIndex(firstChar, '" + firstChar + "') > 0 ";
        }
      }
      //热门商圈
      else if (type == 2)
      {
        sqlstr += " and Exists(select * from en_busArea b, en_busArea_detail bd where b.id = bd.areaid and bd.code = s.code and b.name = '" + busArea + "')";
      }
      //商家名称
      var content = document.getElementById("content").value;
      if ((content != null) && (content != "")){
        sqlstr += " and company like '%" + content + "%' ";
      }
      //下拉框搜索
      var tradeStr = getComboValueById("trade");
      var enterprise = getComboValueById("enterprise");
      if (tradeStr != ""){
        //行业
        if (enterprise == "1"){
            sqlstr += " and trade = '" + tradeStr + "'";
        }
        //城市
        else if (enterprise == "2"){
            list = getDictionaryList("city");
            tradeStr = getDictionaryName("city", tradeStr, list);
            sqlstr += " and companyAddr like '%" + tradeStr + "%' ";
        }
        //折扣
        else if (enterprise == "3"){
            sqlstr += " and ((rebate = '" + tradeStr + "') or (vip = '" + tradeStr + "') or (other = '" + tradeStr + "'))";
        }
      }
      
      //alert(sqlstr);
      if ((pageIndex == null) || (pageIndex == "")){
        pageIndexValue = 0;
      }
      else
      {
        pageIndexValue = pageIndex;
      }
      
       try{
            var pageCount = document.getElementById("pageCount").value;
       }
       catch(e)
       {
            var pageCount = "7";
       }
 
      //传入参数sqlstr为查询语句
      //selectStr为查询语句中从select到from部分
      //fieldStr为结果集中获取数据的字段串，如果是单表操作，且selectStr无s.则可以不加fieldStr参数，它等于selectStr
      //pageIndex为当前页
      //pageCount为每页显示行数，如果不填表示不分页
      var searchUrl="sqlstr="+encode64(sqlstr)+"&orderName=" + orderName + "&selectStr=company,trade,discount,logo,starLevel,id&pageIndex="+pageIndexValue+"&pageCount=" + pageCount;
      result= searchSqlData(searchUrl);  
      
      var showData="";
      var jumpdata="";
      if(result.length>1){
          for(var i=1; i < result.length;i++){   
                //顺序获取字段数据
                company = inciseStr(getArrayData(result[i],0), 4);
                trade = getArrayData(result[i],1);
                discount =getArrayData(result[i],2);
                slogo = getArrayData(result[i],3);
               
                starLevel = getArrayData(result[i],4);
                cid = getArrayData(result[i],5);
                
                dicList=getDictionaryList("trade");
                dicList=getDictionaryList("discount",dicList);
                tradename=getDictionaryName("trade",trade,dicList);
                discountname=getDictionaryName("discount", discount, dicList);
                //封装生成显示数据
                if (slogo == ""){
                     slogo = "images/tmp01.gif";
                }else{
                     slogo="../"+slogo;
                }
                showData += "<div class='item' onmouseover='try{this.className=\"itemmouse\"}catch(ex){}' onmouseout='try{this.className=\"item\"}catch(ex){}'>\r\n"
                               + "    <div class='pic'><a href='detail.aspx?id="+cid+"'><img alt='图片' src='" + slogo + "' /></a></div>\r\n"
                               + "     <ul class='desc'>\r\n"
                               + "       <li>商店名:" + company + "</li>\r\n"
                               + "       <li>所属行业:" + tradename + "</li>\r\n"
                               + "       <li>最高折扣:" + discountname + "</li>\r\n"
                               +  showStar(starLevel, 5)
                               + "     </ul>\r\n"
                               + "   </div>";
 
          }
          //alert("pageIndex=" + result[0][0]);
          //alert("pageCount=" + result[0][1]);
          //alert("itemCount=" + result[0][2]);
          jumpdata=showPageLine(result[0][0],result[0][1],result[0][2]);//分页标签
      }
       document.getElementById("product").innerHTML=showData+"<div class='clearThis'></div>"+jumpdata+"<div class='clearThis'></div>";
       
       */
      
   }
   
  