$(function(){var f=createSpinner();if(testSessionStorage()){window.sessionStorage.removeItem("tuan")}var d=$("#mc");if(testSessionStorage()){window.sessionStorage.setItem("crazy",d.html())}$("#modTit>li").click(function(){d.empty();$("#wait").show();f.spin($("#wait")[0]);$("#modTit>li.curr").removeClass("curr");$(this).addClass("curr");var h=$(this).attr("name");if(h=="tuan"){if(testSessionStorage()){var g=window.sessionStorage.getItem("tuan");if(!g){c()}else{d.html(g);f.stop();$("#wait").hide()}}else{c()}}else{if(h=="crazy"){if(testSessionStorage()){var g=window.sessionStorage.getItem("crazy");d.html(g);f.stop();$("#wait").hide()}else{e()}}else{if(h=="chongzhi"){if(testSessionStorage()){var g=window.sessionStorage.getItem("chongzhi");if(!g){b()}else{f.stop();$("#wait").hide();d.html(g)}}else{b()}}}}});function c(){var g=$("#sidId").val();jQuery.get("/tuan/index/index.json",{cityId:"-2",sid:g},h,"json");function h(n){var p='<div class="t-lists list">';if(n!=null){f.stop();$("#wait").hide();if(n.wares&&n.wares.length!=0){for(var j=0;j<n.wares.length;j++){var l="/tuan/wareInfo.html";var o=n.wares[j];var q=o.teamPrice/o.marketPrice;var k=getDiscount(o.marketPrice,o.teamPrice);var m=o.product;if(m.length>15){m=o.product.slice(0,15)}p+='<a title="" href="'+urlEncode(l,g,[o.cityId,o.categoryId,o.id,0,1])+'">';if(j==0){p+='<div class="box first"'}else{if(j==n.wares.length-1){p+='<div class="box last"'}else{p+='<div class="box"'}}p+=' style="background:url(/images/html5/arrow.png) center right no-repeat; margin-right:6px"><table cellspacing="0" cellpadding="0" class="tab t_table" width="95%"><tbody><tr><td class="p-img"  width="155px"><img  src="'+o.image+'"></td><td valign="top" class="text"><p class="p-name extend-font" >'+m+'</p><p class="p-detail">&#21407;&#20215;&#58;<del>&#65509;'+o.marketPrice+'</del><strong class="deal-price">&#165;'+o.teamPrice+'</strong></p></td></tr><tr><td width="145px"><p class="deal-buy" >'+o.nowNumber+'&#20154;&#24050;&#36141;&#20080;</p></td><td> <p class="discount"><span>'+Math.round(q*100)/10+"&#25240; &#30465;"+priceTransform(k)+"</span></p></td></tr></tbody></table>";p+="</div></a>"}}else{p+='<div class="box" >&#26242;&#26080;&#21830;&#21697;</div>'}p+="</div>";if(testSessionStorage()){window.sessionStorage.setItem("tuan",p)}}if($("li[name='tuan']").hasClass("curr")){$("#mc").html(p)}}}function e(){jQuery.get("/index/index.json",g,"json");function g(m){var j='<div class="t-lists">';if(m!=null){f.stop();$("#wait").hide();if(m.crazyList&&m.crazyList.length!=0){var l=5;if(m.crazyList.length<5){l=m.crazyList.length}for(var k=0;k<l;k++){var n=m.crazyList[k];var h=n.wname;if(h.length>40){h=h.substring(0,40)+"..."}j+='<a href="/product/'+n.wareId+'.html">';if(k==1){j+='<div class="box first" '}else{if(k==m.crazyList.length-1){j+='<div class="box last" '}else{j+='<div class="box" '}}j+='style="height:105px;background:url(/images/html5/arrow.png) center right no-repeat;margin-right:6px"><table cellspacing="0" cellpadding="0" class="tab" width="95%" ><tbody><tr><td class="p-img" style="float:none;" width="105px"><img src="'+n.imageurl+'"  alt=""/></td><td  valign="top" class="text"><div class="p-name" style="color: #3C3C3C;font-size: 0.875em;">'+h+'</div><div class="p-detail" style="width:180px; float:right"><span style="float:left">&#20140;&#19996;&#20215;&#65306;<img onerror="this.src=\'http://www.jd.com/images/no1.gif\'" src="'+n.wmaprice.slice(0,n.wmaprice.length-5)+'3.png" alt=""/><span></div></td></tr></tbody></table></div></a>'}}else{j+='<div class="box first">&#26242;&#26080;&#21830;&#21697;</div></div>'}if($("li[name='crazy']").hasClass("curr")){d.html(j)}}}}function b(){var g=$("#sidId").val();jQuery.get("/chongzhi/preIndex.action",{idProvince:0,sid:g},function(h){if(h!=null){f.stop();$("#wait").css("display","none");if(testSessionStorage()){window.sessionStorage.setItem("chongzhi",h)}if($("li[name='chongzhi']").hasClass("curr")){$("#mc").html(h)}}})}$("#open-close").click(function(){if($(this).hasClass("add")){$("#news").show();$(this).removeClass("add");$(this).addClass("reduce")}else{$("#news").hide();$(this).removeClass("reduce");$(this).addClass("add")}});userLocation("loc-location","location");if(testStorage()){var a=getUserCity();if(!!a){$("#loc-location").html(a+"<span  style='color:blue;font-size:0.875em;padding-left:15px;' href=''>&#26356;&#26032;</span>")}}});