﻿function addf(u, t) { try { if (window.sidebar) { window.sidebar.addPanel(t, u, ""); } else if (window.external) { window.external.AddFavorite(u, t); } else if (window.opera && window.print) { return true; } else { alert("Your browser can not support this operation, Please youse Ctrl+D to add manual."); } } catch (e) { alert("Your browser can not support this operation, Please youse Ctrl+D to add manual."); } }

function init_common() {
    document.body.insertBefore(dialogMask, document.body.childNodes[0]);
    document.body.insertBefore(dialogWarning, document.body.childNodes[0]);
    document.body.insertBefore(dialogWindow, document.body.childNodes[0]);
    document.body.insertBefore(dialogServerList, document.body.childNodes[0]);
    document.body.insertBefore(dialogSupportReply, document.body.childNodes[0]);
    document.body.insertBefore(dialogGift, document.body.childNodes[0]);
    document.body.insertBefore(dialogGameList, document.body.childNodes[0]);
    document.body.insertBefore(dialogCompensateGift, document.body.childNodes[0]);
    window.onresize = onResize;
    window.onscroll = onScroll;
}

var dialogCurrent = null;
var dialogMask = document.createElement("DIV");dialogMask.style.top="0px";dialogMask.style.left = "0px"; dialogMask.style.width = "0px"; dialogMask.style.height = "0px"; dialogMask.style.zIndex = "90"; dialogMask.style.position = "absolute"; dialogMask.style.backgroundColor = "#000000"; dialogMask.style.display = "none"; dialogMask.className = "alpha";
var dialogWarning = document.createElement("DIV");dialogWarning.style.cursor="pointer"; dialogWarning.style.backgroundColor = "#FFFF99"; dialogWarning.style.padding = "5px"; dialogWarning.style.borderStyle = "solid"; dialogWarning.style.borderWidth = "1px"; dialogWarning.style.borderColor = "#FF3333"; dialogWarning.style.color = "#FF3333"; dialogWarning.style.position = "absolute"; dialogWarning.style.zIndex = "9999"; dialogWarning.style.display = "none"; dialogWarning.onclick = function () { dialogWarning.style.display = "none"; };
var dialogWindow = document.createElement("DIV");dialogWindow.style.display="none";dialogWindow.style.position="absolute";dialogWindow.style.zIndex="99";dialogWindow.style.border="1px solid #ffbb00";dialogWindow.style.backgroundColor="#111111";dialogWindow.style.color="#dddddd";dialogWindow.innerHTML="<div id=\"window_title\" style=\"border-bottom:1px solid #ffbb00;background-color:#ffbb00;color:#000000;line-height:22px;\"></div><div id=\"window_content\" style=\"margin:10px;text-align:center;\"></div>";
var htmlLoading="<div><img src=\"/_images/loading.gif\" align=\"absmiddle\" />&nbsp;&nbsp;Please wait a moment...</div>";
var scripts=new Array();

function showWindow(code,data,title,w,h){dialogWindow.style.width=w+"px";dialogWindow.style.height=h+"px";$("window_title").innerHTML="<strong>&nbsp;:&nbsp;:&nbsp;"+title+"</strong>";$("window_content").innerHTML=this.htmlLoading;if(code==""){if(data!=""){$("window_content").innerHTML=data;}}else{sendCommand(code,data,"showWindowCB")};this.showDialog(this.dialogWindow,w,h);}
function showWindowCB(s){var ss=s.split(',');var sc=unescape(ss[0].toString().replace(/\+/g," "));var sh=unescape(ss[1].toString().replace(/\+/g," "));var se=unescape(ss[2].toString().replace(/\+/g," "));$("window_content").innerHTML=sh;if(sc!=""){var a=true;for(var i=0;i<this.scripts.length;i++){if(this.scripts[i].toString()==sc){a=false;}}if(a){var so=document.createElement("script");so.language="javascript";so.type="text/javascript";so.defer=true;so.text=sc;document.getElementsByTagName("HEAD").item(0).appendChild(so);this.scripts.push(sc);}}if(se!=""){var so=document.createElement("script");so.language="javascript";so.type="text/javascript";so.defer=true;so.text=se;document.getElementsByTagName("HEAD").item(0).appendChild(so);}}
function hideWindow(){this.hideDialog(this.dialogWindow);}
function showDialog(obj, w, h) { showMask(); obj.style.top = ((document.body.parentNode.clientHeight - h) / 2 + scrollTop()).toString() + "px"; obj.style.left = ((document.body.scrollWidth - w) / 2 + scrollLeft()).toString() + "px"; if (dialogCurrent != null) { dialogCurrent.style.display = "none"; dialogCurrent = null; } dialogCurrent = obj; dialogCurrent.style.display = "";onResize(); }
function hideDialog(obj){obj.style.display = "none"; dialogCurrent = null; hideMask(); }
function showMask(){dialogMask.style.width = scrollWidth().toString() + "px"; dialogMask.style.height = scrollHeight().toString() + "px"; dialogMask.style.display = ""; };
function hideMask(){dialogMask.style.display = "none"; }; 
function onResize(){if (dialogMask.style.display == "") { dialogMask.style.width = document.body.scrollWidth.toString() + "px"; dialogMask.style.height = (document.body.parentNode.scrollHeight).toString() + "px"; } if (dialogCurrent != null) { dialogCurrent.style.top = ((document.body.parentNode.clientHeight - dialogCurrent.offsetHeight) / 2 + scrollTop()).toString() + "px"; dialogCurrent.style.left = ((document.body.parentNode.scrollWidth - dialogCurrent.offsetWidth) / 2 + scrollLeft()).toString() + "px"; } }
function onScroll(){if (dialogCurrent != null) { dialogCurrent.style.top = ((document.body.parentNode.clientHeight - dialogCurrent.offsetHeight) / 2 + scrollTop()).toString() + "px"; dialogCurrent.style.left = ((document.body.parentNode.scrollWidth - dialogCurrent.offsetWidth) / 2 + scrollLeft()).toString() + "px"; } }

// form
function showWarning(obj,text){dialogWarning.style.top = (getTop(obj) + getHeight(obj) + 1).toString() + "px";dialogWarning.style.left = (getLeft(obj) + 1).toString() + "px";dialogWarning.innerHTML = text;dialogWarning.style.display = "";setTimeout("dialogWarning.style.display='none'", 5000);obj.focus();}
function check_form(obj){dialogWarning.style.display="none";var is=new Array("INPUT","TEXTAREA","SELECT");for(var j=0;j<is.length;j++){var inputs=obj.getElementsByTagName(is[j]);for(var i=0;i<inputs.length;i++){if(inputs[i].accept){if(inputs[i].value==inputs[i].alt||!check_input(inputs[i])){showWarning(inputs[i],inputs[i].alt);return false;}}}}return true;}
function check_input(obj){var code=obj.accept;var r=true;var cl=code.split("|");for(var i=0;(i<cl.length);i++){if(r){var codes=cl[i].split(",");switch(codes[0]){
case "Checked": r = obj.checked; break;
case "Email": r = check_form_Email(obj.value); break;
case "Equal": r = (obj.value == $(codes[1]).value); break;
case "Text": r = check_form_Text(obj.value, parseInt(codes[1]), parseInt(codes[2])); break;
case "Regex": r = check_form_Regex(obj.value, cl[i].substring(6)); break;
}}}return r;}
function check_form_Email(str) { return (str.match(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/ig) == str); }
function check_form_Text(str, min, max) { var c = 0; for (var i = 0; i < str.replace(/(^\s*)|(\s*$)/g, "").length; i++) { if (str.charCodeAt(i) > 255) { c += 2; } else { c++; } } if (min > 0 && c < min) { return false; } if (max > 0 && c > max) { return false; } return true; }
function check_form_Regex(str,pat){var re=new RegExp(pat);return re.test(str);}

function sendCommand(cmd, dat, evt) { var xhttp = getXmlhttp(); xhttp.open("post", "/_.aspx?" + cmd, true); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.setRequestHeader("Content-length", dat.length); xhttp.setRequestHeader("Connection", "close"); xhttp.send(dat);xhttp.onreadystatechange = function () { if (xhttp.readyState == 4 && xhttp.status == 200) { eval(evt + "('" + xhttp.responseText + "')"); } }  }
function sendForm(cmd, form, evt) { var dat = ""; var is = new Array("INPUT", "TEXTAREA", "SELECT"); for (var j = 0; j < is.length; j++) { var inputs = form.getElementsByTagName(is[j]); for (var i = 0; i < inputs.length; i++) { if (inputs[i].id && inputs[i].id != "") { dat += dat == "" ? "" : "&"; dat += inputs[i].id + "=" + escape(inputs[i].value); } } } sendCommand(cmd, dat, evt); }

function $(s) { return document.getElementById(s); }
function getXmlhttp() { var http_request; if (window.XMLHttpRequest) { http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType("text/xml"); } } else if (window.ActiveXObject) { try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } if (!http_request) { return null; } return http_request; }
function getLeft(obj) { var left = obj.offsetLeft; while (obj.offsetParent && obj.offsetParent.tagName != "BODY") { left += obj.offsetParent.offsetLeft; obj = obj.offsetParent } return left; }
function getTop(obj) { var top = obj.offsetTop; while (obj.offsetParent && obj.offsetParent.tagName != "BODY") { top += obj.offsetParent.offsetTop; obj = obj.offsetParent; } return top; }
function getWidth(obj) { return obj.offsetWidth; }
function getHeight(obj) { return obj.offsetHeight }
function scrollTop() { if (document.body.scrollTop) { return document.body.scrollTop; } else { return document.documentElement.scrollTop; } }
function scrollLeft() { if (document.body.scrollLeft) { return document.body.scrollLeft; } else { return document.documentElement.scrollLeft; } }
function scrollHeight() { if (document.body.scrollHeight) { return document.body.scrollHeight; } else { return document.documentElement.scrollHeight; } }
function scrollWidth() { if (document.body.scrollWidth) { return document.body.scrollWidth; } else { return document.documentElement.scrollWidth; } }
function padLeft(s, l, t) { var ss = s.toString(); while (ss.length < l) { ss = t + ss; } return ss; }
function roundUp(n, num) { var p = 0; if (n > 0) { var nums = num * 1.0; if (num == 2) { p = n * 100; } if (num == 3) { p = n * 1000; } p = Math.round(p); sp = "" + p; l = sp.length; return sp.substring(0, l - nums) + "." + sp.substring(l - nums, l); } else { return 0; } }
String.prototype.Trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
function checkFile(obj) {
    if (obj.value == "") { return true; }
    var s = obj.value.split('.');
    var result = (s[s.length - 1] == "jpg" || s[s.length - 1] == "JPG") ? true : false;
    return result;
}
function jsCopy(obj) {
    var testCode = obj.value;
    if (copy2Clipboard(testCode) != false) {
        
    }
}
function copy2Clipboard(txt) {
    if (window.clipboardData) {
        window.clipboardData.clearData();
        window.clipboardData.setData("Text", txt);
    }
    else if (navigator.userAgent.indexOf("Opera") != -1) {
        window.location = txt;
    }
    else if (window.netscape) {
        try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        }
        catch (e) {
            alert("The security restrictions of Firefox limit you to copy to clipboard.Please open 'about:config' and set the 'signed.applets.codebase_principal_support' to true.After that,please try again.");
            return false;
        }
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip) return;
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans) return;
        trans.addDataFlavor('text/unicode');
        var str = new Object();
        var len = new Object();
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        var copytext = txt; str.data = copytext;
        trans.setTransferData("text/unicode", str, copytext.length * 2);
        var clipid = Components.interfaces.nsIClipboard;
        if (!clip) return false;
        clip.setData(trans, null, clipid.kGlobalClipboard);
    }
}


var dialogServerList = document.createElement("DIV"); dialogServerList.className = "openDialog"; dialogServerList.style.width = "700px"; dialogServerList.style.height = "580px"; dialogServerList.style.display = "none"; dialogServerList.style.position = "absolute"; dialogServerList.style.display = "none"; dialogServerList.style.zIndex = "9999"; dialogServerList.innerHTML = "<div id=\"div_close\"></div><div class=\"title\">Select World</div><div id=\"world\" class=\"world\"></div>";
var dialogSupportReply = document.createElement("DIV"); dialogSupportReply.className = "openDialog"; dialogSupportReply.style.width = "700px"; dialogSupportReply.style.height = "550px"; dialogSupportReply.style.display = "none"; dialogSupportReply.style.position = "absolute"; dialogSupportReply.style.display = "none"; dialogSupportReply.style.zIndex = "9999"; dialogSupportReply.innerHTML = "<div class=\"title\">Reply</div><div id=\"div_reply\" class=\"support_create_content\" style=\"width:550px; margin:0 auto;\"><form id=\"reply_form\" enctype=\"multipart/form-data\" method=\"post\" action=\"/support.aspx?supportadd\"><div id=\"hide_values\"></div><div class=\"message\" style=\"width:580px;\"><div class=\"message_ft\">Message&nbsp;:&nbsp;&nbsp;</div><div class=\"message_gt\" style=\"width:500px\"><textarea id=\"content\" cols=\"15\" rows=\"3\" class=\"message_textarea_out\" style=\"width:450px;\" name=\"content\" onfocus=\"this.className='message_textarea_over'\" onblur=\"this.className='message_textarea_out'\"></textarea></div></div><p id=\"notify_content\" class=\"attachment_title\">It\'s must be in 500 words.</p><p class=\"attachment\">Attachment&nbsp;&nbsp;:&nbsp;&nbsp;<input type=\"file\" id=\"reply_attachment\" name=\"reply_attachment\" class=\"attacment_input\" onchange=\"$(\'attachment\').innerHTML = this.value\" /><span id=\"attachment\"></span></p><p class=\"attachment_title\">It\'s must be a jpg(that is with .jpg extension).The size is limited in 500k or less.</p><p class=\"p_submit\"><input type=\"button\" value=\"Submit\" class=\"submit\" onclick=\"if($(\'content\').value.Trim() == \'\') { showWarning($('content'),'The content cannot be blank.'); return;} if($('content').value.length > 500){  showWarning($('content'),'The subject should not be over 500 characters.'); return; } if(!checkFile($('reply_attachment'))){ showWarning($('reply_attachment'),'Please upload a JPG image.'); return;}  $('reply_form').submit();\" /><input type=\"button\" value=\"Close\" class=\"submit\" style=\"margin-left:10px;\" onclick=\"hideDialog(dialogSupportReply)\" /></p></form></div>";
var dialogGift = document.createElement("DIV"); dialogGift.className = "openDialog"; dialogGift.style.width = "400px"; dialogGift.style.height = "180px"; dialogGift.style.display = "none"; dialogGift.style.position = "absolute"; dialogGift.style.display = "none"; dialogGift.style.zIndex = "9999"; dialogGift.innerHTML = "<div class=\"title\">Gift Key</div><div style=\"width:350px;\"><input id=\"input_key\" class=\"input_txt_over\" style=\"width:350px\" type=\"text\" readonly=\"readonly\" /><br /><br /><input type=\"button\" value=\"Click here to copy\" class=\"submit\" style=\"width:130px;\" onclick=\"jsCopy($('input_key'))\" /><input type=\"button\" value=\"Back\" class=\"submit\" style=\"margin-left:10px;\" onclick=\"showServerListBack($('game').value)\" /><input type=\"button\" value=\"Close\" class=\"submit\" style=\"margin-left:10px;\" onclick=\"hideDialog(dialogGift)\" /></div>";
var dialogCompensateGift = document.createElement("DIV"); dialogCompensateGift.className = "openDialog"; dialogCompensateGift.style.width = "400px"; dialogCompensateGift.style.height = "180px"; dialogCompensateGift.style.display = "none"; dialogCompensateGift.style.position = "absolute"; dialogCompensateGift.style.display = "none"; dialogCompensateGift.style.zIndex = "9999"; dialogCompensateGift.innerHTML = "<div class=\"title\">Gift Key</div><div style=\"width:350px;\"><input id=\"input_compensate_key\" class=\"input_txt_over\" style=\"width:350px\" type=\"text\" readonly=\"readonly\" /><br /><br /><input type=\"button\" value=\"Click here to copy\" class=\"submit\" style=\"width:130px;\" onclick=\"jsCopy($('input_compensate_key'))\" /><input type=\"button\" value=\"Back\" class=\"submit\" style=\"margin-left:10px;\" onclick=\"hideDialog(dialogCompensateGift)\" /><input type=\"button\" value=\"Close\" class=\"submit\" style=\"margin-left:10px;\" onclick=\"hideDialog(dialogCompensateGift)\" /></div>";
var dialogGameList = document.createElement("DIV"); dialogGameList.className = "openDialog"; dialogGameList.style.width = "700px"; dialogGameList.style.height = "180px"; dialogGameList.style.display = "none"; dialogGameList.style.position = "absolute"; dialogGameList.style.display = "none"; dialogGameList.style.zIndex = "9999"; dialogGameList.innerHTML = "<div class=\"title\">Game List</div><div id=\"div_game\" class=\"div_game\"></div>";
