function goGreek() {

    var sURL, tURL, fURL;

    sURL = window.location.href;
    tURL = sURL.replace(/\/en\//, "/gr/");
    fURL = tURL.replace(/lang=en/, "lang=gr");

    window.location = fURL;


}

function goEnglish() {

    var sURL, tURL, fURL;

    sURL = window.location.href; 
    tURL = sURL.replace(/\/gr\//, "/en/");
    fURL = tURL.replace(/lang=gr/, "lang=en");

    window.location = fURL;

}


function isValidEmail(emailAddr) {

    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailAddr)){
        return true;
    }
    return false;
}

function validateContactForm(f, lang) {

    var Msg = "";

    if (f.firstname.value == "") {
        if (lang == "el") {
            Msg = "Παρακαλώ εισάγετε το όνομα σας.\n\n";
        }else{
            Msg = "Please enter your first name.\n\n";
        }
        f.firstname.focus();
        alert(Msg);
        return false;
    }

    if (f.lastname.value == "") {
        if (lang == "el") {
            Msg = "Παρακαλώ εισάγετε το επώνυμο σας.\n\n";
        }else{
            Msg = "Please enter your last name.\n\n";
        }
        f.lastname.focus();
        alert(Msg);
        return false;
    }

    if (f.email.value != "") {
        if (!isValidEmail(f.email.value)) {
            if (lang == "el") {
                Msg = "Το email που δώσατε δεν έχει την σωστή δομή. \nΤο email πρέπει είναι της μορφής π.χ. someone@somedomain.com\n\n";
            }else{
                Msg = "The email address you entered is not in the right format.\nEmail addresses must be in the form e.g. someone@somedomain.com.\n\n";
            }
            f.email.value = "";
            f.email.focus();
            alert(Msg);
            return false;
        }
    }else{
        if (lang == "el") {
            Msg = "Παρακαλώ εισάγετε το email σας.\n\n";
        }else{
            Msg = "Please enter your email address.\n\n";
        }
        f.email.focus();
        alert(Msg);
        return false;
    }

    if (f.comments.value == "") {
        if (lang == "el") {
            Msg = "Παρακαλώ εισάγετε τα σχόλια σας.\n\n";
        }else{
            Msg = "Please enter your comments.\n\n";
        }
        f.comments.focus();
        alert(Msg);
        return false;
    }

    f.sendBtn.disabled=true;
    f.resetBtn.disabled=true;
    
    return true;

}

function validateMemberLogin(f) {

    if (f.userid.value == "") {
        alert("Please enter your username.\n");
        f.userid.focus();
        return false;
    }else{
        if (!(/^[\w\d]+$/.test(f.userid.value))) {
            alert("The username you have entered is invalid. Usernames must be alphanumeric.\n");
            f.userid.value = '';
            f.userid.focus();
            return false;
        }
    }

    if (f.pwd.value == "") {
        alert("Please enter your password.\n");
        f.pwd.focus();
        return false;
    }else{
        if (/[\s]+/.test(f.pwd.value)) {
            alert("The password you entered is invalid. Passwords cannot contain whitespaces.\n");
            f.pwd.value = '';
            f.pwd.focus();
            return false;
        }
    }

    alert("The system could not log you in because the login credentials you supplied could not be verified.\n");
    return false;

}
