﻿$.fn.tab = function(options) {
    options = options ? options : { type: 0 };
    var css_u, css_s;
    if (options.type == 0) { css_u = "box_2_un", css_s = "box_2_s_b"; }
    else { css_u = "box_2_un", css_s = "box_2_s"; }

    var o = this;
    var t = $("ul:eq(0)>li", o);
    jQuery.each(t, function(i, obj) {
        $(obj).mouseover(function() { $("ul:eq(0)>li:not(:eq(" + i + "))", o).removeClass(css_s).addClass(css_u); $(obj).removeClass(css_u).addClass(css_s); o.children(":gt(0):not(:eq(" + i + "))").hide(); o.children(":gt(0):eq(" + i + ")").show(); });
    });
};

function FlashBox() {
    var focus_width = 460;
    var focus_height = 150;
    var text_height = 20;
    var swf_height = focus_height + text_height;
    var temp = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"" + focus_width + "\" height=\"" + swf_height + "\">";
    temp += ('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="pic/pix.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">');
    temp += ('<param name="menu" value="false"><param name=wmode value="opaque">');
    temp += ('<param name="FlashVars" value="pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '">');
    temp += ('<embed src="pic/pix.swf" wmode="opaque" FlashVars="pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '" menu="false" bgcolor="#F0F0F0" quality="high" width="' + focus_width + '" height="' + swf_height + '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    temp += ('</object>');
    return temp;
}

function Init() {
    $.post("response.aspx?action=1", null, WebResponse, "json");
    try {
        var _cd = new Date(Date.parse(cd));
        _cd.setTime(_cd.getTime() + (ci * 60 * 60 * 1000));
        var _n = new Date();
        if (_n > _cd) {
            $.post("t.aspx", null, WebResponse, "json");
        }
    }
    catch (err) {
    }
}

function Login() {
    var username=$.trim($("#UserName").val());
    var password=$("#PassWord").val();
    if (username == "") { alert("请填写用户名！"); return false; }
    $.post("response.aspx?action=2", "username=" + username + "&password=" + password, WebResponse, "json");
    alert("小提示：如果要使用高级登录，点击《通行证》登录，这样可以保留您的登录信息！");
    return true;
}

$(function() {
    $("#b_flashgame").tab({ type: 1 });
    $("#b_ml").tab();
    $("#b_flash").html(FlashBox());
    Init();
});

function Zgjm() {
    var wd = $.trim($("#zgjm_wd").val());
    if (wd == "") { alert("请输入梦境内容！"); $("#zgjm_wd").focus(); return; }
    var url = "http://ml.showku.com/search-" + encodeURI(wd) + ".htm";
    window.location.href = url;
}

function WebResponse(obj) {
    if (obj.Status != 1) { alert(obj.Error); return; }
    switch (obj.Action) {
        case 1:
            {
                if (obj.UserID != -1)
                    $("#page_login").html("<div class=\"login_welcome\">欢迎您，" + obj.UserName + "  <a href=\"http://passport.showku.com/\">通行证</a> | <a href=\"http://passport.showku.com/logout.aspx\">退出</a></div>");
            }
            break;
        case 2:
            {
                alert("登录成功！");
                Init();
            }
            break;
    }
}

