// COMMENTS

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };

var VarttiNameSpace = {
    validateAndSubmit: function (commentsform) {		
		commentsform._comments_WAR_vartti_comments_name.value = commentsform._comments_WAR_vartti_comments_name.value.trim(); 
		commentsform._comments_WAR_vartti_comments_message.value = commentsform._comments_WAR_vartti_comments_message.value.trim();
		
		if (commentsform._comments_WAR_vartti_comments_name.value=='' && 
		commentsform._comments_WAR_vartti_comments_message.value=='') {
			alert('Nimi ja kommentti eiv\u00E4t voi olla tyhji\u00E4');
			return;
		}
		else if (commentsform._comments_WAR_vartti_comments_name.value=='') {
			alert('Nimi ei voi olla tyhj\u00E4');
			return;
		}
		else if (commentsform._comments_WAR_vartti_comments_message.value=='') {
			alert('Kommentti ei voi olla tyhj\u00E4');
			return;
		}
		commentsform.submit();
    }
}
