﻿//取select的值
function GetRadioValue(RadioName) {
    var radios = document.getElementsByName(RadioName);
    for (var i = 0; i < radios.length; i++) {
        if (radios[i].checked) return radios[i].value;
    }
    return null;
}
if (!Object.extend) {
    Object.extend = function(dest, source, replace) {
        for (var prop in source) {
            if (replace == false && dest[prop] != null) { continue; }
            dest[prop] = source[prop];
        }
        return dest;
    };
}
Object.extend(window, {
    isIE: navigator.userAgent.toLowerCase().indexOf('msie') != -1,
    isFirefox: navigator.userAgent.toLowerCase().indexOf('firefox') != -1,
    isOpera: window.opera != null
});

/**********************动态创建表单*******************************/
//helper function to create the form
function getNewSubmitForm() {
    var submitForm = document.createElement("FORM");
    document.body.appendChild(submitForm);
    submitForm.method = "POST";
    return submitForm;
}

//helper function to add elements to the form
function createNewFormElement(inputForm, elementName, elementValue) {
    //create a submit button     
    var tempInput = document.createElement("input");
    tempInput.type = "hidden";
    tempInput.name = elementName;
    tempInput.value = elementValue;  //the parameter of method in the code of DispatchAction.
    inputForm.appendChild(tempInput);
    return tempInput;
}

/**********************动态创建表单*******************************/

/**********************表格工具***********************************/

var cellcss, cellovercss;
function DrawTable(tableid, cellcssn, cellovercssn) {
    cellcss = cellcssn;
    cellovercss = cellovercssn;
    var tblList = document.getElementById(tableid);
    for (var irow = 0; irow < tblList.rows.length; irow++) {
        var maxheight = 0;
        for (var icell = 0; icell < tblList.rows[irow].cells.length; icell++) {
            if (tblList.rows[irow].cells[icell].tagName.toLowerCase() == 'td') {
                tblList.rows[irow].cells[icell].className = cellcss;
                tblList.rows[irow].cells[icell].onmouseover = Cellmouseover;
                tblList.rows[irow].cells[icell].onmouseout = Cellmouseout;
                if (tblList.rows[irow].cells[icell].offsetHeight > maxheight) {
                    maxheight = tblList.rows[irow].cells[icell].offsetHeight;
                }
            }
        }
        for (var icell = 0; icell < tblList.rows[irow].cells.length; icell++) {
            document.getElementById(tblList.rows[irow].cells[icell].lang).style.height = maxheight + 'px';
        }
    }
}
function Cellmouseover() { this.className = cellovercss; };
function Cellmouseout() { this.className = cellcss; };

var rowcolor, alterrowcolor, rowovercolor;
function DrawTableRowBgColor(tableid, rowcolorn, alterrowcolorn, rowovercolorn) {
    rowcolor = rowcolorn;
    alterrowcolor = alterrowcolorn;
    rowovercolor = rowovercolorn;
    var tblList = document.getElementById(tableid);
    if (tblList == null) {
        return;
    }
    for (var irow = 0; irow < tblList.rows.length; irow++) {
        if (irow % 2 > 0) {
            tblList.rows[irow].style.backgroundColor = rowcolor;
            tblList.rows[irow].lang = rowcolor;
        }
        else {
            tblList.rows[irow].style.backgroundColor = alterrowcolor;
            tblList.rows[irow].lang = alterrowcolor;
        }
        tblList.rows[irow].onmouseover = Rowmouseover;
        tblList.rows[irow].onmouseout = Rowmouseout;
    }
}
function Rowmouseover() { this.style.backgroundColor = rowovercolor; };
function Rowmouseout() { this.style.backgroundColor = this.lang; };

/**********************表格工具***********************************/

/**********************位置***********************************/

//获取元素绝对顶点
function GetTop(El) {
    var ElTop = El.offsetTop;
    while (El.offsetParent != null && El.tagName != "BODY") {
        ElTop += El.offsetParent.offsetTop;
        El = El.offsetParent;
    }
    return ElTop;
}

//获取元素绝对左起点
function GetLeft(El) {
    var ElLeft = El.offsetLeft;
    while (El.offsetParent != null && El.tagName != "BODY") {
        ElLeft += El.offsetParent.offsetLeft;
        El = El.offsetParent;
    }
    return ElLeft;
}

/**********************位置***********************************/