$(document).ready(function(){
	
	document.formLogin.name.focus();
	//***************************************************
	// Submit form check
	//***************************************************
	$("#formLogin").submit(function() {
        //Initialise variables
        var errorMsg = "";
        var errorMsgLong = "";

        //Function to check form is filled in correctly before submitting
    	//Check for username
    	if ($("#name").val() == ""){
    		errorMsg += "\n\tUsername \t- Enter your username";
    	}

        //Check for password
        if ($("#password").val().length < 6){
        	errorMsg += "\n\tPassword \t- Enter your password";
        }

        //If there is aproblem with the form then display an error
        if ((errorMsg != "") || (errorMsgLong != "")){
                msg = ""; //"_______________________________________________________________\n\n";
                msg += "The form has not been submitted because there are problem(s) with the form.\n";
                msg += "Please correct the problem(s) and re-submit the form.\n";
                msg += "_______________________________________________________________\n\n";
                msg += "The following field(s) need to be corrected: -\n";
                errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
                return false;
        }

        return true;
	});
});
	
