var ad1 = [
        { href: "#1", img: "/theme/pay/res/index_game.png", title: "XXX", info: "SSS" },
        { href: "#2", img: "/theme/pay/res/index_game.png", title: "22", info: "3223" },
        { href: "#3", img: "/theme/pay/res/index_game.png", title: "333", info: "3434" },
        { href: "#4", img: "/theme/pay/res/index_game.png", title: "444", info: "544545" }
]
var ad2 = [
        { href: "#1", img: "/theme/pay/res/index_183912988.jpg", title: "1111", alt: "11111" },
        { href: "#2", img: "/theme/pay/res/index_183912988.jpg", title: "22", alt: "3223" },
        { href: "#3", img: "/theme/pay/res/index_183912988.jpg", title: "333", alt: "3434" },
        { href: "#4", img: "/theme/pay/res/index_183912988.jpg", title: "444", alt: "544545" }
]
/*** 对联广告设置 ****************/
var _isshow = false;
var _top = 130;
var _w = 170;
var _h = 303;
var l_href = "#l"; //左侧链接
var r_href = "#r"; //右侧链接
var _boder = "border:1px solid #eee";
var _bgclolr = "#fff;";

var l_flash = "/upload/flash/2eba588bf.swf";
var r_flash = "/upload/flash/2eba588bf.swf";


var l_html = '<object onclick="zuo()" width="' + _w + '" height="' + _h + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" >' +
            '<param name="movie" value="' + l_flash + '" />' +
            '<param name="wmode" value="transparent">' +
            '<param name="quality" value="high" />' +
            '<embed width="' + _w + '" height="' + _h + '" src="' + l_flash + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"  wmode="transparent"></embed></object>';

var r_html = '<object width="' + _w + '" height="' + _h + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" >' +
            '<param name="movie" value="' + r_flash + '" />' +
            '<param name="wmode" value="transparent">' +
            '<param name="quality" value="high" />' +
            '<embed width="' + _w + '" height="' + _h + '" src="' + r_flash + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"  wmode="transparent"></embed></object>';
/*** 对联广告设置 *** 结束 ******/

/*** 右下角弹出框 ***************/
var bottom_player = {
    isshow: false,
    title: "充值提醒",
    html: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"><param name="movie" value="/upload/flash/2eba588bf.swf"><param name="wmode" value="transparent"><param name="quality" value="high"><embed src="/upload/flash/2eba588bf.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" ></object>',
    href: "#111111111"
}
/*** 右下角弹出框 *** 结束 ******/

/*******************************************/
function miaovAddEvent(oEle, sEventName, fnHandler) {
    if (oEle.attachEvent) {
        oEle.attachEvent('on' + sEventName, fnHandler);
    }
    else {
        oEle.addEventListener(sEventName, fnHandler, false);
    }
}


function startMove(obj, iTarget, fnCallBackEnd) {
    if (obj.timer) {
        clearInterval(obj.timer);
    }
    obj.timer = setInterval
	(
		function () {
		    doMove(obj, iTarget, fnCallBackEnd);
		}, 30
	);
}

function doMove(obj, iTarget, fnCallBackEnd) {
    var iSpeed = (iTarget - obj.offsetHeight) / 8;

    if (obj.offsetHeight == iTarget) {
        clearInterval(obj.timer);
        obj.timer = null;
        if (fnCallBackEnd) {
            fnCallBackEnd();
        }
    }
    else {
        iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
        obj.style.height = obj.offsetHeight + iSpeed + 'px';

        ((window.navigator.userAgent.match(/MSIE 6/ig) && window.navigator.userAgent.match(/MSIE 6/ig).length == 2) ? repositionAbsolute : repositionFixed)()
    }
}

function repositionAbsolute() {
    var oDiv = document.getElementById('miaov_float_layer');
    var left = document.body.scrollLeft || document.documentElement.scrollLeft;
    var top = document.body.scrollTop || document.documentElement.scrollTop;
    var width = document.documentElement.clientWidth;
    var height = document.documentElement.clientHeight;

    oDiv.style.left = left + width - oDiv.offsetWidth - 4 + 'px';
    oDiv.style.top = top + height - oDiv.offsetHeight - 4 + 'px';
}

function repositionFixed() {
    var oDiv = document.getElementById('miaov_float_layer');
    var width = document.documentElement.clientWidth;
    var height = document.documentElement.clientHeight;

    oDiv.style.left = width - oDiv.offsetWidth - 4 + 'px';
    oDiv.style.top = height - oDiv.offsetHeight - 4 + 'px';
    $("#ad_tottom_btn_href").height(oDiv.offsetHeight - 30 - 4);
}
/*********************************/
$(document).ready(function () {
    var ad1_html = "";
    for (var i = 0; i < ad1.length; i++) {
        ad1_html += '<li style="height:39px;overflow:hidden;">' +
                    '<a href="' + ad1[i].href + '" target="_blank" >' +
                    '<img src="' + ad1[i].img + '" alt="" height="32" width="32">' +
                    '<h3>' + ad1[i].title + '</h3>' +
                    '<span>' + ad1[i].info + '</span>' +
                    '</a></li>';
    }
    $("#pay_ad_ad1").html(ad1_html);


    var ad2_html = "";
    for (var i = 0; i < ad2.length; i++) { ad2_html += '<li><a href="' + ad2[i].href + '" target="_blank" title="' + ad2[i].title + '" ><img src="' + ad2[i].img + '" alt="' + ad2[i].alt + '" height="80" width="175"></a></li>'; }
    $("#pay_ad_ad2").html(ad2_html);


    if (bottom_player.isshow) {


        var div_html_ad = document.createElement("div");
        div_html_ad.setAttribute("class", "float_layer");
        div_html_ad.setAttribute("id", "miaov_float_layer");

        var btm_html = '<h2>' +
                    '<strong>' + bottom_player.title + '</strong>' +
                    '<a id="ad_tottom_btn_close" href="javascript:void(0);"  class="close"></a></h2>' +
                    '<div class="content"><div class="wrap">' + bottom_player.html +
                    '</div></div><div id="ad_tottom_btn_href"><a href=' + bottom_player.href + ' target="_blank"></a></div>';
        document.body.appendChild(div_html_ad)
        $("#miaov_float_layer").html(btm_html);
        $("#ad_tottom_btn_close").click(function () {
            $("#miaov_float_layer").remove();
        });
        var oDiv = document.getElementById('miaov_float_layer');
        var oBtnMin = document.getElementById('btn_min');
        var oBtnClose = document.getElementById('btn_close');
        var oDivContent = oDiv.getElementsByTagName('div')[0];
        var iMaxHeight = 0;
        var isIE6 = window.navigator.userAgent.match(/MSIE 6/ig) && !window.navigator.userAgent.match(/MSIE 7|8/ig);
        oDiv.style.display = 'block';
        iMaxHeight = oDivContent.offsetHeight;

        if (isIE6) {
            oDiv.style.position = 'absolute';
            repositionAbsolute();
            miaovAddEvent(window, 'scroll', repositionAbsolute);
            miaovAddEvent(window, 'resize', repositionAbsolute);
        }
        else {
            oDiv.style.position = 'fixed';
            repositionFixed();
            miaovAddEvent(window, 'resize', repositionFixed);
        }
    }

})

/**************/
if (_isshow) {
    lastScrollY = 0;
    function close(id) {
        if (id == "L") {
            document.getElementById("lovexin12").setAttribute("style", "display:none");
            document.getElementById("lovexin15").setAttribute("style", "display:none");
        } else {
            document.getElementById("lovexin14").setAttribute("style", "display:none");
            document.getElementById("lovexin16").setAttribute("style", "display:none");
        }
    }

    function heartBeat() {
        var diffY;
        if (document.documentElement && document.documentElement.scrollTop)
            diffY = document.documentElement.scrollTop;
        else if (document.body)
            diffY = document.body.scrollTop
        else
        { /*Netscape stuff*/ }
        percent = .1 * (diffY - lastScrollY);
        if (percent > 0) percent = Math.ceil(percent);
        else percent = Math.floor(percent);
        document.getElementById("lovexin12").style.top = parseInt(document.getElementById("lovexin12").style.top) + percent + "px";
        document.getElementById("lovexin14").style.top = parseInt(document.getElementById("lovexin12").style.top) + percent + "px";
        document.getElementById("lovexin15").style.top = parseInt(document.getElementById("lovexin15").style.top) + percent + "px";
        document.getElementById("lovexin16").style.top = parseInt(document.getElementById("lovexin16").style.top) + percent + "px";
        lastScrollY = lastScrollY + percent;
    }
    suspendcode12 = "<div id=\"lovexin12\" style='left:2px;position:absolute;z-index:999999;top:" + _top + "px; width:" + _w + "px;height:" + _h + "px;background-color:" + _bgclolr + "" + _boder + ";'><div style='height:" + (_h - 2) + "px'>" + l_html + "</div><div style='text-align:right;'><a href='javascript:close(\"L\")' onclick='close()'>关闭</a></div></div>"
    suspendcode14 = "<div id=\"lovexin14\" style='right:2px;position:absolute;z-index:999999;top:" + _top + "px; width:" + _w + "px;height:" + _h + "px;background-color:" + _bgclolr + "" + _boder + ";'><div style='height:" + (_h - 2) + "px'>" + r_html + "</div><div style='text-align:left;'><a href='javascript:close(\"R\")' onclick='close()'>关闭</a></div></div>"
    document.write(suspendcode12);
    document.write(suspendcode14);
    suspendcode15 = "<div onclick='openpage(\"L\")' id=\"lovexin15\" style='cursor:pointer; cursor:hand;left:2px;position:absolute;z-index:9999999;top:" + _top + "px; width:" + _w + "px;height:" + _h + "px;background:#fff; filter:alpha(opacity=1);opacity:0.1;'></div>"
    suspendcode16 = "<div onclick='openpage(\"R\")' id=\"lovexin16\" style='cursor:pointer; cursor:hand;right:2px;position:absolute;z-index:9999999;top:" + _top + "px; width:" + _w + "px;height:" + _h + "px;background:#fff; filter:alpha(opacity=1);opacity:0.1;'></div>"
    document.write(suspendcode15);
    document.write(suspendcode16);
    window.setInterval("heartBeat()", 1);

    function openpage(tp) {
        if (tp == "L") {
            window.open(l_href);
        } else {
            window.open(r_href);
        }
    }
}