function openWindow(url, width, height) {
	var leftValue = (screen.width - width) / 2;
 	var topValue = (screen.height - height) / 2;
 	var newWindow = window.open(url, "", "toolbar=0, scrollbars=0, resizable=0, width=" + width + ", height=" + height + ", left=" + leftValue + ", top=" + topValue + "");
}

function HighlightText(id) {
    document.getElementById(id).style.color = "#000000";
    document.getElementById(id).style.cursor = "pointer";
}

function UnhighlightText(id) {
    document.getElementById(id).style.color = "#64543c";
}

function Toggle(id) {
    if (document.getElementById(id).style.display == "none") {
        document.getElementById(id + "-text").innerHTML = "collapse";
        document.getElementById(id + "-border").style.display = "none";
    } else {
        document.getElementById(id + "-text").innerHTML = "expand";
        document.getElementById(id + "-border").style.display = "block";
    }
}

function CheckDataCollectionForm() {
    var isValid = false;
    
    for (i = 0; i < document.forms[0].projectType.length; i++) {
        if (document.forms[0].projectType[i].checked) {
            isValid = true;
        }
    }
    
    if (isValid) {
        TurnOnLink();
    } else {
        TurnOffLink();
    }
}

function CheckSubmitNewProjectForm() {
    var isValid = false;
    var projectTypeValid = false;
    var projectPhaseValid = false;
    var projectTitleValid = false;
    var projectIDValid = false;
    var separatePlanTypeValid = false;
    var fileValid = false;
    
    for (i = 0; i < document.forms[0].projectType.length; i++) {
        if (document.forms[0].projectType[i].checked) {
            projectTypeValid = true;
        }
    }

    for (i = 0; i < document.forms[0].projectPhase.length; i++) {
        if (document.forms[0].projectPhase[i].checked) {
            projectPhaseValid = true;
        }
    }

    if (document.forms[0].projectPhase[0].checked) {
        animatedcollapse.show('project-title');
        if (document.forms[0].projectTitle.value != "") {
            projectTitleValid = true;
        }
    } else {
        animatedcollapse.hide('project-title');
    }

    if (document.forms[0].existingProject[0].checked) {
        animatedcollapse.show('project-id');
        if (document.forms[0].projectID.value != "") {
            projectIDValid = true;
        }
    } else {
        animatedcollapse.hide('project-id');
    }

    for (i = 0; i < document.forms[0].separatePlanType.length; i++) {
        if (document.forms[0].separatePlanType[i].checked) {
            separatePlanTypeValid = true;
        }
    }
    
    if (document.forms[0].file.value != "") {
        fileValid = true;
    }

    if (document.forms[0].projectPhase[0].checked && document.forms[0].existingProject[0].checked) {
        if (projectTypeValid && projectPhaseValid && separatePlanTypeValid && projectTitleValid && projectIDValid && fileValid) {
            isValid = true;
        }    
    } else if (document.forms[0].projectPhase[0].checked && !document.forms[0].existingProject[0].checked) {
        if (projectTypeValid && projectPhaseValid && separatePlanTypeValid && projectTitleValid && fileValid && document.forms[0].existingProject[1].checked) {
            isValid = true;
        }
    } else {
        if (projectTypeValid && projectPhaseValid && separatePlanTypeValid && fileValid) {
            isValid = true;
        }
    }
    
    if (isValid) {
        TurnOnLink();
    } else {
        TurnOffLink();
    }
}

function CheckContactBIGForm() {
    var isValid = true;
    
    if (document.forms[0].name.value == "") {
        isValid = false;
    }
    
    if (!CheckEmail()) {
        isValid = false;
    }
    
    if (isValid) {
        TurnOnLink();
    } else {
        TurnOffLink();
    }
}

function TurnOnLink() {
    document.getElementById("off").style.display = "none";
    document.getElementById("on").style.display = "block";
}

function TurnOffLink() {
    document.getElementById("off").style.display = "block";
    document.getElementById("on").style.display = "none";
}

function CheckEmail() {
    var str = document.forms[0].email.value;
    var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    if (filter.test(str)) {
        return true;
    } else {
        return false;
    }
}

function ResetForm() {
    document.forms[0].reset();
}