﻿function ShowList(id)
{
    var txtInput = document.getElementById(id);
    var drpList = document.getElementById(id+'List');
    var drpItems = document.getElementById(id+'Items');
    if(drpList.style.display == 'block')
    {
        txtInput.title = '点击显示下拉框';
        drpList.style.display = 'none';
    }
    else
    {
        txtInput.title = '点击关闭下拉框';
        drpList.style.display = 'block';
        drpList.style.left = GetOffsetLeft(txtInput)+'px';
        drpList.style.top = (GetOffsetTop(txtInput)+1)+'px';
        drpItems.style.width = txtInput.offsetWidth+'px';
    }
}

function GetOffsetTop(e) 
{
    var offsetTop = e.offsetTop;
    var offsetParent = e.offsetParent;
    while(offsetParent)
    {
        offsetTop += offsetParent.offsetTop;
        offsetParent = offsetParent.offsetParent;
    }
    return offsetTop + e.offsetHeight;
}
function GetOffsetLeft(e) 
{
    var offsetLeft = e.offsetLeft;
    var offsetParent = e.offsetParent;
    while(offsetParent) 
    {
        offsetLeft += offsetParent.offsetLeft;
        offsetParent = offsetParent.offsetParent;
    }
    return offsetLeft;
}
//容错
function killErrors() {
return true;
}
window.onerror = killErrors;
