var DI={a:[],l:[],n:[]};var UID=0;var ls=[];var loginOnly=false;var preLoginAction="";var preLoginFunction;var preLoginForce=false;var mail_account="service@iplaycc.com";var hint_service='<br><br><a href="#ccAlert" onclick="$(this).next().toggle();return false;">一直收不到信?</a><div class=hide style="border:2px dashed #BBB;padding:5px">請用您註冊時使用的email寄信到'+mail_account+"，會有客服人員為您處理。</div>";var img_load=' <img src="img/load.gif" style="position:relative;top:2px">';var img_success=' <span class="ic ic_c">&nbsp;</span>';var img_failed=' <span class="ic ic_e">&nbsp;</span>';var hint_blank="不可以空白喔！";var m_intro='<td style="width:220px;line-height:180%" valign=top>會員專屬功能<div style="margin:5px 0 0 10px">'+img_success+"收藏遊戲<br>"+img_success+"共同編輯遊戲簡介<br>"+img_success+"自動遊戲紀錄<br>"+img_success+"遊戲紀錄統計<br>"+img_success+"更多功能陸續新增中...</div>";function isBlank(a){if($.trim(a)==""){return true}return false}(function(a){a.extend(a.fn,{cover:function(b,d){switch(b){case"load":d="資料讀取中"+img_load;break;case"process":d="資料處理中"+img_load;break;case"success":d=img_success+'<span style="color:red">送出成功！</span>';this.uncover("lag");break;case"failed":d=img_failed+'<span style="color:red">'+d+"<br>送出失敗，請再試看看</span>";this.uncover("lag",2000);break;case"custom":break}var c=this.parent();if(!c.is(':has("#loading")')){c.css("position","relative").css("textAlign","left");c.prepend('<div id=loading style="background-color:#EEE;position:absolute;z-index:1"><table style="width:'+this.outerWidth()+"px;height:"+this.outerHeight()+'px"><tr><td></table></div>')}c.find("#loading td").html(d).css("textAlign","center");c.find("#loading").css("opacity",0).fadeTo("normal",0.8)},uncover:function(d,b){var c=a(this).parent();if(d=="lag"){if(b==null){b=1000}setTimeout(function(){c.find("#loading").remove()},b)}else{c.find("#loading").remove()}},showHint:function(d,b){var c=a(this);if(!c.next().hasClass("rel")){c.after("<div class=rel><div class=hint><div></div></div></div>")}c.next().find(".hint>div").html(d);c.next().find(".hint").show();if(b!=null){setTimeout(function(){a(c).hideHint()},b)}c.focus();return c},hideHint:function(){this.next().find(".hint").hide();return this},ccDialog:function(c,b){DI[b].push(this);this.dialog(c)},ccLoadUserMenu:function(){var b=a(this);if(UID){b.html("<b>"+a.cookie("nick")+'</b> | <a href="m/" target=_self>會員區</a> | <a id=l_logout href="#l_logout">登出</a>');b.find("#l_logout").click(function(){ccAlert("登出中...請稍候"+img_load);a.post("API","f=logout",function(){updateUID(0);ccAlert("已登出<br>記得常回來愛玩嘻嘻玩喔！");b.ccLoadUserMenu();if(loginOnly){window.location="/login"}});return false})}else{b.html('<a id=l_register href="#l_register">註冊</a> | <a id=l_login href="#l_login">登入</a>');b.find("#l_register").click(function(){showRL("register","註冊");return false});b.find("#l_login").click(function(){showRL("login","登入");return false})}},ccHrefVar:function(){var b=a(this).attr("href").split("#");return b[b.length-1]},ccAutoCompleteEmail:function(){a(this).autocomplete({source:function(e,d){var l=e.term.indexOf("@");if(l>0&&l<e.term.length-1){var b=["gmail.com","hotmail.com","hotmail.com.tw","kimo.com","livemail.tw","live.com","msn.com","msa.hinet.net","pchome.com.tw","seed.net.tw","so-net.net.tw","sinamail.com","xuite.net","yahoo.com.tw","yahoo.com","ymail.com","yam.com"];l=e.term.split("@");var h=l[0];var c=l[1];if(h.length>0&&c.length>0){var k=new Array();var j="^"+c.substr(0,1)+".*";var g=new RegExp(j,"i");for(var f in b){if(g.test(b[f])){k.push(h+"@"+b[f])}}return d(k)}}d([])}})}})})(jQuery);function updateUID(a){UID=a;if(UID==0){$.each(DI.l,function(){this.dialog("close")})}else{$.each(DI.n,function(){this.dialog("close")})}}function showRL(a,b){if($("#rlDiv").length==0){$("body").append("<div><div id=rlDiv><table><tr>"+m_intro+'<td valign=top><div id=rlTab><ul><li><a href="#registerDiv">註冊</a><li><a href="#loginDiv">登入</a></ul><div id=registerDiv><form><table><tr><td>email<td>：<input type=text name=email ac=email><tr><td>暱　　稱<td>：<input type=text name=nick><tr><td>密　　碼<td>：<input type=password name=PW><tr><td>確認密碼<td>：<input type=password name=PW2><tr><td colspan=2><input type=checkbox id=agree name=agree checked><label for=agree>我已閱讀且同意</label><a href="policy" target=_blank><u>使用條款和隱私權政策</u></a></table><div style="text-align:right"><button type="submit">註冊</button></div></form></div><div id=loginDiv><form><table><tr><td>email<td>：<input id=ttt type=text name=email ac=email><tr><td>密　　碼<td>：<input type=password name=PW></table><div style="text-align:right"><a href="#resetPW" onclick="showResetPW();return false;">忘記密碼?</a> <button class="ui-state-default ui-corner-all submitBtn" type="submit">登入</button></div></form></div></div><input type=hidden name=onDiv value="registerDiv"></table></div></div>');$("#rlTab").tabs().removeClass().addClass("ui-tabs");$("#rlTab ul").removeClass("ui-widget-header").css("borderBottom","1px solid #3399ff");$("#rlTab div").css("padding","5px 0");$("#rlTab li a").click(function(){$("#rlDiv [name=onDiv]").val($(this).ccHrefVar());$($(this).attr("href")).find("input").eq(0).focus()});$("#rlDiv form").submit(function(){checkRLForm();return false});$("#rlDiv").ccDialog({width:520,bgiframe:true,resizable:false,title:b},"n")}$("#ui-dialog-title-rlDiv").html(b);$("#rlTab a[href=#"+a+"Div]").click();$("#rlDiv").dialog("open")}function checkRLForm(){$("#rlDiv").uncover();var a=$("#rlDiv [name=onDiv]").val();var c=$("#"+a+" form");if(isBlank(c.find("[name=email]").val())){c.find("[name=email]").showHint(hint_blank);c.one("click",function(){$(this).hideHint()});return false}if(c.find("[name=PW]").val().length<4){c.find("[name=PW]").showHint("密碼至少要4個字元以上");c.one("click",function(){$(this).hideHint()});return false}if(a=="registerDiv"){if(c.find("[name=PW]").val()!=c.find("[name=PW2]").val()){c.find("[name=PW2]").showHint("兩次輸入密碼不同喔！");c.one("click",function(){$(this).hideHint()});return false}if(isBlank(c.find("[name=nick]").val())){c.find("[name=nick]").showHint(hint_blank);c.one("click",function(){$(this).hideHint()});return false}if(c.find("[name=nick]").val().length>20){c.find("[name=nick]").showHint("暱稱請在20個字內");c.one("click",function(){$(this).hideHint()});return false}if(c.find("[name=agree]:checked").length==0){c.find("[name=agree]").next().showHint("要同意才能註冊喔！");c.one("click",function(){$(this).hideHint()});return false}}c.cover("process");var b=a.substr(0,a.length-3);$.post("API","f="+b+"&"+c.serialize(),function(d){if(d.status=="SUCCESS"){c.cover("success");updateUID(d.data.UID);$("#userMenu").ccLoadUserMenu();showHelloDiv(b,d.data)}else{c.cover("failed",d.data)}},"json")}function showHelloDiv(a,b){if(preLoginAction!=""&&preLoginForce){preLoginFunction.call();return}if(a=="register"){var c="註冊成功！";var d="恭喜您成為愛玩嘻嘻的會員！"}else{var c="登入成功！";var d="歡迎回來愛玩嘻嘻！"}if($("#helloDiv").length==0){$("body").append("<div id=helloDiv></div>");$("#helloDiv").ccDialog({width:420,autoOpen:false,bgiframe:true,resizable:false,title:c},"l")}$("#helloDiv").html('<div id=helloWording></div><div id=helloMenu style="text-align:center"></div><div id=helloAlert></div>');$("#ui-dialog-title-helloDiv").html(c);$("#helloWording").html("Hi! <b>"+b.nick+"</b><br>"+d+" 您想要先做什麼呢？");if(preLoginAction==""){$("#helloMenu").append("<button onclick=\"$('#helloDiv').dialog('close');\">繼續<br>瀏覽此頁</button>")}else{$("#helloMenu").append("<button onclick=\"preLoginFunction.call();$('#helloDiv').dialog('close');\">"+preLoginAction+"</button>")}$("#helloMenu").append("<button onclick=\"window.location='m/'\">會員區<br>首頁</button><button>愛玩嘻嘻<br>首頁</button>");if(!b.verified){$("#helloMenu").append('<button onclick="showVerifyEmail();">認證<br>Email</button>');$("#helloAlert").html("<em>*</em>因您尚未認證email，若超過七天未登入，系統將會自動刪除您的帳號。認證email後帳號將可永久保留。")}$("#helloMenu button").css("width","88px").css("height","88px").css("margin","8px 3px");$("#helloDiv").dialog("open").dialog("moveToTop")}function showResetPW(){if($("#resetPW").length==0){$("body").append('<div id=resetPW><form><div>請填寫您註冊時使用的email，系統會將新密碼寄給您：</div><input style="width:250px" type=text name=email></form></div>');$("#resetPW form").submit(function(){var a=$(this);a.cover("custom","重設密碼信傳送中"+img_load+"<br>本項操作較為耗時，請耐心等候，謝謝");$.post("API","f=resetPW&"+a.serialize(),function(b){if(b.status=="SUCCESS"){a.cover("success");ccAlert("重設密碼信已寄出，若您在五分鐘內沒有收到信，請檢查您的垃圾信件夾或重試一次。"+hint_service,"成功寄出！");$("#resetPW").dialog("close")}else{a.cover("failed",b.data)}},"json");return false});$("#resetPW").ccDialog({autoOpen:false,bgiframe:true,resizable:false,title:"重設密碼",buttons:{"送出":function(){$("#resetPW form").submit()}},close:function(){$("#resetPW form").uncover()}},"n")}$("#resetPW").dialog("open").dialog("moveToTop").find("input:first").focus()}function showVerifyEmail(){if($("#verifyEmail").length==0){$("body").append("<div id=verifyEmail></div>");$("#verifyEmail").ccDialog({autoOpen:false,bgiframe:true,resizable:false,title:"認證Email"},"a")}$("#verifyEmail").html("請稍候，資料讀取中"+img_load).dialog("open").dialog("moveToTop");$.post("API","f=getVeriInfo",function(a){var b="您用來註冊的email是"+a.data.email+"<br>";if(a.data.lasttime!=null){b+="上次認證信在"+displayTime(a.data.lasttime)+"寄出<br>若您沒有收到，請先檢查您的垃圾信件夾，或"}b+='<button class="ui-state-default ui-corner-all" type=button onclick="resendVeri();return false;">按此重新索取認證信</button>'+hint_service;$("#verifyEmail").html(b).find("div").uncover()},"json")}function resendVeri(){if(!UID){showRL("login","請先登入才能索取認證信");return}$("#verifyEmail").dialog("close");ccAlert("認證信寄送中"+img_load+"<br>此項操作較為耗時，請耐心等候，謝謝","重寄認證信");$.post("API","f=verifyLetter",function(a){if(a.status=="SUCCESS"){ccAlert("認證信已寄出，若您在五分鐘內沒有收到信，請檢查您的垃圾信件夾或重試一次。"+hint_service,"重寄認證信")}else{ccAlert("要求失敗，請稍後重試一次，或來信"+mail_account+"，由客服人員為您處理。","重寄認證信")}},"json")}function ccAlert(b,a){if(isBlank(a)){a="提示訊息"}if($("#alert").length==0){$("body").append("<div id=alert></div>");$("#alert").ccDialog({width:350,autoOpen:false,bgiframe:true,resizable:false,title:a},"a")}$("#ui-dialog-title-alert").html(a);if(b.length<20){$("#alert").css("textAlign","center")}else{$("#alert").css("textAlign","left")}$("#alert").html(b).dialog("open").dialog("moveToTop")}jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m=$.extend({},m);m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h<k.length;h++){var c=jQuery.trim(k[h]);if(c.substring(0,b.length+1)==(b+"=")){d=decodeURIComponent(c.substring(b.length+1));break}}}return d}};function ajaxRand(){var a=new Date();return"&t="+a.getTime()}function zerofill(b,a){b=b+"";while(b.length<a){b="0"+b}return b}function displayTime(a){var a=new Date(a*1000);return a.getFullYear()+"-"+zerofill(a.getMonth()+1,2)+"-"+zerofill(a.getDate(),2)+" "+zerofill(a.getHours(),2)+":"+zerofill(a.getMinutes(),2)}function displayDate(a){var a=new Date(a*1000);return a.getFullYear()+"-"+zerofill(a.getMonth()+1,2)+"-"+zerofill(a.getDate(),2)}function number_format(a){if(a==undefined){return""}if(a.length<=3){return a}var b=a.length%3;return a.substr(0,b)+","+a.substr(b).replace(/(\d{3})(?=\d)/g,"$1,")}function htmlspecialchars_decode(a){a=a.toString();a=a.replace(/&lt;/g,"<");a=a.replace(/&gt;/g,">");a=a.replace(/&quot;/g,'"');a=a.replace(/&amp;/g,"&");return a}$("input[ac=email]").live("focus",function(){$(this).ccAutoCompleteEmail()});