﻿//获取浏览器高度
function web_getTotalHeight() {
    if ($.browser.msie) {
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight;
    } else {
        return self.innerHeight;
    }
}

//获取浏览器宽度
function web_getTotalWidth() {
    if ($.browser.msie) {
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : document.body.clientWidth;
    } else {
        return self.innerWidth;
    }
}

//顶部距离
function web_getToTop() {
    var scrollPos;
    if (typeof window.pageYOffset != 'undefined')    //针对Netscape 浏览器
    {
        scrollPos = window.pageYOffset;
    }
    else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
        scrollPos = document.documentElement.scrollTop;
    }
    else if (typeof document.body != 'undefined') {
        scrollPos = document.body.scrollTop;
    }
    return scrollPos;
}

$(document).ready(function() {
    showDD();
    //改变窗口大小
    var pResizeTimer = null;
    $(window).bind('resize',
		  function() {
		      if (pResizeTimer)
		          clearTimeout(pResizeTimer);
		      pResizeTimer = setTimeout(showDD, 50);
		  }).bind('scroll', function() {
		      if (pResizeTimer)
		          clearTimeout(pResizeTimer);
		      pResizeTimer = setTimeout(showDD, 50);
		  });
    //end
})
function showDD() {
    if ($("#webLeft").html()) {
        var width = web_getTotalWidth();
        var height = web_getTotalHeight();
        var top = web_getToTop();
        w_left = $("#webLeft").attr("l") * 1;
        w_top = $("#webLeft").attr("t") * 1;
        w_top = w_top + top;
        $("#webLeft").css("position", "absolute");
        $("#webLeft").css("z-index", "10001");
        $("#webLeft").css("left", w_left);
        $("#webLeft").css("top", w_top);
    }
    if ($("#webRight").html()) {
        var width = web_getTotalWidth();
        var height = web_getTotalHeight();
        var top = web_getToTop();
        var w_w = $("#webRight").css("width");
        var _w = w_w.substring(0, w_w.indexOf("px")) * 1;
        w_left = $("#webRight").attr("l") * 1;
        w_left = width - _w - w_left;
        w_top = $("#webRight").attr("t") * 1;
        w_top = w_top + top;
        $("#webRight").css("position", "absolute");
        $("#webRight").css("z-index", "10001");
        $("#webRight").css("left", w_left);
        $("#webRight").css("top", w_top);
    }
}