_scripts=document.getElementsByTagName("script"),_src=_scripts[_scripts.length-1].getAttribute("src"),_sign=_src.indexOf("?"),_param=new Object;
if(_sign!=-1){
  var strParam=_src.substring(_sign+1),allParam=strParam.split("&");
  for(var idx in allParam){
    var oneParam=allParam[idx].split("=");
    _param[oneParam[0]]=oneParam[1];
  }
}
_sortAction="_sorts";
function changeSortTab(idx){
  var sortClass="",brandClass="";
  if(idx==1){
    sortClass="proCur";
    brandClass="brand";
    _sortAction="_sorts";
  }else{
    sortClass="pro";
    brandClass="brandCur";
    _sortAction="_brands";
  }
  var sort=document.getElementById("sortTab");
  sort.className=sortClass;
  sort.setAttribute("class",sortClass);
  var brand=document.getElementById("brandTab");
  brand.className=brandClass;
  brand.setAttribute("class",brandClass);
}
_defaultLayerTop=199;
_defaultStep=28;
_tempCid=1;
function overSort(cid,idx,curr){
  var layer=jQuery("#sortLayerItem");
  //layer.html("");
//  jQuery.get(_param.frontPath+"/"+_param.webIndex+"/IndexInclude/SubColumns.do",{cid:cid,action:_sortAction},function(data){
//    layer.html(data);
//  });
  
  curr.className="sortlicur";
  curr.setAttribute("class","sortlicur");
  var sortLayer=document.getElementById("sortOpen");
  sortLayer.style.top=_defaultLayerTop+_defaultStep*(idx-1)+"px";
  sortLayer.style.display="block";
  document.getElementById("subColumn_"+cid+_sortAction).style.display="block";
  _tempCid=cid;
  document.getElementById("LanternFrame").style.cssText="_position:relative;_z-index:-1;";
}
function outSort(curr,id){
  curr.className="sortli";
  curr.setAttribute("class","sortli");
  document.getElementById("sortOpen").style.display="none";
  document.getElementById("LanternFrame").style.cssText="";
  document.getElementById("subColumn_"+id+_sortAction).style.display="none";
}
function overSortLayer(curr){
  curr.style.display="block";
  var sort=document.getElementById("sort_"+_tempCid);
  sort.className="sortlicur";
  sort.setAttribute("class","sortlicur");
  document.getElementById("subColumn_"+_tempCid+_sortAction).style.display="block";
  document.getElementById("LanternFrame").style.cssText="_position:relative;_z-index:-1;";
}
function outSortLayer(curr){
  curr.style.display="none";
  var sort=document.getElementById("sort_"+_tempCid);
  sort.className="sortli";
  sort.setAttribute("class","sortli");
  document.getElementById("subColumn_"+_tempCid+_sortAction).style.display="none";
  document.getElementById("LanternFrame").style.cssText="";
}
function codeRefresh(obj){
  obj.src=_param.frontPath+"/ValidateCode?dump="+Math.random();
}
function loginSubmit(form){
  //var form=document.getElementById("loginForm");
  if(form.loginId.value==""){
    alert("请填写用户名！");
    form.loginId.focus();
    return false;
  }
  if(form.password.value==""){
    alert("请填写密码！");
    form.password.focus();
    return false;
  }
  if(form.validateCode.value==""){
    alert("请填写验证码！");
    form.validateCode.focus();
    return false;
  }
  jQuery.post(_param.frontPath+"/Member/UserLogin.do",{loginId:form.loginId.value,password:form.password.value,validateCode:form.validateCode.value},function(data){
    var msg=data.split(",");
    if(msg[0]=="0"){
      var expires = new Date();
      expires.setDate(expires.getDate() + 30);
      document.cookie="localLoginId="+msg[4]+";expires="+expires.toGMTString()+";path="+(_param.frontPath==""?"/":_param.frontPath);
      _snsLoginConn=msg[6];
      if(_snsLoginConn=="yes"){
         window.location.href=_snsUrl+"emall/setLogin.jsp?frontEnd_userId="+msg[3]+"&frontEnd_loginId="+msg[4]+"&frontEnd_time="+msg[5]+"&isAdmin=no&emallUrl="+encodeURIComponent(msg[1])+"&encode="+msg[8];
      }else{
        window.location=msg[1];
      }
    }
    if(msg[0]=="1")alert("您输入的账号不存在，请重新输入！");
    if(msg[0]=="2")alert("您的帐号或密码输入有误，请重新输入！");
    if(msg[0]=="3")alert("验证码输入有误，请重新输入！");
    if(msg[0]=="4")alert("卡号不存在，请重新输入！");
    if(msg[0]=="8")alert("账号被冻结，请与管理员联系！");
  });
  return false;
}
function scareTimer(leftTime,pastTime){
  var block=document.getElementById("scareTimer");
  var time;
  var intervalId=setInterval(function(){
    if(leftTime<=0&&pastTime>0){
      time=pastTime;
      //var day = time/(1000*60*60*24);
      //if(day<=1){
        var h=Math.floor(time/(1000*60*60));
        var m=Math.floor(time/(1000*60))%60;
        var s=Math.floor(time/(1000))%60;
        block.innerHTML="<li class='fst'>剩余<br/>时间</li><li class='num'>" + h + "</li><li>时</li>"+ "<li class='num'>"+m+ "</li><li>分</li>"+ "<li class='num'>"+s+ "</li><li>秒</li>";
      //}
      pastTime-=1000;
    }
    if(leftTime>0){
      time=leftTime;
      //var day = time/(1000*60*60*24);
      //if(day<=1){
        var h1=Math.floor(time/(1000*60*60));
        var m1=Math.floor(time/(1000*60))%60;
        var s1=Math.floor(time/(1000))%60;
        block.innerHTML="<li class='fst'>距离<br/>开始</li><li class='num'>" + h1 + "</li><li>时</li>"+ "<li class='num'>"+m1+ "</li><li>分</li>"+ "<li class='num'>"+s1+ "</li><li>秒</li>";
      //}
      leftTime-=1000;
    }
    if(pastTime<=0){
      block.innerHTML="<li></li><li class='num'>00</li><li>时</li><li class='num'>00</li><li>分</li><li class='num'>00</li><li>秒</li>";
      clearInterval(intervalId);
    }
  },1000);
}
_compLastIdx=1;
function showDetail(idx,cid){
  if(_compLastIdx!=idx){
    document.getElementById("c"+cid+"_"+idx).style.display="none";
    document.getElementById("c"+cid+"_"+idx+"_d").style.display="block";
    document.getElementById("c"+cid+"_"+_compLastIdx).style.display="block";
    document.getElementById("c"+cid+"_"+_compLastIdx+"_d").style.display="none";
    _compLastIdx=idx;
  }
}
_compLastCid=8005;
function changeCompositor(cid){
  if(_compLastCid!=cid){
    showDetail(1,_compLastCid);
    showDetail(1,cid);
    var tabCurr=document.getElementById("comp_tab_"+cid);
    var tabOther=document.getElementById("comp_tab_"+_compLastCid);
    if(cid==8005){
      tabCurr.className="current";
      tabCurr.setAttribute("class", "current");
      tabOther.className="link2";
      tabOther.setAttribute("class", "link2");
    }else{
      tabCurr.className="current2";
      tabCurr.setAttribute("class", "current2");
      tabOther.className="link";
      tabOther.setAttribute("class", "link");
    }
    document.getElementById("compositor_"+cid).style.display="block";
    document.getElementById("compositor_"+_compLastCid).style.display="none";
    _compLastCid=cid;
  }
}
_noticeLastIdx=1;
function changeNotice(idx){
  if(_noticeLastIdx!=idx){
    var tabCurr=document.getElementById("noticeLayer"+idx);
    var tabOther=document.getElementById("noticeLayer"+_noticeLastIdx);
    var isDisabled=true;
    if(idx==1){
      tabCurr.className="shopCur";
      tabCurr.setAttribute("class", "shopCur");
      tabOther.className="login";
      tabOther.setAttribute("class", "login");
      document.getElementById("affucgeLayer").style.zIndex="3";
      document.getElementById("loginLayer").style.zIndex="1";
      var form=document.getElementById("loginForm");
      if(form!=null){
        form.loginId.blur();
        form.password.blur();
        form.validateCode.blur();
      }
    }else{
      tabCurr.className="loginCur";
      tabCurr.setAttribute("class", "loginCur");
      tabOther.className="shop";
      tabOther.setAttribute("class", "shop");
      document.getElementById("affucgeLayer").style.zIndex="1";
      document.getElementById("loginLayer").style.zIndex="3";
    }  
    _noticeLastIdx=idx;
  }
}
_discountLastIdx=1;
function changeDiscountTab(idx){
  if(_discountLastIdx!=idx){
    var box=document.getElementById("discountBox");
    var tab1=document.getElementById("discountTab"+idx);
    var tab2=document.getElementById("discountTab"+_discountLastIdx);
    if(idx==1){
      box.className="mizone";
      box.setAttribute("class", "mizone");
      tab1.className="mizoneCur";
      tab1.setAttribute("class", "mizoneCur");
      tab2.className="hotSellLink";
      tab2.setAttribute("class", "hotSellLink");
      document.getElementById("discountContent1").style.display="block";
      document.getElementById("discountContent2").style.display="none";
    }else{
      box.className="hotSell";
      box.setAttribute("class", "hotSell");
      tab1.className="hotSellCur";
      tab1.setAttribute("class", "hotSellCur");
      tab2.className="mizoneLink";
      tab2.setAttribute("class", "mizoneLink");
      document.getElementById("discountContent2").style.display="block";
      document.getElementById("discountContent1").style.display="none";
    }
    _discountLastIdx=idx;
  }
}
_lastHotIdx=1;
function changeHotSell(cid,idx){
  if(_lastHotIdx!=idx){
    jQuery("#hotSellContent").load(_param.frontPath+"/"+_param.webIndex+"/IndexInclude/HotSellContent.do",{cid:cid});
    var curr=document.getElementById("hotColumn"+idx);
    var last=document.getElementById("hotColumn"+_lastHotIdx);
    curr.className="current";
    curr.setAttribute("class", "current");
    last.className="";
    last.setAttribute("class", "");
    _lastHotIdx=idx;
  }
}
function lastBrandPage(page,cid){
  jQuery("#brandContent").load(_param.frontPath+"/"+_param.webIndex+"/IndexInclude/HotSellBrandContent.do",{ccid:cid,page:page-1});
}
function nextBrandPage(page,cid){
  jQuery("#brandContent").load(_param.frontPath+"/"+_param.webIndex+"/IndexInclude/HotSellBrandContent.do",{ccid:cid,page:page+1});
}
_lastSubIdx=1;
function changeSubColumn(pid,cid,style,idx,count){
  if(_lastSubIdx!=idx){
    jQuery("#columnBox"+pid).load(_param.frontPath+"/"+_param.webIndex+"/IndexInclude/ColumnBoxStyle"+style+".do",{cid:cid});
    var curr=document.getElementById("subColumn"+pid+"_"+idx);
    var last=document.getElementById("subColumn"+pid+"_"+_lastSubIdx);
    var nomalClass=count==_lastSubIdx?"last":"";
    curr.className="current";
    curr.setAttribute("class", "current");
    last.className=nomalClass;
    last.setAttribute("class", nomalClass);
    if(_lastSubIdx>1)document.getElementById("subColumn"+pid+"_"+(_lastSubIdx-1)).removeAttribute("style");
    if(idx>1)document.getElementById("subColumn"+pid+"_"+(idx-1)).style.background="none";
    _lastSubIdx=idx;
  }
}