﻿function GG() { $("#WebLink").toggle(); };
function GH() { $("#WebLink").hide(); };

/*訊息Confirm*/
function jConfirm(str, callback) {
    var w = $(window).width();
    var h = $(window).height();
    $("body").append("<div id='mask' />");
    $("body").append("<div id='Msgbox'><p id='MsgTit'>提示問題</p></div>")
    $("#Msgbox").css("top", (h - $("this").height() - 100) / 2).css("left", (w - 300) / 2);
    $("#Msgbox").append("<p>" + str + "</p>");
    $("#Msgbox").append("<p><a id='jy'>是</a><a id='jn'>否</a></p>");
    $("#jy").live("click", function () { if (callback) callback(true); $("#Msgbox").remove(); $("#mask").remove(); });
    $("#jn").live("click", function () { if (callback) callback(false); $("#Msgbox").remove(); $("#mask").remove(); });
}

function RePw() {     /*密碼提示 &  style*/
    $("input[type='password']").each(function () {
        ($(this).is(":visible")) ? $(this).next("a").css("left", ($(this).position().left) + "px").css("top", ($(this).position().top) + "px").css("line-height", $(this).outerHeight() + "px").height($(this).outerHeight()).width($(this).outerWidth()).show() : "";
    });
    setTimeout("RePw()", 350);
};
function isTest() { /*Is測試*/
    (location.href.match(/localhost/)) ? true : false;
}

function isMobile() { /*Is手機*/
    var uA = navigator.userAgent;
    return (uA.match(/iPhone/) || uA.match(/Android/) || uA.match(/Windows Phone/)) ? true : ($(window).width() < 481) ? true : false;
}

function GoWin(url, title) {
    window.open(url, title, "height=600,width=800,top=0,left=0,toolbar=0,menubar=0,scrollbars=0,resizable=1,location=0,status=0");
};

$(function () {
    $(document).ready(function () {
        $(document).bind("contextmenu", function (event) { return false; }); /*右鍵鎖*/
        (top.location != location) ? top.location.replace("Default.aspx") : ""; /*禁內嵌*/
    });
    $("body").ready(function () {
        $('#WebLink').hide();
        /* FLASH選單效果*/
        var nn = '';
        switch (window.location.pathname.substr(1, 4)) {
            case 'Game': nn = 'menu01'; break;
            case 'Teac': nn = 'menu02'; break;
            case 'Serv': nn = 'menu03'; break;
            case 'Mem_': nn = 'menu04'; break;
            case 'TOP1': nn = 'menu05'; break;
            case 'Guil': nn = 'menu06'; break;
            case 'Down': nn = 'menu07'; break;
            case 'Good': nn = 'menu08'; break;
        };
        if ($("head").html().indexOf("swfobject.js") > 0) {
            swfobject.embedSWF("_swf/ad.swf", "flashADc", "570", "270", "9.0.0", "_swf/expressInstall.swf", {}, { wmode: "transparent" }, {}); /*首頁廣告*/
            swfobject.embedSWF("../_swf/top.swf", "flashheader", "975", "167", "9.0.0", "../_swf/expressInstall.swf", {}, { wmode: "transparent" }, {});
            swfobject.embedSWF("../_swf/menu.swf?page=" + nn, "flashmenu", "975", "88", "9.0.0", "../_swf/expressInstall.swf", {}, { wmode: "transparent" }, {});
        };
        /*以下為IE6 PNG圖檔透明修正*/
        //($.browser.msie && $.browser.version.substr(0, 1) < 7) ? $getScript("_js/DD_belatedPNG_0.0.8a-min.js.js", function () { DD_belatedPNG.fix('*'); }) : "";
    });
    $("body").click(function () {
        $('#WebLink').hide();
    });
    $("#WebLink a").click(function () {
        switch ($(this).attr("id")) {
            case "Fb": GoWin("http://fb2.xin-stars.com/FbQconnect.aspx", "星城FB立即玩"); break;
            case "Try": GoWin("http://www.xin-stars.com.tw", "星城WEB立即玩"); break;
            case "Msn": GoWin("http://Msn.xin-stars.com", "星城MSN立即玩"); break;
            case "Molo": GoWin("https://m2.molo.gs/login.html?Language=TW&Region=886&Category=login&ServiceName=1&ReturnURL=http://www.xin-stars.com.tw", "星城MOLO立即玩"); break;
            case "Bw":
                newWindow = window.open("about:blank", "星城BW立即玩", "height=300,width=430,top=0,left=0,toolbar=0,menubar=0,scrollbars=0,resizable=1,location=0,status=0");
                if (!newWindow) return false;
                var html = "<html><head></head><body><form id='formid' method='post' action='https://www.bonuswinner.com.tw/cc/bw_auth.php'>";
                html += "<input type='hidden' name='game' value='xinstars'/>";
                html += "<input type='hidden' name='url' value='http://www.xin-stars.com.tw'/>";
                html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</script></body></html>";
                newWindow.document.write(html);
                return newWindow;
                break;
        };
    });
    /*密碼提示 &  style*/
    $("input[type='text']").keydown(function (e) { if (e.which && e.which == 13) { return false }; });
    $("body").ready(function () {
        $("input[type='password']").each(function () {
            $(this).attr("onclick", "$(this).next('a').remove();$(this).removeAttr('onclick').removeAttr('onFocus');").attr("onFocus", "$(this).next('a').remove();$(this).removeAttr('onclick').removeAttr('onFocus');");
            $(this).after("<a onclick ='$(this).prev().click().focus(); $(this).remove();' style='position:absolute; text-align:left; vertical-align:middle; z-index:2; display:none; margin-left:8px;'>密碼4-12碼英數字</a>");
        });
        RePw();
    });
})

