// topmenu v1.000

// 链接
var link_acc = "http://acc.object.com.cn";
var link_login = "http://acc.object.com.cn/Login.aspx";
var link_logout = "http://acc.object.com.cn/Logout.aspx"
var link_reg = "http://acc.object.com.cn/Reg/Reg.aspx";
var link_index = "http://acc.object.com.cn/Index.aspx";
var link_vip = "http://card.object.com.cn/VIP/Index.aspx";
var link_pay = "http://card.object.com.cn";
var link_cs = "http://cs.object.com.cn";
var link_star = "http://acc.object.com.cn/StarServiceActivity/Login.aspx";

// email地址
var email_ceo = "zongcai@objectgames.com";

// 头部广告图片地址
var topAdUrl = "http://acc.object.com.cn/Images/topmenu/20120113.jpg";
// 头部广告链接
var topAdLink = "#";

// ajax调用地址
var url_state = "/HttpHandler/TopMenuChkLoginHandler.aspx";

// css中图片的跟路径
var css_imgpath = "http://acc.object.com.cn/";

// 获取头部样式
function getTopCss() {
    var css = "";
    css += "<style>";
    css += "body {padding:0;margin:0; height:45px; background-position:center 45px; font-size:12px;}";
    css += "ul,li{padding:0;margin:0; list-style:none;}";
    css += "a{text-decoration:none;}";
    css += "img{border:0;}";
    css += "#topWrap,.topLogo,.topShow,.fwtj,.tj2pk,.ntj_time,.ntj_free,.dto,.qssj,.tj2,.tiandi,.ds,.jxjz,.logo1,.logo2{ display:block;background:url(" + css_imgpath + "images/topbg.png);}";
    css += "#topWrap{width:100%; height:45px; margin:0 auto;background-repeat:repeat-x; position:relative; z-index:2147483647;}";
    css += "#topMain{width:100%; margin:0 auto; position:relative; min-width:1002px; _width:expression((documentElement.clientWidth < 1002) ? '1002px' : '100%' );}";
    css += "#topWrap .topLogo{width:160px; height:45px; background-position:0 -153px; position:absolute; left:0;}";
    css += "#topWrap .topLogo .username{color:#FF4900;}";
    css += "#topWrap .topLogo a{width:160px; height:45px; display:block;}";
    css += "#topWrap .topAd{width:235px; height:40px; position:absolute; left:170px; top:3px;}";
    css += "#topWrap .topLink{ right:95px;  padding-right:13px ;position:absolute; top:12px; height:21px; line-height:21px; word-wrap:normal; }";
    css += "#topWrap .topLink span{color:#c6cae7;padding:0 4px 0 3px;}";
    css += "#topWrap .topLink span.reg{color:#c6cae7;padding:0 0 0 4px;}";
    css += "#topWrap .topLink a{color:#000;}";
    css += "#topWrap .topLink a:hover{color:#ff6a33}";
    css += "#topWrap .topLink .exit{color:#0086ce; line-height:21.5px; padding-left:5px;}";
    css += "#topWrap .topLink .exit:hover{color:#004d7a; text-decoration:underline;}";
    css += "#topWrap .topLink div{ float:left; display:inline-block; line-height:21px; }";
    css += "#topWrap .topLink .loginId{ font-weight:bold; color:#ff4900;}";
    css += "#topWrap .topLink .mail{width:80px; background:url(images/mail.gif) 1px 0px no-repeat; text-align:right; padding-left:20px;}";
    css += "#topWrap .topShow{width:96px; height:21px; background-position:-160px -153px; position:absolute; right:10px; top:12px;}";
    css += "#topWrap .topShow .btn{width:78px; height:21px;cursor:pointer; line-height:23px; padding-left:18px; overflow:hidden;}";
    css += "#topWrap .topShow .box{width:292px; height:381px;  position:absolute; top:18px; right:0; overflow:hidden; z-index:2147483647; display:none;}";
    css += "#topWrap .topShow .head{width:292px; height:20px;background:url(" + css_imgpath + "images/show.gif) no-repeat; float:left;}";
    css += "#topWrap .topShow .content{width:267px; height:349px; border:1px solid #c8c8c8; border-top:none; padding-left:23px; float:left; background:#fff; }";
    css += "#topWrap .topShow .content li{width:69px; height:101px; display:inline-block; padding:0 15px 19px 0; margin:0; float:left;}";
    css += "#topWrap .topShow .content .linkbox{width:60px; height:42px; padding:5px 5px 0; float:left;}";
    css += "#topWrap .topShow .content a{width:30px; height:21px; line-height:21px; text-align:center; color:#205c7b; display:block; float:left;}";
    css += "#topWrap .topShow .content a:hover{color:#ff6a33;}";
    css += "#topWrap .topShow .content a:hover{color:#ff6a33;}";
    css += "#topWrap .topShow .content .fwtj{width:69px; height:54px;background-position:-207px -99px;}";
    css += "#topWrap .topShow .content .tj2pk{width:69px; height:54px;background-position:-207px -45px;}";
    css += "#topWrap .topShow .content .dto{width:69px; height:54px;background-position:-69px -99px;}";
    css += "#topWrap .topShow .content .ntj_time{width:69px; height:54px;background-position:-69px -45px;}";
    css += "#topWrap .topShow .content .ntj_free{width:69px; height:54px;background-position:0px -45px;}";
    css += "#topWrap .topShow .content .qssj{width:69px; height:54px;background-position:-138px -45px;}";
    css += "#topWrap .topShow .content .tiandi{width:69px; height:54px;background-position:0px -99px;}";
    css += "#topWrap .topShow .content .tj2{width:69px; height:54px;background-position:-138px -99px;}";
    css += "#topWrap .topShow .content .ds{width:69px; height:54px;background-position:0px -223px;}";
    css += "#topWrap .topShow .content .jxjz{width:69px; height:54px;background-position:-69px -223px;}";
    css += "</style>";
    return css;
}

// 获取头部html代码
function getTopHtml() {
    var html = "";
    html += "<div id='topWrap'>";
    html += "<div id='topMain'>";
    html += "<div class='topLogo'><a href='http://www.object.com.cn/' target='_blank'></a></div>";
    html += "<div class='topAd'><a href='" + topAdLink + "' target='_blank'><img src='" + topAdUrl + "' style='' /></a></div>";
    html += "<div class='topLink'>";
    html += "<div class='topLogin' style='display:none'><a href='" + link_login + "'>登录</a><span class='reg'>|</span> <a href='" + link_reg + "'>注册</a></div>";
    html += "<div class='topLoginIn'>欢迎您：<span class='loginId'> </span><a class='exit' href='" + link_logout + "'>退出</a></div>";
    html += "<div><span>|</span><a href='" + link_acc + "' target='_blank'>通行证</a><span>|</span><a href='" + link_pay + "' target='_blank'>充值</a><span>|</span><a href='" + link_cs + "' target='_blank'>客服</a><span>|</span><a href='" + link_vip + "' target='_blank'>vip专区</a><span>|</span><a href='" + link_star + "' target='_blank'>星级服务</a><span>|</span><a href='mailto:" + email_ceo + "' class='mail'>总裁信箱</a></div></div>";
    html += "<div class='topShow'>";
    html += "<div class='btn'>目标游戏</div> ";
    html += "<div class='box'>";
    html += "<div class='head'></div>";
    html += "<div class='content'>";
    html += "<ul>";
    html += "<li><a href='http://ds.object.com.cn' class='ds' target='_blank'></a><div class='linkbox'><a href='http://card.object.com.cn/payds.asp' target='_blank'>充值</a><a href='http://ds.object.com.cn/ActiveLibary/Index.aspx' target='_blank'>活动</a><a href='http://ds.object.com.cn' target='_blank'>官网</a><a href='http://dsbbs.object.com.cn' target='_blank'>论坛</a></div></li>";
    html += "<li><a href='http://jz.object.com.cn/' class='jxjz' target='_blank'></a><div class='linkbox'><a href='#' title='暂未开放'>充值</a><a href='#' title='暂未开放'>活动</a><a href='http://jz.object.com.cn/' target='_blank'>官网</a><a href='http://jzbbs.object.com.cn' target='_blank'>论坛</a></div></li>";
    html += "<li><a href='http://fw.object.com.cn/' class='fwtj' target='_blank'></a><div class='linkbox'><a href='http://card.object.com.cn/PayOnline.aspx?gametype=1005' target='_blank'>充值</a><a href='http://fw.object.com.cn/event.aspx' target='_blank''>活动</a><a href='http://fw.object.com.cn/' target='_blank'>官网</a><a href='http://bbs.object.com.cn/index.php?gid=35' target='_blank'>论坛</a></div></li>";
    html += "<li><a href='http://tjpk.object.com.cn/' class='tj2pk' target='_blank'></a><div class='linkbox'><a href='http://card.object.com.cn/PayOnline.aspx?gametype=1006' target='_blank'>充值</a><a href='http://tjpk.object.com.cn/event/' target='_blank'>活动</a><a href='http://tjpk.object.com.cn/' target='_blank'>官网</a><a href='http://bbs.object.com.cn/index.php?gid=38' target='_blank'>论坛</a></div></li>";
    html += "<li><a href='http://dto.object.com.cn/' class='dto' target='_blank'></a><div class='linkbox'><a href='http://card.object.com.cn/PayOnline.aspx?gametype=1002' target='_blank'>充值</a><a href='http://dto.object.com.cn/event/default.aspx?SortID=6' target='_blank'>活动</a><a href='http://dto.object.com.cn/' target='_blank'>官网</a><a href='http://bbs.object.com.cn/index.php?gid=3' target='_blank'>论坛</a></div></li>";
    html += "<li><a href='http://www.tjnet.com.cn/' class='ntj_time' target='_blank'></a><div class='linkbox'><a href='http://card.object.com.cn/PayOnline.aspx?gametype=1001' target='_blank'>充值</a><a href='http://www.tjnet.com.cn/News/default.aspx?SortID=3' target='_blank'>活动</a><a href='http://www.tjnet.com.cn/' target='_blank'>官网</a><a href='http://bbs.object.com.cn/index.php?gid=84' target='_blank'>论坛</a></div></li>";
    html += "<li><a href='http://qssj.object.com.cn/Default.aspx' class='qssj' target='_blank'></a><div class='linkbox'><a href='http://card.object.com.cn/PayOnline.aspx?gametype=1011' target='_blank'>充值</a><a href='http://qssj.object.com.cn/news/Index.aspx?type=2' target='_blank'>活动</a><a href='http://qssj.object.com.cn/Default.aspx' target='_blank'>官网</a><a href='http://bbs.object.com.cn/index.php?gid=24' target='_blank'>论坛</a></div></li>";
    html += "<li><a href='http://tiandi.object.com.cn/' class='tiandi' target='_blank'></a><div class='linkbox'><a href='http://card.object.com.cn/PayOnline.aspx?gametype=1010' target='_blank'>充值</a><a href='http://tiandi.object.com.cn/event.aspx' target='_blank'>活动</a><a href='http://tiandi.object.com.cn/' target='_blank'>官网</a><a href='http://bbs.object.com.cn/index.php?gid=37' target='_blank'>论坛</a></div></li>";
    html += "<li><a href='http://www.tj2.com.cn/Default.aspx' class='tj2' target='_blank'></a><div class='linkbox'><a href='http://card.object.com.cn/PayOnline.aspx?gametype=1004' target='_blank'>充值</a><a href='http://woq2.object.com.cn/event/' target='_blank'>活动</a><a href='http://www.tj2.com.cn/Default.aspx' target='_blank'>官网</a><a href='http://bbs.object.com.cn/index.php?gid=1' target='_blank'>论坛</a></div></li>";
    html += "</ul>";
    html += "</div>";
    html += "</div>";
    html += "</div>";
    html += "</div></div>";
    return html;
}

// 获取底部
function getFooter() {
    var foothtml = "";
    foothtml += "<style>";
    foothtml += "#footWrap{width:100%; height:90px; background:#fff url(" + css_imgpath + "images/footWrapbg.jpg) 0 top repeat-x; float:left; margin-top:10px; overflow: hidden;}";
    foothtml += "#footMain{width:1002px; margin:0 auto; padding-top:15px; position:relative;}";
    foothtml += "#footMain .footLogo{width:220px; height:25px; float:left; padding-left:250px;}";
    foothtml += "#footMain .footLogo .logo1,#footMain .footLogo .logo2{width:100px; height:25px; display:block; float:left; background-position:0 -198px;}";
    foothtml += "#footMain .footLogo .logo2{background-position:-100px -198px; margin-left:10px;}";
    foothtml += "#footMain .footLink{width:360px; height:25px; line-height:25px; float:left;}";
    foothtml += "#footMain .footLink span{padding:0 5px;}";
    foothtml += "#footMain .footLink a{color:#303030;}";
    foothtml += "#footMain .footLink a:hover{color:#888888; text-decoration:underline;}";
    foothtml += "#footMain .footLink span{padding:0 5px;}";
    foothtml += "#footMain .copyRight{width:1002px; height:25px; text-align:center; float:left; color:#303030; *padding-top:10px;}";
    foothtml += "</style>";
    foothtml += "<div id='footWrap'>";
    foothtml += "<div id='footMain'>";
    foothtml += "<div class='footLogo'><a class='logo1' href='http://www.object.com.cn' target='_blank'></a><a class='logo2' href='http://www.object.com.cn' target='_blank'></a></div>";
    foothtml += "<div class='footLink'><a href='http://www.object.com.cn/' target='_blank'>目标官网</a><span>|</span> <a href='http://www.object.com.cn/AboutUs.aspx' target='_blank'>公司介绍</a><span>|</span><a href='http://cs.object.com.cn' target='_blank'>客服中心</a><span>|</span><a href='http://www.object.com.cn/HR.aspx' target='_blank'>招聘信息</a><span>|</span><a href='http://www.object.com.cn/ContactUs.aspx' target='_blank'>联系我们</a></div>";
    foothtml += "<div class='copyRight'><p>版权所有  北京目标在线科技有限公司《网络文化经营许可证》编号：京网文[2011]0416-141号  京ICP证：060688   京ICP备11041698号 北京公安局海淀分局编号：1101081886</p></div>";
    foothtml += "</div>";
    foothtml += "</div>";
    return foothtml;
}

// onload
$(function() {
    // 清除图片缓存
    if ($.browser.version == 6) {
        document.execCommand("BackgroundImageCache", false, true);
    }

    if ($.browser.version == 8) {
        $("head").append("<meta http-equiv='X-UA-Compatible' content='IE=EmulateIE7' />");
    }

    // 生成html
    var top = getTopCss() + getTopHtml();
    var footer = getFooter();
    $("body").prepend(top);
    $("body").append(footer);

    // 获取用户登录状态
    $.get(url_state, { r: Math.random() }, function(data) {
        var login = false;
        var info = data.split("|");
        if (info.length == 3 && info[0] == "1") {
            login = true;
        }

        if (login) {
            var accType = info[2];
            var accRemark = "";
            if (accType == "3") {
                accRemark = "<span style='color:#000;font-weight:normal;'>  (天骄2用户)</span>";
            }
            else if (accType == "2") {
                accRemark = "<span style='color:#000;font-weight:normal;'>  (暇月战歌用户)</span>";
            }
            $(".loginId").html(info[1] + accRemark);
            $(".topLoginIn").css("display", "");
            $(".topLogin").css("display", "none");
        }
        else {
            $(".loginId").text("");
            $(".topLoginIn").css("display", "none");
            $(".topLogin").css("display", "");
        }
    });

    // 目标游戏浮动层
    $(".topShow .btn").hover(
        function() {
            $(".topShow .box").show();
        },
        function() {
            $(".topShow .box").hide();
        }
    );
    $(".topShow .box").hover(
        function() {
            $(this).show();
        },
        function() {
            $(this).hide();
        }
    );
});


