﻿//"1 固定左上", "2 固定右上", "3 固定对联", "4 浮动左上"
//"5 浮动左下", "6 浮动右上", "7 浮动右下", "8 浮动对联",
//格式为 showtype | src | width | height | link | title | font |
var AD = {};
AD.create = function(type, code) {
    switch (type) {
        case "1":
            document.write('<div style="position: absolute; z-index: 9999; left: 0; top: 0;">');
            document.write(code);
            document.write('</div>');
            break;
        case "2":
            document.write('<div style="position: absolute; z-index: 9999; right: 0; top: 0;">');
            document.write(code);
            document.write('</div>');
            break;
        case "3":
            document.write('<div style="position: absolute; z-index: 9999; left: 22px; top: 127px;">');
            document.write(code);
            document.write('</div>');
            document.write('<div style="position: absolute; z-index: 9999; right: 22px; top: 127px;">');
            document.write(code);
            document.write('</div>');
            break;
        case "4":
            document.write('<div style="position:fixed; _position:absolute; z-index: 9999; left: 0; top: 0;">');
            document.write(code);
            document.write('</div>');
            break;
        case "5":
            document.write('<div style="position:fixed; _position:absolute; z-index: 9999; left: 0; bottom: 0;">');
            document.write(code);
            document.write('</div>');
            break;
        case "6":
            document.write('<div style="position:fixed; _position:absolute; z-index: 9999; right: 0; top: 0;">');
            document.write(code);
            document.write('</div>');
            break;
        case "7":
            document.write('<div style="position:fixed; _position:absolute; z-index: 9999; right: 0; bottom: 0;">');
            document.write(code);
            document.write('</div>');
            break;
        case "8":
            document.write('<div id="floatside1" style="position: absolute; z-index: 9999; left: 22px; top: 127px;">');
            document.write(code);
            document.write('</div>');
            document.write('<div id="floatside2" style="position: absolute; z-index: 9999; right: 22px; top: 127px;">');
            document.write(code);
            document.write('</div>');
            window.setInterval("AD.floatSide('floatside1', 'floatside2')", 30);
            break;
        case "9":
            document.write('<div id="floatfree" style="visibility:visible; position:absolute; z-index: 9999;">');
            document.write(code);
            document.write('</div>');
            window.setInterval("AD.changePos('floatfree')", delay);
            break;
    }
}

var lastScrollY = 0;
AD.floatSide = function(objid1, objid2) {
    var diffY;
    if (document.documentElement && document.documentElement.scrollTop)
        diffY = document.documentElement.scrollTop;
    else if (document.body)
        diffY = document.body.scrollTop

    var percent = .1 * (diffY - lastScrollY);
    if (percent > 0) percent = Math.ceil(percent);
    else percent = Math.floor(percent);
    document.getElementById(objid1).style.top = parseInt(document.getElementById(objid1).style.top) + percent + "px";
    if (objid2 != undefined)
        document.getElementById(objid2).style.top = parseInt(document.getElementById(objid2).style.top) + percent + "px";
    lastScrollY = lastScrollY + percent;
}

