function checkUncheckAll(theElement) {

    var theForm = theElement.form, z = 0;
    for(z=0; z<theForm.length;z++){
        if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
            theForm[z].checked = theElement.checked;
        }
    }
}

function ComfirmDialog(theElement, Action, Object)
{
    var iCheck = 0;
    var theForm = theElement.form, z = 0;
    
    for(z=0; z<theForm.length; z++)
    {
        if(theForm[z].type == 'checkbox' || theForm[z].name == 'checkall')
        {
            if (theForm[z].checked)
            {
                iCheck = 1;
                break;
            }
        }
    }
    
    if (iCheck == 1)
    {
        if (Object=='contact')
            return confirm('Do you want to ' + Action + ' the selected contact(s)?');

        if (Object=='user')
            return confirm('Do you want to ' + Action + ' the selected user(s)?');

        if (Object=='group')
            return confirm('Do you want to ' + Action + ' the selected group(s)?');
    }

}

function ConfirmOperation(message, options) 
{
    Dialog.confirm(mensaje, options);
}


function showPopupMenu(layerId, parentMenu)
{
    var parentMenuObj = document.getElementById(parentMenu);
    var popupObj = document.getElementById(layerId);
    var offsetX =5;
    var offsetY =27;

    popupObj.style.top = getAbsY(parentMenuObj) + offsetY;
    popupObj.style.left = getAbsX(parentMenuObj) + offsetX;
    if(navigator.appName == "Netscape")
    {
        popupObj.style.left = getAbsX(parentMenuObj) + offsetX + "px";
        popupObj.style.top =  getAbsY(parentMenuObj) + offsetY + "px";
    }
    popupObj.style.display = "inline";
    popupObj.style.visibility = "visible";
}

function hidePopupMenu(layerId)
{
    var popupObj = document.getElementById(layerId);
    popupObj.style.visibility = "hidden";
}

function getAbsX(obj) //gets absolute X coordinate of an object
{
    var leftOffset = 0;

    if (obj.offsetParent)
    {

        while (obj.offsetParent)
        {
            leftOffset += obj.offsetLeft;
            obj = obj.offsetParent;
        }
    }
    else if (obj.x) //for Netscape v.4
    {
        leftOffset = obj.x;
    }
    return leftOffset;
}

function getAbsY(obj) //gets absolute Y coordinate of an object
{
    var topOffset = 0;

    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            topOffset += obj.offsetTop;
            obj = obj.offsetParent;
        }
    }
    else if (obj.y) //for Netscape v.4
    {
        topOffset = obj.y;
    }
    
    return topOffset;
}

function checkAll(field) 
{
    for (i = 0; i < field.length; i++)
        field[i].checked = true;
}

function uncheckAll(field) 
{
    for (i = 0; i < field.length; i++)
        field[i].checked = false;
}
