function fillAuctionCategories(level) {
    document.forms[0].action="/de/fillAuctionCategories.do";
    switch (level) {
        case 2:
            if (document.forms[0].category.selectedIndex > -1) {
                updateAuctionCategoryText(2);
                document.forms[0].level.value = "2";
            }
            break;
        case 3:
            if (document.forms[0].subCategory.selectedIndex > -1) {
                updateAuctionCategoryText(3);
                document.forms[0].level.value = "3";
            }
            break;
        case 4:
            if (document.forms[0].subSubCategory.selectedIndex > -1) {
                updateAuctionCategoryText(4);
                document.forms[0].level.value = "4";
            }
            break;
        case 5:
            if (document.forms[0].subSubSubCategory.selectedIndex > -1) {
                updateAuctionCategoryText(5);
                document.forms[0].level.value = "5";
            }
            break;
    }
    document.forms[0].submit();
}

function setValidation(validate) {
    if (validate == true) {
        document.forms[0].validate.value = "T";
    } else {
        document.forms[0].validate.value = "F";
    }
}

function setValidationAndInvitation(validate) {
    if (validate == true) {
        document.forms[0].validate.value = "T";
        document.forms[0].sendInvitation.value = "T";
    } else {
        document.forms[0].validate.value = "F";
        document.forms[0].sendInvitation.value = "F";
    }
}

function submitForm(validate, target) {
    if (validate == true) {
        document.forms[0].validate.value = "T";
    } else {
        document.forms[0].validate.value = "F";
    }
    document.forms[0].forward.value = target;
    document.forms[0].submit();
}

function editInvitationMail() {
	document.forms[0].sendInvitation.value = "C";
	document.forms[0].submit();
	
	return true;
}

function updateProjectCategoryText() {
    if (document.forms[0].category.selectedIndex > -1) {
        document.forms[0].categoryText.value = document.forms[0].category[document.forms[0].category.selectedIndex].text;
    }
}

function updateAuctionCategoryText(level) {

    switch (level) {
        case 2:
            if (document.forms[0].category.selectedIndex > -1) {
                document.forms[0].categoryText.value = document.forms[0].category[document.forms[0].category.selectedIndex].text;
            }
            break;
        case 3:
            document.forms[0].categoryText.value = document.forms[0].category[document.forms[0].category.selectedIndex].text;
            if (document.forms[0].subCategory.selectedIndex > -1) {
                document.forms[0].categoryText.value += " > ";
                document.forms[0].categoryText.value += document.forms[0].subCategory[document.forms[0].subCategory.selectedIndex].text;
            }
            break;
        case 4:
            document.forms[0].categoryText.value = document.forms[0].category[document.forms[0].category.selectedIndex].text;
            document.forms[0].categoryText.value += " > ";
            document.forms[0].categoryText.value += document.forms[0].subCategory[document.forms[0].subCategory.selectedIndex].text;
            if (document.forms[0].subSubCategory.selectedIndex > -1) {
                document.forms[0].categoryText.value += " > ";
                document.forms[0].categoryText.value += document.forms[0].subSubCategory[document.forms[0].subSubCategory.selectedIndex].text;
            }
            break;
        case 5:
            if (document.forms[0].category.selectedIndex > -1) {
                document.forms[0].categoryText.value = document.forms[0].category[document.forms[0].category.selectedIndex].text;
            }
            if (document.forms[0].subCategory.selectedIndex > -1) {
                document.forms[0].categoryText.value += " > ";
                document.forms[0].categoryText.value += document.forms[0].subCategory[document.forms[0].subCategory.selectedIndex].text;
            }
            if (document.forms[0].subSubCategory.selectedIndex > -1) {
                document.forms[0].categoryText.value += " > ";
                document.forms[0].categoryText.value += document.forms[0].subSubCategory[document.forms[0].subSubCategory.selectedIndex].text;
            }
            if (document.forms[0].subSubSubCategory.selectedIndex > -1) {
                document.forms[0].categoryText.value += " > ";
                document.forms[0].categoryText.value += document.forms[0].subSubSubCategory[document.forms[0].subSubSubCategory.selectedIndex].text;   
            }
            break;
    }
}

function deletePersonalEntry(adrbId) {
    document.forms[0].action="/de/deleteFromPersonalAddressbook.do";
    document.forms[0].adrbId.value=adrbId;
    document.forms[0].submit();
}

function deleteUnpersonalEntry(adrbId) {
    document.forms[0].action="/de/deleteFromUnpersonalAddressbook.do";
    document.forms[0].adrbId.value=adrbId;
    document.forms[0].submit();
}

function fillCombo(param) {
	document.forms[0].action="/de/fillCountry.do#country";
	document.forms[0].comboBox.value = param;
	document.forms[0].submit();
}

function fillEditCombo(param) {
	document.forms[0].action="/de/fillEditCountry.do#country";
	document.forms[0].comboBox.value = param;
	document.forms[0].submit();
}

function fillUserdataCombo(param) {
	document.forms[0].action="/de/auth/fillUserdataCombo.do#country";
	document.forms[0].comboBox.value = param;
	document.forms[0].submit();
}

function fillProjectCombo(param) {
	document.forms[0].action="/de/fillProjectCombo.do#country";
	document.forms[0].comboBox.value = param;
	document.forms[0].submit();
}

function fillProjectOrgCombo(param) {
    document.forms[0].action="/de/fillProjectOrgCombo.do#country";
    document.forms[0].comboBox.value = param;
    document.forms[0].submit();
}

function fillAuctionCombo(param) {
	document.forms[0].action="/de/fillAuctionCombo.do#country";
	document.forms[0].comboBox.value = param;
	document.forms[0].submit();
}

function uploadProjectManager() {
	document.forms[0].upload_project_manager.disabled = true;
	document.forms[0].action="/de/auth/uploadProjectManager.do";
	document.forms[0].submit();

	return false;
}

function uploadProject() {
    document.forms[0].upload_project.disabled = true;
    document.forms[0].action="/de/auth/uploadProject.do";
    document.forms[0].submit();

    return false;
}

function uploadProjectAdditional() {
    document.forms[0].upload_project_additional.disabled = true;
    document.forms[0].action="/de/auth/uploadProjectAdditional.do";
    document.forms[0].submit();

    return false;
}

function deleteAbstractFile() {
	document.forms[0].upload_abstract.disabled = true;
	document.forms[0].action="/de/auth/deleteFromAbstractFiles.do";
	document.forms[0].submit();
		
	return false;
}

function describeAbstractFile() {
	document.forms[0].upload_abstract.disabled = true;
	document.forms[0].action="/de/auth/describeAbstractFiles.do";
	document.forms[0].submit();

	return false;
}

function uploadBackgroundFile() {
	document.forms[0].upload_background.disabled = true;
	document.forms[0].action="/de/auth/uploadBackgroundFile.do";
	document.forms[0].submit();

	return false;
}

function deleteBackgroundFile() {
	document.forms[0].upload_background.disabled = true;
	document.forms[0].action="/de/auth/deleteFromBackgroundFiles.do";
	document.forms[0].submit();
		
	return false;
}

function describeBackgroundFile() {
	document.forms[0].upload_background.disabled = true;
	document.forms[0].action="/de/auth/describeBackgroundFiles.do";
	document.forms[0].submit();

	return false;
}

function uploadAdditionalFile() {
	document.forms[0].upload_additional.disabled = true;
	document.forms[0].action="/de/auth/uploadAdditionalFile.do";
	document.forms[0].submit();

	return false;
}

function deleteAdditionalFile() {
	document.forms[0].upload_additional.disabled = true;
	document.forms[0].action="/de/auth/deleteFromAdditionalFiles.do";
	document.forms[0].submit();
		
	return false;
}

function deleteAuctionBackgroundImage(idToDelete) {
    document.forms[0].forward.value = 'createAuctionStep2';
    document.forms[0].deleteImage.value = idToDelete;
    document.forms[0].action="/de/auth/deleteAuctionBackgroundImage.do";
    document.forms[0].submit();

    return false;
}

function describeAdditionalFile() {
	document.forms[0].upload_additional.disabled = true;
	document.forms[0].action="/de/auth/describeAdditionalFiles.do";
	document.forms[0].submit();

	return false;
}

function uploadAuctionImage() {
    document.forms[0].upload_auction_image.disabled = true;
    document.forms[0].action="/de/auth/uploadAuctionImage.do";
    document.forms[0].submit();

    return false;
}

function uploadAuctionBackgroundImage() {
    document.forms[0].upload_auction_background.disabled = true;
    document.forms[0].forward.value = 'createAuctionStep2';
    document.forms[0].action="/de/auth/uploadAuctionBackground.do";
    document.forms[0].submit();

    return false;
}

function uploadProjectBackgroundImage() {
    document.forms[0].upload_project_background.disabled = true;
    document.forms[0].action="/de/auth/uploadProjectBackground.do";
    document.forms[0].submit();

    return false;
}

function uploadAuctionAdditionalFile() {
    document.forms[0].upload_auction_additional.disabled = true;
    document.forms[0].action="/de/auth/uploadAuctionAdditionalFile.do";
    document.forms[0].submit();

    return false;
}

function disableOrganization(arg0) {
	document.forms[0].organization.disabled = true;
    document.forms[0].orgStreet.disabled = true;
    document.forms[0].orgZipCode.disabled = true;
    document.forms[0].orgCity.disabled = true;
    document.forms[0].orgPhone.disabled = true;
    document.forms[0].orgFax.disabled = true;
    document.forms[0].orgEmail.disabled = true;
    document.forms[0].orgCountry.disabled = true;
    document.forms[0].orgState.disabled = true;
    document.forms[0].orgCounty.disabled = true;
	document.forms[0].remittee.value = arg0;
	document.forms[0].remittee.focus();
}

function enableOrganization() {
	document.forms[0].organization.disabled = false;
    document.forms[0].orgStreet.disabled = false;
    document.forms[0].orgZipCode.disabled = false;
    document.forms[0].orgCity.disabled = false;
    document.forms[0].orgPhone.disabled = false;
    document.forms[0].orgFax.disabled = false;
    document.forms[0].orgEmail.disabled = false;
    document.forms[0].orgCountry.disabled = false;
    document.forms[0].orgState.disabled = false;
    document.forms[0].orgCounty.disabled = false;
	document.forms[0].remittee.value = "";
}

function enableDonnationList() {
	if (document.forms[0].project.value != "") {
		document.forms[0].donnation.disabled = false;
	} else {
		document.forms[0].donnation.disabled = true;
	}
}


function getAppletContents() {

    return document.editor1.getContents();
}

function deleteOption(object,index) {
    object.options[index] = null;
}

function addOption(object,text,value) {
    var defaultSelected = true;
    var selected = true;
    var optionName = new Option(text, value, defaultSelected, selected)
    object.options[object.length] = optionName;
}

function copySelected(fromObject, toObject) {
    for (var i=0, l=fromObject.options.length;i<l;i++) {
        if (fromObject.options[i].selected)
            addOption(toObject,fromObject.options[i].text,fromObject.options[i].value);
    }
    for (var i=fromObject.options.length-1;i>-1;i--) {
        if (fromObject.options[i].selected)
            deleteOption(fromObject,i);
    }
}

function deleteDummy(object1, object2) {
    if (object1.options[0].value == "-1") {
        object1.options[0] = null;
    }
    if (object2.options[0].value == "-1") {
        object2.options[0] = null;
    }
    return true;
}

function copyToClipboard(param) {
	tempval = document.forms[0][param].value;
	tempval.execCommand("Copy");
}

function setCheckBox(field, object1) {
    if (object1.checked == true) {
        document.forms[0][field].value = "T";
    } else {
        document.forms[0][field].value = "F";
    }
}

function addToAddressbook(type) {
    url = "/de/auth/mycare/project/add_to_addressbook.jsp?salutation=";
    url += document.forms[0].salutation.value;
    url += "&firstName=";
    url += document.forms[0].firstName.value;
    url += "&lastName=";
    url += document.forms[0].lastName.value;
    url += "&email=";
    url += document.forms[0].email.value;
    url += "&title=";
    url += document.forms[0].title.value;
    url += "&type=";
    url += type;
    newWindow = window.open(url, "", "height=1,width=1");
	for (var i=0; i<100000; i++) {
		doNothing();
	}
    newWindow.close();
}

function doNothing() {
}

function deleteProjectBackgroundImage(idToDelete) {
    document.forms[0].forward.value = 'createProjectStep2';
    document.forms[0].deleteImage.value = idToDelete;
    document.forms[0].action="/de/auth/deleteProjectBackgroundImage.do";
    document.forms[0].submit();

    return false;
}

function deleteProjectAdditionalFile(idToDelete) {
    document.forms[0].forward.value = 'createProjectStep1';
    document.forms[0].deleteAdditional.value = idToDelete;
    document.forms[0].action="/de/auth/deleteProjectAdditional.do";
    document.forms[0].submit();

    return false;
}

function fillEstateCategories(level) {
    document.forms[0].action="/de/fillEstateCategories.do";
    switch (level) {
        case 2:
            if (document.forms[0].category.selectedIndex > -1) {
                updateEstateCategoryText(2);
                document.forms[0].level.value = "2";
            }
            break;
        case 3:
            if (document.forms[0].subCategory.selectedIndex > -1) {
                updateEstateCategoryText(3);
                document.forms[0].level.value = "3";
            }
            break;
        case 4:
            if (document.forms[0].subSubCategory.selectedIndex > -1) {
                updateEstateCategoryText(4);
                document.forms[0].level.value = "4";
            }
            break;
        case 5:
            if (document.forms[0].subSubSubCategory.selectedIndex > -1) {
                updateEstateCategoryText(5);
                document.forms[0].level.value = "5";
            }
            break;
    }
    document.forms[0].submit();
}

function updateEstateCategoryText(level) {

    switch (level) {
        case 2:
            if (document.forms[0].category.selectedIndex > -1) {
                document.forms[0].categoryText.value = document.forms[0].category[document.forms[0].category.selectedIndex].text;
            }
            break;
        case 3:
            document.forms[0].categoryText.value = document.forms[0].category[document.forms[0].category.selectedIndex].text;
            if (document.forms[0].subCategory.selectedIndex > -1) {
                document.forms[0].categoryText.value += " > ";
                document.forms[0].categoryText.value += document.forms[0].subCategory[document.forms[0].subCategory.selectedIndex].text;
            }
            break;
        case 4:
            document.forms[0].categoryText.value = document.forms[0].category[document.forms[0].category.selectedIndex].text;
            document.forms[0].categoryText.value += " > ";
            document.forms[0].categoryText.value += document.forms[0].subCategory[document.forms[0].subCategory.selectedIndex].text;
            if (document.forms[0].subSubCategory.selectedIndex > -1) {
                document.forms[0].categoryText.value += " > ";
                document.forms[0].categoryText.value += document.forms[0].subSubCategory[document.forms[0].subSubCategory.selectedIndex].text;
            }
            break;
        case 5:
            if (document.forms[0].category.selectedIndex > -1) {
                document.forms[0].categoryText.value = document.forms[0].category[document.forms[0].category.selectedIndex].text;
            }
            if (document.forms[0].subCategory.selectedIndex > -1) {
                document.forms[0].categoryText.value += " > ";
                document.forms[0].categoryText.value += document.forms[0].subCategory[document.forms[0].subCategory.selectedIndex].text;
            }
            if (document.forms[0].subSubCategory.selectedIndex > -1) {
                document.forms[0].categoryText.value += " > ";
                document.forms[0].categoryText.value += document.forms[0].subSubCategory[document.forms[0].subSubCategory.selectedIndex].text;
            }
            if (document.forms[0].subSubSubCategory.selectedIndex > -1) {
                document.forms[0].categoryText.value += " > ";
                document.forms[0].categoryText.value += document.forms[0].subSubSubCategory[document.forms[0].subSubSubCategory.selectedIndex].text;   
            }
            break;
    }
}

function fillEstateCombo(param) {
	document.forms[0].action="/de/fillEstateCombo.do#country";
	document.forms[0].comboBox.value = param;
	document.forms[0].submit();
}

function deleteEstateBackgroundImage(idToDelete) {
    document.forms[0].forward.value = 'createEstateStep2';
    document.forms[0].deleteImage.value = idToDelete;
    document.forms[0].action="/de/auth/deleteEstateBackgroundImage.do";
    document.forms[0].submit();

    return false;
}

function deleteEstateAdditional(idToDelete) {
    document.forms[0].forward.value = 'createEstateSte1';
    document.forms[0].deleteImage.value = idToDelete;
    document.forms[0].action="/de/auth/deleteEstateAdditional.do";
    document.forms[0].submit();

    return false;
}

function uploadEstateImage() {
    document.forms[0].upload_estate_image.disabled = true;
    document.forms[0].action="/de/auth/uploadEstateImage.do";
    document.forms[0].submit();

    return false;
}

function uploadEstateBackgroundImage() {
    document.forms[0].upload_estate_background.disabled = true;
    document.forms[0].forward.value = 'createEstateStep2';
    document.forms[0].action="/de/auth/uploadEstateBackground.do";
    document.forms[0].submit();

    return false;
}

function uploadEstateAdditionalFile() {
    document.forms[0].upload_estate_additional.disabled = true;
    document.forms[0].action="/de/auth/uploadEstateAdditionalFile.do";
    document.forms[0].submit();

    return false;
}
