jQuery(document).ready(function(){
  jQuery("#topKeywords").suggest(_frontPath+"/AutoComplete",{minchars:1,fn:'submitSearchForm()'});
});
function showProBox(){
  var obj=document.getElementById("proBox");
  obj.className="prohover";
  obj.setAttribute("class","prohover");
  document.getElementById("showProBox").style.display="block";
}
function hideProBox(){
  var obj=document.getElementById("proBox");
  obj.className="pro";
  obj.setAttribute("class","pro");
  document.getElementById("showProBox").style.display="none";
}
_sortType=1;
function selectedProBox(curr,num){
  var obj=document.getElementById("proBox");
  obj.className="pro";
  obj.setAttribute("class","pro");
  obj.innerHTML=curr.innerHTML;
  document.getElementById("showProBox").style.display="none";
  _sortType=num;
  if(num==1){
    document.getElementById("SortCid").value="603";
    document.getElementById("searchform").setAttribute("action", _frontPath+"/ProductList.do");
  }else{
    document.getElementById("InfoCid").value="904";
    document.getElementById("searchform").setAttribute("action", _frontPath+"/InfoCenter/InfoList.do");
  }
  document.getElementById("allBox").innerHTML="所有分类";
}
function showAllBox(){
  var obj=document.getElementById("allBox");
  obj.className="allhover";
  obj.setAttribute("class","allhover");
  document.getElementById("showAllBox"+_sortType).style.display="block";
}
function hideAllBox(){
  var obj=document.getElementById("allBox");
  obj.className="all";
  obj.setAttribute("class","all");
  document.getElementById("showAllBox"+_sortType).style.display="none";
}
function selectedAllBox(curr,id){
  var obj=document.getElementById("allBox");
  obj.className="all";
  obj.setAttribute("class","all");
  obj.innerHTML=curr.innerHTML;
  document.getElementById("showAllBox"+_sortType).style.display="none";
  if(_sortType==1)document.getElementById("SortCid").value=id;
  else document.getElementById("InfoCid").value=id;
}
function showTopCartBox(count){
  if(count>0)document.getElementById("cartOpen").style.display="";
}
function hideTopCartBox(){
  document.getElementById("cartOpen").style.display="none";
}
function showSaleBox(count){
  if(count>0)document.getElementById("featureOpen").style.display="";
}
function hideSaleBox(){
  document.getElementById("featureOpen").style.display="none";
}
function checkTopSearchForm(){
  var keyword=jQuery("#topKeywords");
  if(_sortType==1){
    if(keyword.val()!=""){
      jQuery("#thKeywords").val(jQuery.trim(keyword.val()));//+",title,content"
    }else{
      alert("请输入搜索关键字！");
      keyword.focus();
      return false;
    }
  }else{
    if(keyword.val()!=""){
      jQuery("#infoKeyword").val(jQuery.trim(keyword.val()));
    }else{
      alert("请输入搜索关键字！");
      keyword.focus();
      return false;
    }
  }
  return true;
}
function submitSearchForm(){
  if(!checkTopSearchForm())return false;
  document.getElementById("searchform").submit();
}
var scrollInterval=0;
function sideCartScroll (id,_top){
  var me=id.charAt?document.getElementById(id):id,d1=document.body,d2=document.documentElement;
  d1.style.height=d2.style.height='100%';
  me.style.top=_top?_top+'px':0;//me.style.left=_left+"px";//[(_left>0?'left':'left')]=_left?Math.abs(_left)+'px':0;
  intervalSideCart(me,d1,d2,_top);
  return arguments.callee;
}
function intervalSideCart(me,d1,d2,_top){
  scrollInterval=setInterval(function (){
    me.style.top=parseInt(me.style.top)+(Math.max(d1.scrollTop,d2.scrollTop)+_top-parseInt(me.style.top))*0.1+'px';
  },10+parseInt(Math.random()*20));
}
function showSideCart(id){
  clearInterval(scrollInterval);
  var top=document.getElementById(id).offsetTop;
  var sideCart=jQuery("#scroll");
  sideCart.css("top",top+"px").slideDown(10);
}
function hideSideCart(){
  var sideCart=document.getElementById("scroll");
  sideCart.style.display="none";
}
function overSideCart(){
  clearInterval(scrollInterval);
  var sideCart=document.getElementById("scroll");
  sideCart.style.display="block";
}
function outSideCart(){
  var sideCart=document.getElementById("scroll");
  sideCart.style.display="none";
  var me=document.getElementById("sideScroll"),d1=document.body,d2=document.documentElement;
  intervalSideCart(me,d1,d2,185);
}
_sideCartBoxTop=0,_currIdx=1;
function sideCartUp(){
  if(_currIdx==1)return;
  var box=document.getElementById("sideCartBox");
  _sideCartBoxTop+=50;
  _currIdx--;
  box.style.top=_sideCartBoxTop+"px";
}
function sideCartDown(count){
  if(_currIdx+2>=count)return;
  var box=document.getElementById("sideCartBox");
  _sideCartBoxTop-=50;
  _currIdx++;
  box.style.top=_sideCartBoxTop+"px";
}
function loginOutSNS(snsLoginConn){
//  if(snsLoginConn=="yes"){
//    jQuery.ajax({timeout:2000,type:"GET",dataType:"script",url:_snsUrl+"emall/exitControl.jsp",cache:false,complete:function(){window.location=_frontPath+"/Member/Exit.do";},error:function(){window.location=_frontPath+"/Member/Exit.do";}});
//  }else{
//    window.location=_frontPath+"/Member/Exit.do";
//  }
//  window.location.href=_frontPath+"/clearFrontendSessionForSNS.jsp?emallUrl="+_snsUrl+"emall/exitControl.jsp";
}