function UseMobile(){var t=["midp","j2me","avant","docomo","novarra","palmos","palmsource","240x320","opwv","chtml","pda","windows ce","mmp/","blackberry","mib/","symbian","wireless","nokia","hand","mobi","phone","cdm","up.b","audio","sie-","sec-","samsung","htc","mot-","mitsu","sagem","sony","alcatel","lg","eric","vx","NEC","philips","mmm","xx","panasonic","sharp","wap","sch","rover","pocket","benq","java","pt","pg","vox","amoi","bird","compal","kg","voda","sany","kdd","dbt","sendo","sgh","gradi","jb","dddi","moto","iphone","android","iPod","incognito","webmate","dream","cupcake","webos","s8000","bada","googlebot-mobile"],i=navigator.userAgent.toLowerCase(),n;if(i.indexOf("messenger")>0)return!1;for(n=0;n<t.length;n++)if(i.indexOf(t[n])>0)return!0;return!1}function CheckNoHtml(n){return!/<([a-z]+) *[^\/]*?>/.test(n)}function NewWindow_epaper(){thewindow=window.open("/Other/ePaper","thewindow","left=150,top=200,width=460,height=310");thewindow.opener==null&&(thewindow.opener=window)}function NewWindow_spoof(){thewindow=window.open("/StaticPage/spoof.html","thewindow","top=50,width=850,height=800");thewindow.opener==null&&(thewindow.opener=window)}function searchcheck(){var n=$("#qu").val(),t=$("#ct option:selected").val(),r="",u,f,e;if(t==undefined&&(t="K"),n.length==0?(u=$(".searchkey").find('a[href*="search"]').length,f=Math.floor(Math.random()*u),n=$(".searchkey").find('a[href*="search"]').eq(f).text()):n.length>0?(n=n.replace(/[\!|\~|\`|\&|\!|\@@|\$|\%|\^|\&|\*|\(|\)|\_|\=|\||\\|\[|\]|\{|\}|\;|\:|\,|\<|\.|\>|\/|\〔|\〕|\【|\】]/g," "),n=n.replace(/  /g," ").replace(/  /g," ").replace(/ /g," "),n=n.replace(" AND "," and ").replace(" OR "," or "),$("#qu").val(n)):r="請輸入至少一個字以上來查詢。",r==""){var o=t,i="";["TC","S","HK","P","R","D","R","L"].indexOf(t)>=0?(i="&fq=ProdType:"+t,t="K"):t=="NP"?(t="K",i="&fq=ProdType:N"):t=="Bonus"&&(t="K",i="&fq=BonusRebatePoint:[1%20TO%20*]");e=/^([\d]{9})(x{1}|X{1}|[\s]{0}|[\d]{1}|[\d]{3,4})$/;e.test(n)&&(t="ISBN");location.href="/search/index/?ct="+t+"&qu="+encodeURIComponent(n)+i}else return alert(r),!1;return!1}function searchcheckmobile(){var n=$("#qumobile").val(),t=$("#ctmobile option:selected").val(),r="",u,f,e;if(t==undefined&&(t="K"),n.length==0?(u=$(".searchkey").find('a[href*="search"]').length,f=Math.floor(Math.random()*u),n=$(".searchkey").find('a[href*="search"]').eq(f).text()):n.length>0?(n=n.replace(/[\!|\~|\`|\&|\!|\@@|\$|\%|\^|\&|\*|\(|\)|\_|\=|\||\\|\[|\]|\{|\}|\;|\:|\,|\<|\.|\>|\/]/g," "),n=n.replace(/  /g," ").replace(/  /g," ").replace(/ /g," "),n=n.replace(" AND "," and ").replace(" OR "," or "),$("#qumobile").val(n)):r="請輸入至少一個字以上來查詢。",r==""){var o=t,i="";["TC","S","HK","P","R","D","R","L"].indexOf(t)>=0?(i="&fq=ProdType:"+t,t="K"):t=="NP"?(t="K",i="&fq=ProdType:N"):t=="Bonus"&&(t="K",i="&fq=BonusRebatePoint:[1%20TO%20*]");e=/^([\d]{9})(x{1}|X{1}|[\s]{0}|[\d]{1}|[\d]{3,4})$/;e.test(n)&&(t="ISBN");location.href="/search/index/?ct="+t+"&qu="+encodeURIComponent(n)+"&ls=SD"+i}else return alert(r),!1;return!1}function GoTop(){$("html,body").stop().animate({scrollTop:0},500)}function Go(n){Loading("show");GoTop();setTimeout(function(){location.href=n},500)}function GoTo(n){Go(n)}function GO(n){Go(n)}function GoHome(){location.href="/home/index/"}function Move(n){$("html,body").stop().animate({scrollTop:n},500)}function Login(){Loading("show");setTimeout(function(){location.href="/Member/Login/?returnurl="+location.href.replace(/&/g,"%26")},500)}function Logout(){Loading("show");setTimeout(function(){location.href="/Member/Logout/?returnurl="+location.href.replace(/&/g,"%26")},500)}function LoginPanel(n){if(n==="True"){var t=$(".LoginMenu").find(".btnLogin");t.addClass("btnLogout").removeClass("btnLogin").text("會員登出").attr("onclick","Logout();")}}function open_window(n){aWindow=window.open(n,"aWindow","Toolbar=no,width=982,height=460,status=no,scrollbars=yes, resize=no,menubar=no")}function AddItem(n,t,i){var r,e,u;sanminCrossDomain.push({addPfid:n});sanminCrossDomain.push({event:t?"AddQuickCart":"AddCart"});$("#DivAddItem").length==0&&$("<div/>").attr("id","DivAddItem").appendTo("body");var o=$("#DivAddItem"),s=$("<div/>").attr("style","disply:none;"),f="";return t==!0&&(f="&quickMode=True"),r="",i&&(r="&sFlag="+i),e=httpsHost+"/Shopping/AddItem/?id="+n+"&js=true"+f+r,$(".AddScript").remove(),u=$("<script/>").addClass(".AddScript"),u.attr("src",e),u.appendTo("body"),!0}function AddFavorite(n){var t="/Shopping/AddFavorite/"+n;Loading("show");$.ajax({type:"GET",url:t,cache:!1}).done(function(t){AddItemOK(t);Loading("hide");sanminCrossDomain.push({addPfid:n});sanminCrossDomain.push({event:"AddWishlist"})}).fail(function(){Loading("hide")})}function GoogleBook(n,t){var r=confirm("您將離開此頁面，前往Google圖書平台"),i;r==!0&&(sanminCrossDomain.push({addPfid:t,event:"BuyFreeEBook"}),i="https://play.google.com/store/books/details?id="+n,window.open(i))}function FreeEBook(n){alert("尚未開放下載，敬請期待");sanminCrossDomain.push({addPfid:n,event:"DownFreeEBook"})}function AddItemOK(n){Loading("hide");MsgBox(n)}function ReloadCaptchaImg(){var n=Math.floor(Math.random()*100);$("#CaptchaImg").attr("src","/other/Captcha/"+n)}function LoadOrderInfo(){AjaxJsView("OrderInfo","OrderInfoBox")}function JsonLoad(n,t){var i=$("#"+n);$.getJSON(t).done(function(n){i.html(n.value)})}function AjaxJsView(n,t){var i=$("<script/>").attr("type","text/javascript");i.attr("src","/API/AjaxJsView/"+n+"/"+t);i.appendTo("body")}function GetBrowser(){var u=navigator.userAgent.toLowerCase(),n="other",i=["msie 5.0","msie 6.0","msie 7.0","msie 8.0","msie 9.0","msie 10.0","like gecko","firefox","safari","opera","netscape","chrome"],r,t;for(r in i)t=i[r],u.indexOf(t)!=-1&&(n=t),n=="like gecko"&&(n="IE11"),n=n.replace(/ /g,"").replace("msie","IE");return n}function Lazyload(){var n=$(".lazyload,div.SanminProdImg img,img.SanminProdImg,img.SanminProdImg2");if(n.length>0){var t=$(window).scrollTop(),i=self.innerHeight,r=t+i;n.each(function(){var n=$(this),t=n.attr("original");ShowProdImg(n)})}}function ShowProdImg(n){var t=n.attr("original");n.removeClass("lazyload").removeAttr("original");n.attr("src",t)}function SelectAll(){$(".Ck_add").each(function(){this.checked=!0})}function SelectClear(){$(".Ck_add").each(function(){this.checked=!1})}function SelectToAdd(){var n="";$('input:checkbox:checked[class="Ck_add"]').each(function(){n+="+"+$(this).val()});n.length>1&&AddItem(n.substring(0),!1)}function sleep(n){for(var t=new Date,i=t.getTime()+n;;)if(t=new Date,t.getTime()>i)return}function WindowsCenter(n){var t=$("."+n),r=t.width(),f=t.height(),i,u;$(window).width()<t.width()&&(r=$(window).width()-10,t.css("width",r));i=$(window).height()/2-f/2;u=$(window).width()/2-r/2;i<0&&(i=400);t.css("left",u).css("top",10).css("opacity",0);t.stop().animate({top:i,opacity:1},200)}function getCookie(n){for(var r=n+"=",u=document.cookie.split(";"),t,i=0;i<u.length;i++){for(t=u[i];t.charAt(0)==" ";)t=t.substring(1);if(t.indexOf(r)==0)return t.substring(r.length,t.length)}return""}function setCookie(n,t,i){var r=new Date,u;r.setTime(r.getTime()+i*864e5);u="expires="+r.toUTCString();document.cookie=n+"="+t+"; "+u}function Loading(n){var i=$("#Body"),e=i.offset(),u=e.top,f=i.height(),t,r;n==="show"?(t=$("<div/>").addClass("LoadingBk"),r=$("<div/>").addClass("LoadingImg"),r.html("<p>載入中請稍候<\/p>"),$("#ReOrderLoad").length===1?t.css("top",u).height(f):t.css("top",u).height(f),t.appendTo("body"),r.appendTo("body")):($(".LoadingBk").remove(),$(".LoadingImg").remove(),i.show())}function MVCAlert(n){var t=$("<div/>").load("/other/alert/?id="+encodeURIComponent(n));t.appendTo("body")}function MsgBox(n,t,i){var f=UseMobile(),r,u;t===undefined&&(t="");i===undefined&&(i=400);f===!1?(n=n.replace(/\n/g,"<br/>"),r=$("<div/>"),u=$("<div/>"),u.addClass("MsgBoxForm").html('<div class="MsgStr"><b>'+n+'<\/b><\/div><div style="text-align:center;"><button class="OK">確定<\/button><\/div>').width(i).appendTo(r),r.addClass("MsgBox BlackBG").appendTo("body").show(),WindowsCenter("MsgBoxForm"),u.find(".OK").click(function(){t.length>0&&(location.href=t);r.remove()}).focus(),r.click(function(){u.find(".OK").click()})):(n=n.replace("<br/>","\n"),alert(n),t.length>0&&(location.href=t))}function AjaxForm(n,t,i){function u(r){var u=$("#"+r);u.find(".modal-title").html(n);i!=undefined&&u.find(".modal-dialog").width(i);n==="系統提示"?(u.find(".modal-body").html(t),u.modal("show"),setTimeout(function(){Loading("hide")},500)):$.ajax({type:"GET",url:t,data:{ajax:"true"},cache:!1}).done(function(n){u.find(".modal-body").html(n);u.modal("show");setTimeout(function(){Loading("hide")},500)}).fail(function(){alert("error");setTimeout(function(){Loading("hide")},500)})}var r="AjaxForm";Loading("show");setTimeout(function(){$("#"+r).length===0?$.ajax({type:"GET",url:"/other/viewhelper/modal/"+r,cache:!1}).done(function(n){var t=$("<div/>");t.appendTo("body").replaceWith(n);u(r)}).fail(function(){alert("error")}):u(r)},500)}function AjaxLink(n){var t,i;if(n.length>0){if(n.indexOf("java")>=0||n==="#")return!0;Loading("show");$("html,body").animate({scrollTop:0},500);$(window).scrollTop(0);t={href:n};n.substring(0,1)=="/"&&MyBrowser.substring(0,2)!="IE"&!1?$.ajax({type:"POST",url:n,data:{nolayout:!0},cache:!1}).done(function(n){$("Body").html(n);Loading("hide")}).fail(function(){alert("error")}):location.href=n}else i=GetBrowser(),$("#Loading").show();return!1}function Get_Company_Name(n,t){var i=$("#"+n).val(),r;/^([\d]{8})$/.test(i)?($("#"+t).val(""),r="/API/Company/"+i,Loading("show"),$.ajax({type:"get",url:r,dataType:"json",success:function(n){$("#"+t).val(n[0].Company_Name);Loading("hide")},error:function(){alert("查不到此統一編號的相關資訊，請自行輸入抬頭。");Loading("hide")}})):alert("您的統一編號格式非8碼數字。")}function check_carrier(n,t){var i=$("#"+n).val(),r="",u;t=="990000"?r=/^([0-9]{3,7})$/:t=="3J0002"&&(r=/^[\/]{1}([A-Z0-9\.\-\+]){7}$/);r.test(i)?(i=encodeURIComponent(i),u="/API/Bizapivan?id="+i+"&type="+t,Loading("show"),$.ajax({type:"get",url:u,dataType:"json",success:function(n){n.isExist=="Y"?alert("此為可使用載具。"):alert("查無此資料");Loading("hide")},error:function(){alert("查無此資料");Loading("hide")}})):alert("您的載具格式有誤。")}function BrowserProdAdd(n,t,i,r){var f,s;if(n!=""){var o={id:n,ISBN:t,name:i,src:r},e=localStorage.getItem(BrowserProdKey),u=[];e!=""&&e!=undefined&&(u=JSON.parse(e));f=!0;$.each(u,function(n,t){t.id==o.id&&(f=!1)});f&&u.length>5&&u.splice(0,1);f&&(u.push(o),s=JSON.stringify(u),localStorage.setItem(BrowserProdKey,s))}}function BrowserProdLog(n){var r=localStorage.getItem(BrowserProdKey),u,t,f,i;r!=""&&r!=undefined&&(u=JSON.parse(r),t=$("#ProdBrowse"),u.length>0&&t.length>0&&(f=t.find(".swiper-wrapper"),i=0,$.each(u,function(t,r){if(n!=r.ISBN){i+=1;var u=$("<div/>").addClass("item swiper-slide");u.html('<div class="topBook"><div class="frame'+t+'"><div class="product2img"><a href="/Product/index/'+r.id+'"><img src="'+r.src+'"><\/a><\/div><div class="topBookh3" style="height: 40px;line-height: 18px;overflow:hidden;"><a href="/Product/index/'+r.id+'">'+r.name+"<\/a><\/div><\/div><\/div>");i==1?u.appendTo(f):u.insertBefore(f.find(".item").eq(0))}}),i>0&&t.show()))}function BrowserConfigLoad(){var n=localStorage.getItem("BrowserConf");n!=undefined&&(BrowserConf=JSON.parse(n))}function BrowserConfigSave(){var n=JSON.stringify(BrowserConf);localStorage.setItem("BrowserConf",n)}function BrowserProdLayout(){var t=localStorage.getItem(BrowserProdKey),n;if(t!=""&&t!=undefined&&(n=JSON.parse(t),n.length>0)){BrowserConfigLoad();$(".extend").css("right",BrowserConf.ShowBrowserLog?"0px":"-85px");$(".extend .frame ul li").remove();$(".extend .booksExtend").css("visibility","initial");$.each(n,function(n,t){var i=$("<li/>").html('<div class="Promote_book"><a href="/product/index/'+t.id+'" target="_blank"><img src="'+t.src+'" alt="" title="'+t.name+'" /><\/a><\/div>');n==0?i.appendTo($(".extend .frame ul")):i.insertBefore($(".extend .frame ul").find("li").eq(0))});switch(n.length){case 1:$(".extend .booksExtend").css("height","130px");break;case 2:$(".extend .booksExtend").css("height","225px");break;case 3:break;default:$(".extend .carouselbtn").show()}$(".extend .imgExtend").show()}$(".extend .imgExtend").click(function(){var n=!($(".extend").css("right")=="0px");$(".extend").animate({right:n?"0px":"-85px"},500);BrowserConf.ShowBrowserLog=n;BrowserConfigSave()});$(".carouselvertical").each(function(){var t=$(this),l=t.find(".page"),u=t.find(".carouselbtn"),o=t.find(".frame").height(),f=t.find("ul"),i=f.find("li"),s=i.length,r=Math.ceil(o/i.outerHeight(!0)),e=Math.ceil(s/r),h=r*i.outerHeight(!0)*-1,c=400,n=0;i.length<=3&&u.hide();u.find(".prev, .next").click(function(t){n=Math.floor((t.target.className=="prev"?n-1+e:n+1)%e);var i=r*(n+1);f.stop().animate({top:n*h},c);t.preventDefault()}).focus(function(){this.blur()})})}function AdColse(n){$("#"+n).remove();document.cookie=n+"=true;domain=sanmin.com.tw"}function AdShow(n){var t=$("#"+n);getCookie(n)==""&&(t.show(),t.find("button").click(function(){AdColse(n)}))}var nuderIE8,Nowurl,httpsHost,BrowserProdKey,BrowserConf;location.href.indexOf("www.m.sanmin.com.tw")>0&&(location.href=location.href.replace("www.m.sanmin.com.tw","www.sanmin.com.tw"));var support=$.support,specialEffect=support.style,userAgent=navigator.userAgent.toLowerCase(),MyBrowser=GetBrowser();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};nuderIE8=!1;v=$.browser.version;$.browser.msie==!0&&(v=="7.0"||v=="6.0")&&(nuderIE8=!0),function(){jQuery.fn.setfocus=function(){return this.each(function(){var n=this;setTimeout(function(){try{n.focus()}catch(t){}},0)})}}(jQuery);$(function(){function it(){StartSearchFlag=!1;setTimeout(rt,500)}function rt(){var n,r,u;StartSearchFlag||(n=i.val(),r=i.offset(),n=n.trim(),rephonetic=/[\u3105-\u3129\u02CA\u02C7\u02CB\u02D9]/,n.length>=1&&n.length<=10?(t.css("top",r.top+50).css("left",r.left).css("min-width",i.width()+2).css("z-index",999),u=rephonetic.exec(n.substr(-1,1))==null,u&&(t.toggle(!1),tmpWord!=n&&($TipWord.find("li").remove(),$.getJSON("/Search/keyWord/"+encodeURIComponent(n),function(r){$.each(r,function(t,r){$li=$("<li/>").html(r);$li.click(function(){tmpWord=n;i.val($(this).text());y()});$li.appendTo($TipWord)});$TipWord.find("li").length>0&&t.delay(100).toggle(!0)}),StartSearchFlag=!1,tmpWord=n),$TipWord.find("li").length>0&&t.delay(100).toggle(!0))):y())}function y(){$TipWord.find("li").remove();t.toggle(!1)}function g(t){var u=h.eq(t),i,r;e=t;i=n.find("li").eq(t).find("img");r=i.attr("original");typeof orininal!==undefined&&i.attr("src",r).removeAttr("orininal");p.find(".ICON-ball_Red").removeClass("ICON-ball_Red").addClass("ICON-ball_Gray");u.removeClass("ICON-ball_Gray").addClass("ICON-ball_Red");t-l>=2?n.css("margin-left",(-t+1)*585):l-t>=2&&n.css("margin-left",(-t-1)*585);n.stop().animate({"margin-left":-t*585},300);l=t}function a(){e+1>=d?e=0:e+=1;g(e);r=setTimeout(a,s)}function ut(){f||$(".ShoppingMenu_child").hide()}var i,t,b,h,l,o,v,u,w,nt,f;Lazyload();MyBrowser.substring(0,2)!="IE"&&!1&&$("a").click(function(n){var r=n.button,i,t;if(r==0&&(i=$(this).attr("target"),t=$(this).attr("href"),$(".popover").remove(),(typeof i==typeof undefined||i==!1)&&typeof t!=typeof undefined&&t.indexOf("#")<=0))return AjaxLink(t)});i=$("#qu");t=$(".SearchTip");$TipWord=t.find(".TipWord");tmpWord="";speed_SETIP=200;StartSearchFlag=!1;i.focusin(function(){}).focusout(function(){setTimeout(y,500)}).keyup(function(){StartSearchFlag=!0;setTimeout(it,500)});b=20;$(".PromoProd").each(function(){var i=$(this).height(),u=$(this).find(".ProdInfo").height(),n=$(this).find(".Intro").text(),r=$(this).find(".Title>a").attr("href"),t;n=n.replace(/ /g,"");n.length>10&&(t=$("<div/>").addClass("ICON").addClass("ICON-more").addClass("BtnMore").attr("onclick","GO('"+r+"')"),t.css("top",i-b).appendTo($(this)))});var k=$(".Menu585"),n=k.find(".Promo_list>ul"),d=n.find("li").length,p=k.find(".btn_number>ul"),r,s=3e3,e=0;if(n.find("li").each(function(){$("<li/>").addClass("ICON-ball_Gray").addClass("ICON").appendTo(p)}),n.width(d*585),h=p.find("li"),h.eq(0).addClass("ICON-ball_Red").removeClass("ICON-ball_Gray"),h.hover(function(){g($(this).index());clearTimeout(r)},function(){r=setTimeout(a,s)}).click(function(){window.open(n.find("a").eq($(this).index()).attr("href"))}),n.hover(function(){clearTimeout(r)},function(){r=setTimeout(a,s)}),r=setTimeout(a,s),l=0,o=$(".HeadImg"),v=o.length,o.eq(0).show(),v>1){u=1;w=5e3;function tt(){o.hide();o.eq(u).show();u=u+1;u>=v&&(u=0);nt=setTimeout(tt,w)}v>1&&(nt=setTimeout(tt,w))}$(window).resize(function(){_windowHieight=$(window).height();$(window).width()<1745?$(".specbox").css("height",30):$(".specbox").css("height",0)}).resize();$('a[href^="/Shopping/AddItem/"]').each(function(){var t=$(this),n=t.attr("href");n.indexOf("/Shopping/AddItem/")==0&&(n=n.replace("/Shopping/AddItem/",""),c="",$(this).attr("class")&&(c=$(this).attr("class")),n=c.indexOf("quick")>=0?"javascript:AddItem('"+n+"',true);":"javascript:AddItem('"+n+"',false);",t.attr("href",n),t.addClass("AddItem"))});$('a[href*="javascript:AddItem"]').each(function(){var n=$(this).attr("href");$(this).attr("href",n.replace(/&#39;/g,'"'))});$(".modal").appendTo("body");$(".ClassMenu").each(function(){var t=$(this),f=t.find("li"),i=t.find("span"),r=t.attr("value"),n,u;i.length>0&&(n=i.eq(0).attr("name"),typeof n!="undefined"&&n!==!1&&(u=n.length,i.click(function(){var n=$(this).attr("name");AjaxLink(r+n)})))});f=!1;$("#ShoppingMenu").find("li").mouseenter(function(){var n;if(f=!1,$(".ShoppingMenu_child").hide(),$("#ShoppingMenu").find("li").removeClass("active"),n="."+$(this).attr("class"),$(n).length>0){f=!0;var t=$(this).offset(),i=t.left,r=t.top;$(n).css("left",i).css("top",r+40).show();$(this).addClass("active")}});$(".ShoppingMenu").mouseleave(function(){f=!1;setTimeout(function(){ut()},100)});$(".ShoppingMenu_child").mouseenter(function(){f=!0}).mouseleave(function(){$(this).hide();$("#ShoppingMenu").find("li").removeClass("active")});$(".ShoppingMenu_child").find("li").click(function(){$(".ShoppingMenu_child").hide()});$(".ShoppingMenu_child").find("li").click(function(){$(".ShoppingMenu_child").hide();var n=$(this).find("a").attr("href");Loading("show");location.href=n});$(".PageBtnPanel li").click(function(){location.href=$(".PageLink").attr("url")+"&pi="+$(this).attr("value")});$(".ViewStyleBtn > .rankCondit").click(function(){if($(this).val()=="usersearch")return!1;location.href=$("#ViewStyleUrl").val()+"&vs="+$(this).attr("value")})});$(".ViewStyleBtn > .rankCondit").click(function(){location.href=$("#ViewStyleUrl").val()+"&vs="+$(this).attr("value")});Nowurl=location.href.toLowerCase();httpsHost="https://"+location.host;location.host==="localhost"&&(httpsHost="https://localhost:44300");BrowserProdKey="BrowserProd";BrowserConf={ShowBrowserLog:!0}