﻿
$(document).ready(function()
{$("#close").click(function(){$("#div3w").slideUp("slow",function(){$("#openbtn").css("display","block");$.cookie("IsClosed","Y",{expires:365,path:'/',domain:'.weirang.com'});})})
$("#openbtn").click(function(){$("#div3w").slideDown("slow",function(){$("#openbtn").css("display","none");})})});$(function(){var word='';var timeoutid=null;$("#keyword").keyup(function(event){var neword=$("#keyword").attr("value");var myEvent=event||window.event;var keyCode=myEvent.keyCode;switch(keyCode){case 38:if($("#keytips").css("display")=="block"){var arr=$("#keytips li").filter(".current");if(arr.length!=0){var index=$("#keytips li").index(arr[0]);switch(index){case 0:$("#keyword").attr("value",word);$("#keytips li").eq(index).removeClass("current");break;default:$("#keytips li").eq(index).removeClass("current");$("#keyword").attr("value",$("#keytips li").eq(index-1).children().eq(0).text());$("#keytips li").eq(index-1).addClass("current");}}
else{$("#keyword").attr("value",$("#keytips li").eq($("#keytips li").length-1).children().eq(0).text());$("#keytips li").eq($("#keytips li").length-1).addClass("current");}}else{autocomplete()};break;case 40:if($("#keytips").css("display")=="block"){var arr=$("#keytips li").filter(".current");if(arr.length!=0){var index=$("#keytips li").index(arr[0]);switch(index){case $("#keytips li").length-1:$("#keyword").attr("value",word);$("#keytips li").eq(index).removeClass("current");break;default:$("#keytips li").eq(index).removeClass("current");$("#keyword").attr("value",$("#keytips li").eq(index+1).children().eq(0).text());$("#keytips li").eq(index+1).addClass("current");}}
else{$("#keyword").attr("value",$("#keytips li").eq(0).children().eq(0).text());$("#keytips li").eq(0).addClass("current");}}else{autocomplete()};break;case 13:if($("#keytips").css("display")=="block"){var arr=$("#keytips li").filter(".current");if(arr.length!=0){var index=$("#keytips li").index(arr[0]);$("#keyword").attr("value",$("#keytips li").eq(index).children().eq(0).text());$("#keytips").css("display","none");};}else{if(neword!=word)autocomplete()}
break;default:if(neword!=""&&neword!=word){clearTimeout(timeoutid);timeoutid=setTimeout(function(){var url="http://suggest.taobao.com/sug?q="+neword+"&code=utf-8&callback=callback"
var s=document.createElement("script");s.setAttribute("src",url);s.setAttribute("id","GetOrder");document.getElementsByTagName("head")[0].appendChild(s);word=neword;},300)}else{$("#keytips").css("display","none");word=neword;}}})
$("body").click(function(){setTimeout(function(){$("#keytips").css("display","none")},100)})
function autocomplete(){var neword=$("#keyword").attr("value");var url="http://suggest.taobao.com/sug?q="+neword+"&code=utf-8&callback=callback"
var s=document.createElement("script");s.setAttribute("src",url);s.setAttribute("id","GetOrder");document.getElementsByTagName("head")[0].appendChild(s);word=neword;var children=document.getElementById("GetOrder");var parent=children.parentNode;parent.removeChild(children);}});function callback(a){var key=a.result;var keynum=key.length;var str="";for(i=0;i<keynum;i++){str+="<li><span>"+key[i][0]+"</span><em>约"+key[i][1]+"个宝贝</em></li>";}
$("#keytips").html(str);if(keynum>0){$("#keytips").css("display","block")}else{$("#keytips").css("display","none");}
$("#keytips li").hover(function(){$("#keyword").focus();var arr=$("#keytips li").filter(".current");if(arr.length!=0){var index=$("#keytips li").index(arr[0]);$("#keytips li").eq(index).removeClass("current");}
$(this).addClass("current");},function(){$(this).removeClass("current");});$("#keytips li").click(function(){var th=$(this).children().eq(0).text();$("#keyword").attr("value",th);$("#keytips").css("display","none");$("#taosearch").submit();})}
var tao=new Array();tao['img']=[,''];$('#tao_bg').css({'background-image':'url()'});function showNewTip(n){if($.cookie('tao[newUser]')<=2||$.cookie('tao[newUser]')==null){var bodyX=document.documentElement.clientWidth;var bodyY=document.documentElement.clientHeight;var moveX=parseInt(bodyX/2);var moveY=parseInt(bodyY/2);var newtips="<div class=\"tips_xiu\"><div class=\"tips_top\"><span><a href=\"javascript:;\" title=\"不再显示\" onclick=\"closeNewTip("+n+")\"> </a></span><h4 id=\"tips_title\">亲，您知道淘宝返利吗？</h4></div><div class=\"tips_bg\" id=\"tips_text\"></div><div class=\"tips_end\"></div></div>";if(($.cookie('tao[newUser]')==0||$.cookie('tao[newUser]')==null)&&n==1){var startX=parseInt(bodyX/2);var startY=100;$('body').append(newtips);$(".tips_xiu").css({left:startX,top:startY});$('#tips_text').html('<h3 style=\"margin-top:-10px;\"><span>淘宝购物</span>用<span>唯让网</span>可更省钱，真的吗？ <a href="http://huoban.taobao.com/spreader/sutaoDetail.htm?domain=weirang.com" target="_blank"><span>查看认证</span></a></h3><h4><img src=\"/images/jumpfanli.gif\" style=\"margin-left:-15px;\" /></h4><div class="tips_choose"><div class="smt1"><a href="/read-565.html" target="_blank">图解３步拿淘宝返利</a></div><div class="smt2"><a href="/user/register.php">立即注册</a></div></div>');}else if(($.cookie('tao[newUser]')==1||$.cookie('tao[newUser]')==null)&&n==2){var startX=parseInt(bodyX/2)+625;var startY=300;$('body').append(newtips);$(".tips_xiu").css({left:startX,top:startY});$('#tips_title').html('亲，您第一次使用！')
$('#tips_text').html('<h4 style="line-height:25px;">您如何使用<span>秀当网</span>到<span>淘宝购物</span>，才能拿到额外的<span>返利</span>呢？<br>秀当网支持下面两种方式，1分钟即可学会！</h4><div class="tips_choose"><div class="smt1"><a href="/help/video-1.html" target="_blank"><strong>简单３步</strong> 拿返利</a></div><div class="smt2"><a href="/help/video-3.html" target="_blank"><strong>一键</strong> 拿返利</a></div></div>');}
$(".tips_xiu").animate({left:moveX,top:moveY,width:369,opacity:'show'},{duration:400});$(window).scroll(function(){if($(".tips_xiu").css('display')=='block')$(".tips_xiu").css('top',$(document).scrollTop()+moveY);});}}
function closeNewTip(n){$.cookie('tao[newUser]',n,{expires:365,path:'/',domain:'.weirang.com'});var bodyX=document.documentElement.clientWidth;var bodyY=document.documentElement.clientHeight;var startX=parseInt(bodyX/2);var startY=100;if(n>1){startX=parseInt(bodyX/2)+625;startY=300;}
$(".tips_xiu").animate({left:startX,top:startY,width:0,height:0,opacity:'hidden'},{duration:400});}
