function askConfirmation(message)
{
    var input = window.confirm(message);
    if (input == true) {
        return true;
    } else {
        return false;
    }
}

function CreateBookmarkLink(title, url)
{
    if (window.sidebar) {
        window.sidebar.addPanel(title, url, "");
    } else if (window.external) {
        window.external.AddFavorite(url, title);
    } else if (window.opera && window.print) {
        return true;
    }
}

function getElementByName(name, container)
{
    if (container == null)
    {
        container = document;
    }
    
    if (container.elements)
    {
        for (i=0, n=container.elements.length; i < n; i++)
        {
            if (container.elements[i].name == name)
            {
                return container.elements[i];
            }
        }
    }
    
    return null;
 }

function createHiddenFormValue(name, value, parentObject)
{
	var newElement = document.createElement("input");
	newElement.setAttribute("type", "hidden");
	newElement.setAttribute("name", name);
	newElement.setAttribute("value", value);
	parentObject.appendChild(newElement);
}

function changeFormValue(name, value, parentObject)
{
    var formElement = getElementByName(name, parentObject);
    
    if (formElement != null)
    {
        formElement.value = value;
    }
}

function getViewport()
{
    var viewport = {x: 0, y: 0, width: 0, height: 0};
    
    if (typeof window.scrollX != "undefined") {
        viewport.x = window.pageXOffset;
        viewport.y = window.pageYOffset;
        viewport.width = window.innerWidth;
        viewport.height = window.innerHeight;
        return viewport;
    } else {
        if (document.documentElement &&
            typeof document.documentElement.scrollLeft != "undefined" &&
            (document.documentElement.scrollLeft != 0)) {
            viewport.x = document.documentElement.scrollLeft;
            viewport.y = document.documentElement.scrollTop;
            viewport.width = document.documentElement.clientWidth;
            viewport.height = document.documentElement.clientHeight;
            return viewport;
        } else {
            if (document.body &&
                (typeof document.body.scrollLeft != "undefined")) {
                viewport.x = document.body.scrollLeft;
                viewport.y = document.body.scrollTop;
                if (document.compatMode == "CSS1Compat") {
                    viewport.width = document.body.parentNode.clientWidth;
                    viewport.height = document.body.parentNode.clientHeight;
                } else {
                    viewport.width = document.body.clientWidth;
                    viewport.height = document.body.clientHeight;
                }
                return viewport;
            }
        }
    }
    return null;
}

function showDialog(sUrl, dialogObject, iWidth, iHeight, isResizable, sFeatures)
{
    var sFeaturesN = "";
    sFeaturesN += "dialogWidth: " + iWidth + "px;";
    sFeaturesN += "dialogHeight: " + iHeight + "px;";
    sFeaturesN += "status: off;";
    sFeaturesN += "center: yes;";
    
    if (isResizable)
    {
        sFeaturesN += "resizable: no;"
    }
    
    sFeaturesN += sFeatures;
    
    var returnObject = window.showModalDialog(sUrl, dialogObject, sFeaturesN);
    
    return returnObject;
}

function showPopup(sUrl, iWidth, iHeight, isResizable)
{
    var sFeaturesN = ",";
    // sFeaturesN += "center: yes;";
    
    if (!isResizable)
    {
        sFeaturesN += "resizable: no;"
    }
    
    /*
    var returnObject = window.showModalDialog(sUrl, null, sFeaturesN);
    return returnObject;
    */
    
    //newwindow = window.open(sUrl, sName,'height=' + iHeight + ',width=' + iWidth + 'scrollbars=yes,toolbar=no,location=no');
    newwindow = window.open(sUrl,"","Width=" + iWidth + ",Height=" + iHeight + ",scrollbars=yes" + sFeaturesN, 0);
    if (window.focus) {newwindow.focus()}
}
