function publish() {
    document.forms["metadataForm"].action.value = "publish";
    document.forms["metadataForm"].submit();
}

function save() {
    document.forms["metadataForm"].action.value = "save";
    document.forms["metadataForm"].submit();
}

function release(exitEditorUrl, msg, header) {
    if (document.getElementById("action").value == "") {
        alert(msg);
        var theExitWin = window.open(exitEditorUrl, header, "scrollbars=yes,status=yes,menubar=no,resizable=yes,top=0,width=200,height=200,left=0");
    }
}

function toggleServiceName(value) {
    element = document.getElementById('serviceNameField');
    if (value == 'ArcIMS') {
        element.style.visibility = 'visible';
    } else {
        element.style.visibility = 'hidden';
    }
}

function checkPublicationForm() {
    if ((document.getElementById("ID0").checked == false) && (document.getElementById("ID1").checked == false) && (document.getElementById("ID2").checked == false)) {
        var text = "";
        if (document.publishForm.currentLocale.value == "de") {
            text = "Die Angabe zum Protectionlevel fehlt.";
        } else {
            text = "The value for protection level is missing.";
        }
        alert(text);
        return false;
    }
    return true;
}


function checkTemplateForm(id) {
    if (id == 'deleteButton' || id == 'viewButton' || id == 'loadButton') {
        if (document.getElementById("selectedTemplate").value == "") {
            var message = document.getElementById("hiddenTemplateMessage").value;
            alert(message);
        }
    }

    if (id == 'uploadButton') {
        document.getElementById('action').value = "upload";
        document.getElementById('metadataForm').submit();
    }

    if (document.getElementById("selectedTemplate").value != "") {
        if (id == 'deleteButton') {
            document.getElementById('action').value = "delete";
        } else if (id == 'viewButton') {
            document.getElementById('action').value = "view";
        } else if (id == 'loadButton') {
            document.getElementById('action').value = "load";
        }
        document.getElementById('metadataForm').submit();
    }
}

function submitForm(id) {
    document.hierarchyForm.selectedId.value = id;
    document.hierarchyForm.submit();
}

function disableElements() {
    var e = document.getElementsByTagName("input");
    for (var i = 0; i < e.length; i++) {
        if (e[i].value == "NOT EDITABLE") {
            e[i].disabled = true;
        }
    }
}
function openWindowExtended(target, pWidth, pHeight) {
    var WinE = window.open(target, 'winExtend', 'scrollbars=yes,menubar=no,height=' + pHeight + ',width=' + pWidth + ',resizable=yes,toolbar=no,location=no,status=no');
    WinE.focus();
}

function openWindowExtendedScrollable(target, pWidth, pHeight)
{
    var WinE = window.open(target, 'winExtend', 'scrollbars=yes,menubar=no,height=' + pHeight + ',width=' + pWidth + ',resizable=yes,toolbar=no,location=no,status=no');
    WinE.focus();
}

function setSRSCode(code) {
    var e = document.getElementById("srsCode");
    e.value = code;
}

function addOperation() {
    document.forms["metadataForm"].action.value = "addOrRemoveOperation";
    document.forms["metadataForm"].submit();

}

function removeOperation(id) {
    document.getElementById("removeElementIndex").value = id;
    document.forms["metadataForm"].action.value = "addOrRemoveOperation";
    document.forms["metadataForm"].submit();
}

function addCoupledResource() {
    document.forms["metadataForm"].action.value = "addOrRemoveCoupledResource";
    document.forms["metadataForm"].submit();
}

function removeCoupledResource(id) {
    document.getElementById("removeElementIndex").value = id;
    document.forms["metadataForm"].action.value = "addOrRemoveCoupledResource";
    document.forms["metadataForm"].submit();
}


