//tab切换 var root; function tabs(id,title,content,box,on,type,action){ if(type){ $(id+' '+title).click(function(){ $(this).addclass(on).siblings().removeclass(on); $(content+" > "+box).eq($(id+' '+title).index(this)).show().siblings().hide(); }); }else{ $(id+' '+title).mouseover(function(){ $(this).addclass(on).siblings().removeclass(on); $(content+" > "+box).eq($(id+' '+title).index(this)).show().siblings().hide(); }); } if(action){ $(id+' '+title).eq(action).addclass(on).siblings().removeclass(on); $(content+" > "+box).eq(action).show().siblings().hide(); }else{ $(id+' '+title).eq(0).addclass(on).siblings().removeclass(on); $(content+" > "+box).eq(0).show().siblings().hide(); } } function setcookie(name,value){ var days = 30; var exp = new date(); exp.settime(exp.gettime() + days*24*60*60*1000); document.cookie = name + "="+ escape (value) + ";expires=" + exp.togmtstring(); } function getcookie(name){ var arr = document.cookie.match(new regexp("(^| )"+name+"=([^;]*)(;|$)")); if(arr != null){ name1=unescape(arr[2]); var name = name1.replace(/[\',\"]/g,""); return name; }else{ return ""; } } function delcookie(name){ var exp = new date(); exp.settime(exp.gettime() - 1); var cval=getcookie(name); if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.togmtstring(); } function showlogin() { var auth = getcookie('tp_auth'); if(auth != '') { $('#login_username').html(unescape(getcookie('tp_username'))); $('#login_div').hide(); $('#logined_div').show(); } else { $('#logined_div').hide(); $('#login_div').show(); } } $(function(){ showlogin(); }); function resetverifycode(){ var timenow = new date().gettime(); document.getelementbyid('verifyimage').src= root+'/index.php?g=home&m=index&a=verify#'+timenow; } function donghua(obj){ var speed=20; var demoh = document.getelementbyid(obj); var demoh1 = document.getelementbyid(obj+'_1'); var demoh2 = document.getelementbyid(obj+'_2'); demoh2.innerhtml=demoh1.innerhtml; function wfdh(){ if(demoh2.offsetwidth-demoh.scrollleft<=0){demoh.scrollleft-=demoh1.offsetwidth;} if(demoh2.offsetwidth-demoh.scrollleft>0){demoh.scrollleft++;} } var mymarh=setinterval(wfdh,speed); demoh.onmouseover=function() {clearinterval(mymarh);} demoh.onmouseout=function() {mymarh=setinterval(wfdh,speed);} } function showon(obj,onobj,id){ $(obj+' '+ onobj).click(function(){ //$(this).parent().addclass('on').siblings().removeclass('on'); if($(this).parent().hasclass('on')){ $(this).parent().removeclass('on'); }else{ $(this).parent().addclass('on'); } }); if(id){ $('#catlist_'+id).parent().parent().addclass('on'); } } function floaters() { this.delta=0.15; this.playid =null; this.items = []; this.additem = function(id,x,y,content) { var newitem = {}; newitem.object = document.getelementbyid(id); if(x==0){ objw= newitem.object.offsetwidth; var body = (document.compatmode && document.compatmode!="backcompat")? document.documentelement : document.body; newitem.x = x = body.scrollleft + (body.clientwidth - objw)/2; newitem.y = y; }else{ newitem.x = x; newitem.y = y; } this.items[this.items.length] = newitem; } this.play =function(varname){ this.playid = setinterval(varname+'.plays()',30); } this.close = function(obj){ document.getelementbyid(obj).style.display='none'; //clearinterval(this.playid); } } floaters.prototype.plays = function(){ var diffy; if (document.documentelement && document.documentelement.scrolltop) { diffy = document.documentelement.scrolltop; } else if (document.body) { diffy = document.body.scrolltop; }else{} for(var i=0;i= 0){ obj.style['left'] = this.items[i].x+ 'px'; }else{ obj.style['right'] = math.abs(this.items[i].x)+ 'px'; } if( obj.offsettop != total) { var oldy = (total - obj.offsettop) * this.delta; newtop = obj.offsettop + ( oldy>0?1:-1 ) * math.ceil( math.abs(oldy) ); obj.style['top'] = newtop + 'px'; } } } function changeorder(obj,moduleid,id,doit,ordercall){ var objs = document.getelementbyid(obj); var datas={'moduleid':moduleid,'id': id,'num':objs.value}; $.ajax({ type:"post", url: root+"/index.php?m=cart&a=ajax&do="+doit, data: datas, timeout:"4000", datatype:"json", success: function(data){ if(data.data==1){ ordercall.call(this,obj,moduleid,id,doit,data); }else{ alert(doit + ' error'+data.msg); } }, error:function(){ alert("time out,try it"); } }); } function area_change(id,level,province,city,area,provinceid,cityid,areaid){ var datas={'level':level,'provinceid':provinceid,'cityid':cityid,'areaid':areaid}; $.ajax({ type:"post", url: root+"/index.php?m=ajax&a=area&id="+id, data: datas, timeout:"4000", datatype:"json", success: function(data){ if(level==0){ $('#'+province).html(data.province); $('#'+city).html(data.city); $('#'+area).html(data.area); }else if(level==1){ $('#'+city).html(data.city); $('#'+area).html(data.area); }else if(level==2){ $('#'+area).html(data.area); } }, error:function(){ //alert("time out,try it"); } }); }