var allowedExtentions = new Array("doc","pdf","rtf","txt");

function isFilledOut() {
	var errormsg = "";
	var haserror = 0;
	frm=document.form1;
	
	if (frm.firstname.value.length == 0) {
		errormsg += "Please complete the FIRST NAME field. \n";
		haserror = 1;
	}
	
	if (frm.surname.value.length == 0) {
		errormsg += "Please complete the SURNAME field. \n";
		haserror = 1;
	}
	
	if (frm.email.value.length == 0) {
		errormsg += "Please complete the EMAIL field. \n";
		haserror = 1;
	}
	
	if (frm.nationality.value.length == 0) {
		errormsg += "Please complete the NATIONALITY field. \n";
		haserror = 1;
	}
	
	if (frm.telephone.value.length == 0) {
		errormsg += "Please complete the TELEPHONE field. \n";
		haserror = 1;
	}
	
	if (frm.cv.value.length > 0) {
		var filename = frm.cv.value;
		var strend = filename.length;
		var dotpos = filename.lastIndexOf('.');
		var ext = filename.substring(dotpos+1,strend);
		var valid = InArray(allowedExtentions, ext);
		
		if (!valid) {
			errormsg += "That CV file format is not supported. \n";
			haserror = 1;
		}
	}
	
	
	if (haserror == 1) {
		alert(errormsg);
	} else {
		frm.submit();
	}
	
}

function InArray(list, value)
{
    var i;
    for (i=0; i < list.length; i++) {
        if (list[i] === value) {
            return true;
        }
    }
    return false;
};