/**
* VALIDAÇÃO DE FORMULÁRIO
*/
function ValidationFields(){

	//private setMessage
	this.setMessage = false;

	//private arrayFieldsName
	this.arrayFieldsName = new Array();

	//sendForm
	this.sendForm=function(formName){
		var form = eval('document.'+formName);
		this.setMessage = false;
		this.checkFields();
		if(this.setMessage==true){
			this.errorMessage();
		}else{
			form.submit();
			//alert('FOI');
		}
	};

	//addFields
	this.addFields=function(idObj){
		this.arrayFieldsName.push(idObj);
	};

	//checkFields
	this.checkFields=function(){
		if(this.arrayFieldsName.length>1){
			for(i=0;i<this.arrayFieldsName.length;i++){
				if(document.getElementById(this.arrayFieldsName[i]).value==''){
					this.setMessage = true;
				    this.setNullStyleFormElement(this.arrayFieldsName[i]);
				}
				else this.setValidStyleFormElement(this.arrayFieldsName[i]);
			}
		}
	};

	//setNullStyleFormElement
	this.setNullStyleFormElement=function(objId){
		document.getElementById(objId).style.borderColor="red";
	};

	//setValidStyleFormElement
	this.setValidStyleFormElement=function(objId){
		document.getElementById(objId).style.borderColor='';
	};

	//errorMessage
	this.errorMessage=function(){
		alert('OS CAMPOS MARCADOS EM VERMELHO DEVEM SER PREENCHIDOS!');
	};
}
