// JavaScript Document
	function required(inputName,form,contract,typeReturn,photo,inputCheck,allowedTypes){
		
		action = "";
		
		if( inputName == "" )
			inputName = getInputs();	
		else
			inputName = inputName;

 		arrData = inputName.split(",");
		
		d = document.getElementById;
		msg = ""
		quantMsg = 0;
		control = 0;
		
	//Função para verificar se o arquivo pode ser carregado;

	if(photo == 1){
	
		alloweds = allowedTypes.split(",");
		check = document.getElementById(inputCheck).value.substr( document.getElementById(inputCheck).value.length-3, 3 );
		breakPoint = 1;
		
			for( i = 0; i < alloweds.length; i++ ){
			
				if( check.toUpperCase() == alloweds[i].toUpperCase() ){
					
					breakPoint = 0;
				
				}else if( check == "" ){
				
					breakPoint = 2;
					
				}
				
			}
			
			if( breakPoint == 1 ){
				
				alert("Extensão \""+check+"\" não permitido para upload.<br />Selecione apenas arquivos com extensão: "+allowedTypes);
				return false;
				
			}else if( breakPoint == 2){
			
				alert("Não foi carregado nenhum arquivo.");
				return false;
			
			}else{
				
				action = 1;
			
		}

	}
	
//Fim da função

	if( contract == 1 ){
	
		if( document.getElementById("aceito").checked == false ){
			
			msg += '; Marque a opção: <strong>Concordo com o termo de responsabilidade</strong>';
			control = 1;
			quantMsg++;
			
		}
		
	}


	for( i = arrData.length-1; i > -1 ; i-- ){
		elem_obj = new Array();
		elem_obj = arrData[i].split(";");
		id = elem_obj[0];
		fieldName = elem_obj[1];
		
		type = document.getElementById(id).name.split("_");
		
		if( ( type[1] == "dat" ) && ( document.getElementById(id).value != "" ) ){
		
			if( !doDate(document.getElementById(id).value) ){
					
					msg += ';'+fieldName+' inválida';
					control = 1;
					quantMsg++;
			
			}
			
		}
		
		if( ( type[1] == "tel" ) && ( document.getElementById(id).value != "" ) ){
		
			if( document.getElementById(id).name == "mobilePhone_tel" )
				type = 2;
			else
				type = 1;
		
			if( !checkPhone( type , document.getElementById(id).value) ){
					
					msg += ';<strong>'+fieldName+'</strong> inválido';
					control = 1;
					quantMsg++;
			
			}
			
		}
		
		if( ( (document.getElementById(id).name == "mail_str") || (document.getElementById(id).name == "mail_aux") ) && document.getElementById(id).value != "" ){
		
			if( ( checkMail(document.getElementById(id).value)==false ) && (document.getElementById(id).value != "")){
				msg += ';E-mail inválido';
				control = 1;
				quantMsg++;
			}
		}
		
		if( ( (document.getElementById(id).name == "cpf_str") || (document.getElementById(id).name == "cpf_aux") ) && document.getElementById(id).value != "" ){
		
			if( document.getElementById(id).value != "" ){
				
				if ( ( valida_cpf(document.getElementById(id).value) == true ) || ( valida_cnpj(document.getElementById(id).value) == true ) ){
					msg += "";
				}else{
					msg += ';Cpf inválido';
					control = 1;
					quantMsg++;					
				}			
			}
		}
		
		if( document.getElementById(id).name == "password_str" && document.getElementById(id).value != "" ){
		
			if( document.getElementById(id).value.length < 6 ){
			
				msg +=';A senha deve conter no mínimo 6 caracteres';
				control = 1;
				quantMsg++;
			
			}else{
			
				if(document.getElementById(id).value != document.getElementById("confirmPassword_aux").value ){
					msg += ';Senha e confimação da senha devem ser idênticos';
					control = 1;
					quantMsg++;
				}
				
			}
		
		}
				
		if( document.getElementById(id).value == "" ){
			
			msg += ";" + "O campo <strong>" + fieldName + "</strong> não foi preenchido";
			
			control = 1;
			quantMsg++;
			
			//d(arrData[i].split(";")[0]).style.border='2px solid #999999'
			document.getElementById(id).focus();
		
		}
				
				
				
	}
			
		if( control == 1 ){
			
			if(quantMsg == 1 ){
				msgStart = "<strong>Foi encontrado o seguinte erro:</strong><br /><br />"; 
				msgFinal = "";
			}else{
				msgStart = "<strong>Foram encontrados os seguintes erros:</strong><br /><br />"; 
				msgFinal = "";
			}
			
			msgArr = msg.split(";");
			msg = ""
			c = 1;
			for(w = msgArr.length -1 ; w > 0 ; w--){
				msg+= c + " - " + msgArr[w] + ";<br />";
				c++;
			}
			
			msgOut = msgStart+msg+msgFinal
			
			if( typeReturn == 1 ){
				
				for( i = 0 ; i < 50 ; i++ ){
					
					msgOut = msgOut.replace("<br />","\n")
					msgOut = msgOut.replace("<strong>","")
					msgOut = msgOut.replace("</strong>","")					
				
				}
				
				alert(msgOut);
			
			}else{	
			
				document.getElementById("javascriptError").innerHTML = msgOut;
				document.getElementById("javascriptError").style.display = "block";
				window.scroll(0,200);
			
			}
			
			return false;
		
		}else{
		
			action += 1;
		
		}
		
		return true;

	}

