// Gallery pop-up script

function galleryPop(image) {
    var file = "events_gallery_viewer.php?image=" + image;
    galleryViewer=window.open(file,"galleryviewer","toolbar=no,width=400,height=400,directories=no,status=no,scrollbars=no,resize=no,menubar=no")
}


// Validate required form fields for leaving feedback

function validate_feedback() {

    var score = 0; var needed = 0;
    needed++; if (document.forms[0].name.value != '') score++;
    needed++; if (document.forms[0].email.value != '') score++;
    needed++; if (document.forms[0].comment.value != '') score++;
    needed++; if (document.forms[0].member[0].checked || document.forms[0].member[1].checked) score++;

    if (score == needed) return true;
    else {
        alert('Please be sure to complete all fields.'); 
        return false;
    }

}


// Validate required form fields for creating a new administrator

function validate_administrator() {

    var score = 0; var needed = 0;
    needed++; if (document.forms[0].firstname.value != '') score++;
    needed++; if (document.forms[0].lastname.value != '') score++;
    needed++; if (document.forms[0].username.value != '') score++;

    // If we're editing, passwords are not mandatory
    if (!document.forms[0].id.value) {
        needed++; if (document.forms[0].userpass1.value != '') score++;
        needed++; if (document.forms[0].userpass2.value != '') score++;
    }

    if (score == needed) return true;
    else {
        alert('Please be sure to complete all fields marked with an asterisk (*). These fields are required for all administrators.'); 
        return false;
    }

}


// Validate required form fields for adding a new article

function validate_newsarticle() {

    var score = 0; var needed = 0;
    needed++; if (document.forms[0].title.value != '') score++;
    needed++; if (document.forms[0].intro.value != '') score++;
    needed++; if (document.forms[0].article.value != '') score++;
    needed++; if (document.forms[0].status.value != '') score++;

    if (score == needed) return true;
    else {
        alert('Please be sure to complete all fields. News articles cannot be posted without the required information.'); 
        return false;
    }

}


// Validate required form fields for adding a new event

function validate_event() {

    var score = 0; var needed = 0;
    needed++; if (document.forms[0].title.value != '') score++;
    needed++; if (document.forms[0].type.value != '') score++;
    needed++; if (document.forms[0].eventdateday.value != '') score++;
    needed++; if (document.forms[0].eventdatemonth.value != '') score++;
    needed++; if (document.forms[0].eventdateyear.value != '') score++;
    needed++; if (document.forms[0].eventtime.value != '') score++;
    needed++; if (document.forms[0].summary.value != '') score++;
    needed++; if (document.forms[0].venue.value != '') score++;
    needed++; if (document.forms[0].eventdescription.value != '') score++;

    if (score == needed) return true;
    else {
        alert('Please be sure to complete all fields. News articles cannot be posted without the required information.'); 
        return false;
    }

}

// Validate required form fields for adding a new job

function validate_job() {

    var score = 0; var needed = 0;
    needed++; if (document.forms[0].title.value != '') score++;
    needed++; if (document.forms[0].intro.value != '') score++;
    needed++; if (document.forms[0].detail.value != '') score++;

    if (score == needed) return true;
    else {
        alert('Please be sure to complete all fields. Jobs cannot be posted without the required information.'); 
        return false;
    }

}

// Validate required form fields for adding a new link category

function validate_linkcat() {

    var score = 0; var needed = 0;
    needed++; if (document.forms[0].title.value != '') score++;
    needed++; if (document.forms[0].description.value != '') score++;

    if (score == needed) return true;
    else {
        alert('Please be sure to complete all fields. Link categories cannot be posted without the required information.'); 
        return false;
    }

}

// Validate required form fields for adding a new document category

function validate_doccat() {

    var score = 0; var needed = 0;
    needed++; if (document.forms[0].title.value != '') score++;

    if (score == needed) return true;
    else {
        alert('Please be sure to supply a title. Document categories cannot be posted without this.'); 
        return false;
    }

}

// Validate required form fields for adding a new RSS feed

function validate_rssfeed() {

    var score = 0; var needed = 0;
    needed++; if (document.forms[0].title.value != '') score++;
    needed++; if (document.forms[0].sitelink.value != '') score++;
    needed++; if (document.forms[0].source.value != '') score++;

    if (score == needed) return true;
    else {
        alert('Please be sure to complete all fields. RSS feeds cannot be added without the required information.'); 
        return false;
    }

}

// Validate required form fields for adding a new podcast

function validate_podcast() {

    var score = 0; var needed = 0;
    needed++; if (document.forms[0].title.value != '') score++;
    needed++; if (document.forms[0].description.value != '') score++;
    needed++; if (document.forms[0].link.value != '') score++;

    if (score == needed) return true;
    else {
        alert('Please be sure to complete all fields. Podcasts cannot be added without the required information.'); 
        return false;
    }

}

