/*
* 脚本文件
*/
apw = {
    alert: function (m) {
        alert(m)
    },
    confirm: function (g) {
        var re = confirm(g);
        return re;
    },
    pop: function (m, defv) {
        if (undefined == defv) { defv = ""; }
        var inputvalue = prompt(m, defv);
        return inputvalue;
    },
    getCookie: function (c_name) {
        if (document.cookie.length > 0) {
            c_start = document.cookie.indexOf(c_name + "=")
            if (c_start != -1) {
                c_start = c_start + c_name.length + 1;
                c_end = document.cookie.indexOf(";", c_start);
                if (c_end == -1) {
                    c_end = document.cookie.length;
                }
                return unescape(document.cookie.substring(c_start, c_end));
            }
        }
        return null
    },
    setCookie: function (c_name, value, expiredays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
    },
    delCookie: function (c_name) { SetCookie(c_name, "", -1); },
    addFavorite: function () {/*加入收藏*/
        if (document.all)
            window.external.addFavorite(window.location.href, window.document.title);
        else if (window.sidebar)
            window.sidebar.addPanel(window.document.title, window.location.href, "");
    },
    homePage: function () {/*设置首页*/
        var pageURL = window.location.href;
        if (document.all) {
            document.body.style.behavior = 'url(#default#homepage)';
            document.body.setHomePage(pageURL);
        }
        else if (window.sidebar) {
            if (window.netscape) {
                try {
                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                }
                catch (e) {
                    alert("操作被浏览器拒绝，如果想启用功能，\r\n请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值为true");
                }
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', pageURL);
        }
    },
    gop: function (p) { window.location.href = p },
    getpara: function (pm) {/*获取请求地址参数*/
        var args = location.search;
        var reg = new RegExp('[\?&]?' + pm + '=([^&]*)[&$]?', 'gi');
        var chk = args.match(reg);
        var para = RegExp.$1
        return para;
    },
    trim: function (str) {
        return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, '');
    },
    getHost: function (url) {
        var host = "null";
        if (typeof url == "undefined" || null == url) {
            url = window.location.href;
        }
        var regex = /^\w+\:\/\/([^\/]*).*/;
        var match = url.match(regex);
        if (typeof match != "undefined" && null != match) {
            host = match[1];
        }
        return host;
    },
    shortcut: function () {
        var shotcut = "/api/shortcut.ashx";
        window.open(shotcut);
    },
    post: function (_url, _data, _defmsg) {
        var rmpost = new Date().getSeconds() + Math.random();
        if (_url.indexOf('?') != -1) {
            _url += "&pid=" + rmpost;
        } else {
            _url += "?pid=" + rmpost;
        }
        $.ajax({
            url: _url,
            data: _data,
            type: "POST",
            error: function () { apw.alert("服务器错误,请求未能提交."); },
            success: function (msg) {
                apw.alert("方法为完成,返回信息: " + msg);
            }
        });
    }
}

$(document).ready(function () {
    $(".bg_pcgame").mouseenter(function () { $("#game_classify_con").show(); }).mouseout(function () { $("#game_classify_con").hide(); });
    $("#game_classify_con").mouseover(function () { $(this).show(); }).mouseout(function () { $(this).hide(); });
    $("#g_user_account").focus(function () { if (this.value == '请输入用户名') { this.value = '' } }).blur(function () { if (this.value == '') { this.value = '请输入用户名' } })

    $("#g_user_onlogin").click(function () {
        var n = $("#g_user_account").val();
        var p = $("#g_user_password").val();
        var r = $("#remember-me").attr("checked") == "checked";
        $.ajax({
            url: "/api/sys/login.ashx?cid="+Math.random(),
            type: "POST",
            data: "uid=" + n + "&pwd=" + p + "&rem=" + r,
            success: function (msg) {
                if (msg + "" == "200") {
                    window.location.reload();
                } else {
                    alert(msg);
                }
            }
        });
    })

//    $.start2({
//        _showImg: "largeImages",
//        _imgIndex: "thumil_img",
//        _currentCss: { "border-color": "#0000ff" },
//        _disappear: [50, 0],
//        _currentClass: "btn_sum_now"
//    });
});
//幻灯扩展
jQuery.extend({ start2: function (settings) {
    var DEMO; var _count = 0; var config = $.extend({ _waitTime: 5000, _showImg: "", _disappear: [10, 0], _display: [500, 1], _imgIndex: "", _imgSrc: "img-src", _beforeCss: { "border-color": "#CCCCCC" }, _currentCss: { "border-color": "#00FF00" }, _currentClass: "", _showImgCss: { "width": "330px", "height": "230px" }, _title: "title" }, settings); var $showImg = $("#" + config._showImg); var $imgIndex = $("#" + config._imgIndex); var $title = $("#" + config._title); var slide = { over: function () {
        stopAutoToggle(); if (config._currentClass == "") { $imgIndex.children("li").css(config._beforeCss); $(this).css(config._currentCss); } else { $imgIndex.children("li").children("a").removeClass(); $(this).children("a").addClass(config._currentClass); }
        _count = $imgIndex.children("li").index($(this)); _count++; if (_count == $imgIndex.children("li").length) { _count = 0; }
        var img_src = $(this).children("a").attr(config._imgSrc); var title = $(this).children("a").attr(config._title); var _href = $(this).children("a").attr("href"); $showImg.stop(true, false).fadeTo(config._disappear[0], config._disappear[1], function () { $(this).attr({ src: img_src }).css(config._showImgCss).parent("a").attr({ "href": _href, "target": "_blank" }); }).fadeTo(config._display[0], config._display[1]); $title.html(title);
    }, out: function () { DEMO = setTimeout(autoQiehuan, config._waitTime); } 
    }
    function firstQiehuan() {
        var img = new Image(); img.onload = function () { autoQiehuan(); }
        img.src = $imgIndex.children("li").children("a:first").attr("img-src");
    }; function autoQiehuan() { $($imgIndex.children("li").get(_count)).trigger("mouseover"); DEMO = setTimeout(autoQiehuan, config._waitTime); }; function stopAutoToggle() { clearTimeout(DEMO); }
    $imgIndex.children("li").bind("mouseover", slide.over).bind("mouseout", slide.out).children("a").bind("click", function () { return false; }); firstQiehuan();
} 
});
 