
$(document).ready(function(){


// #########################################################################################################
// #########################################################################################################
// #########################################################################################################
	
	// Place ID's of all required fields here.
	requiredFORM_CONTATO = ["oep","nome","ddd","telefone","cidade","email","mensagem"];
	// If using an ID other than #email or #error then replace it here
	email = $("#email");
	errornotice = $("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Preencha este campo";
	emailerror = "E-mail incorreto";

	$("#FORM_CONTATO").submit(function(){	
		//Validate required fields
		for (i=0;i<requiredFORM_CONTATO.length;i++) {
			var input = $('#'+requiredFORM_CONTATO[i]);
			if ((input.val() == "") || (input.val() == emptyerror)) {
				input.addClass("needsfilled");
				input.val(emptyerror);
				errornotice.fadeIn(750);
			} else {
				input.removeClass("needsfilled");
			}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val(emailerror);
		}

		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});
	
						   
	
// #########################################################################################################
// #########################################################################################################
// #########################################################################################################
	
	// Place ID's of all required fields here.
	requiredFORM_ARTIGOJURIDICO = ["nome","ddd","telefone","cidade","email","mensagem"];
	// If using an ID other than #email or #error then replace it here
	email = $("#email");
	errornotice = $("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Preencha este campo";
	emailerror = "E-mail incorreto";

	$("#FORM_ARTIGOJURIDICO").submit(function(){	
		//Validate required fields
		for (i=0;i<requiredFORM_ARTIGOJURIDICO.length;i++) {
			var input = $('#'+requiredFORM_ARTIGOJURIDICO[i]);
			if ((input.val() == "") || (input.val() == emptyerror)) {
				input.addClass("needsfilled");
				input.val(emptyerror);
				errornotice.fadeIn(750);
			} else {
				input.removeClass("needsfilled");
			}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val(emailerror);
		}

		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});
	
	
// #########################################################################################################
// #########################################################################################################
// #########################################################################################################
	
	// Place ID's of all required fields here.
	requiredFORM_TRABALHE = ["nome","ddd","telefone","bairro","cidade","email","mensagem","curriculo"];
	// If using an ID other than #email or #error then replace it here
	email = $("#email");
	errornotice = $("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Preencha este campo";
	emailerror = "E-mail incorreto";

	$("#FORM_TRABALHE").submit(function(){	
		//Validate required fields
		for (i=0;i<requiredFORM_TRABALHE.length;i++) {
			var input = $('#'+requiredFORM_TRABALHE[i]);
			if ((input.val() == "") || (input.val() == emptyerror)) {
				input.addClass("needsfilled");
				input.val(emptyerror);
				errornotice.fadeIn(750);
			} else {
				input.removeClass("needsfilled");
			}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val(emailerror);
		}

		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});


// #########################################################################################################
// #########################################################################################################
// #########################################################################################################
	
	// Place ID's of all required fields here.
	requiredFORM_SUGERIR = ["nome","ddd","telefone","cidade","email","mensagem"];
	// If using an ID other than #email or #error then replace it here
	email = $("#email");
	errornotice = $("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Preencha este campo";
	emailerror = "E-mail incorreto";

	$("#FORM_SUGERIR").submit(function(){	
		//Validate required fields
		for (i=0;i<requiredFORM_SUGERIR.length;i++) {
			var input = $('#'+requiredFORM_SUGERIR[i]);
			if ((input.val() == "") || (input.val() == emptyerror)) {
				input.addClass("needsfilled");
				input.val(emptyerror);
				errornotice.fadeIn(750);
			} else {
				input.removeClass("needsfilled");
			}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val(emailerror);
		}

		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});
	
	
// #########################################################################################################
// #########################################################################################################
// #########################################################################################################
	
	// Place ID's of all required fields here.
	requiredFORM_SENHACORTESIA = ["nome","ddd","telefone","cidade","email","mensagem"];
	// If using an ID other than #email or #error then replace it here
	email = $("#email");
	errornotice = $("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Preencha este campo";
	emailerror = "E-mail incorreto";

	$("#FORM_SENHACORTESIA").submit(function(){	
		//Validate required fields
		for (i=0;i<requiredFORM_SENHACORTESIA.length;i++) {
			var input = $('#'+requiredFORM_SENHACORTESIA[i]);
			if ((input.val() == "") || (input.val() == emptyerror)) {
				input.addClass("needsfilled");
				input.val(emptyerror);
				errornotice.fadeIn(750);
			} else {
				input.removeClass("needsfilled");
			}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val(emailerror);
		}

		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});
	

// #########################################################################################################
// #########################################################################################################
// #########################################################################################################
	
	// Place ID's of all required fields here.
	requiredFORM_RESPONDAEGANHE = ["oep","departamento","cargo","temas","publicoalvo","locais","meses","nome","ddd","telefone","cidade","email"];
	// If using an ID other than #email or #error then replace it here
	email = $("#email");
	errornotice = $("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Preencha este campo";
	emailerror = "E-mail incorreto";

	$("#FORM_RESPONDAEGANHE").submit(function(){	
		//Validate required fields
		for (i=0;i<requiredFORM_RESPONDAEGANHE.length;i++) {
			var input = $('#'+requiredFORM_RESPONDAEGANHE[i]);
			if ((input.val() == "") || (input.val() == emptyerror)) {
				input.addClass("needsfilled");
				input.val(emptyerror);
				errornotice.fadeIn(750);
			} else {
				input.removeClass("needsfilled");
			}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val(emailerror);
		}

		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});


// #########################################################################################################
// #########################################################################################################
// #########################################################################################################
	
	// Place ID's of all required fields here.
	requiredFORM_INCOMPANY = ["oep","contato","cnpj","responsavel","setor","carga_horaria","participantes","mensagem","ddd","telefone","cidade","email"];
	// If using an ID other than #email or #error then replace it here
	email = $("#email");
	errornotice = $("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Preencha este campo";
	emailerror = "E-mail incorreto";

	$("#FORM_INCOMPANY").submit(function(){	
		//Validate required fields
		for (i=0;i<requiredFORM_INCOMPANY.length;i++) {
			var input = $('#'+requiredFORM_INCOMPANY[i]);
			if ((input.val() == "") || (input.val() == emptyerror)) {
				input.addClass("needsfilled");
				input.val(emptyerror);
				errornotice.fadeIn(750);
			} else {
				input.removeClass("needsfilled");
			}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val(emailerror);
		}

		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});
	
	
// #########################################################################################################
// #########################################################################################################
// #########################################################################################################
	
	// Place ID's of all required fields here.
	requiredFORM_EDITORA = ["oep","contato","cnpj","responsavel","setor","mensagem","ddd","telefone","cidade","email"];
	// If using an ID other than #email or #error then replace it here
	email = $("#email");
	errornotice = $("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Preencha este campo";
	emailerror = "E-mail incorreto";

	$("#FORM_EDITORA").submit(function(){	
		//Validate required fields
		for (i=0;i<requiredFORM_EDITORA.length;i++) {
			var input = $('#'+requiredFORM_EDITORA[i]);
			if ((input.val() == "") || (input.val() == emptyerror)) {
				input.addClass("needsfilled");
				input.val(emptyerror);
				errornotice.fadeIn(750);
			} else {
				input.removeClass("needsfilled");
			}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val(emailerror);
		}

		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});	


// #########################################################################################################
// #########################################################################################################
// #########################################################################################################
	
	// Place ID's of all required fields here.
	requiredFORM_WEB = ["Solicitante","DDD","Telefone","Email","Mensagem"];
	// If using an ID other than #email or #error then replace it here
	email = $("#Email");
	errornotice = $("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Preencha este campo";
	emailerror = "E-mail incorreto";

	$("#FORM_WEB").submit(function(){	
		//Validate required fields
		for (i=0;i<requiredFORM_WEB.length;i++) {
			var input = $('#'+requiredFORM_WEB[i]);
			if ((input.val() == "") || (input.val() == emptyerror)) {
				input.addClass("needsfilled");
				input.val(emptyerror);
				errornotice.fadeIn(750);
			} else {
				input.removeClass("needsfilled");
			}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val(emailerror);
		}

		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});	



// #########################################################################################################
// #########################################################################################################
// #########################################################################################################
	
	// Place ID's of all required fields here.
	requiredFORM_REVISTA_IMPRESSA = ["Solicitante","DDD","Telefone","Email","Mensagem"];
	// If using an ID other than #email or #error then replace it here
	email = $("#Email");
	errornotice = $("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Preencha este campo";
	emailerror = "E-mail incorreto";

	$("#FORM_REVISTA_IMPRESSA").submit(function(){	
		//Validate required fields
		for (i=0;i<requiredFORM_REVISTA_IMPRESSA.length;i++) {
			var input = $('#'+requiredFORM_REVISTA_IMPRESSA[i]);
			if ((input.val() == "") || (input.val() == emptyerror)) {
				input.addClass("needsfilled");
				input.val(emptyerror);
				errornotice.fadeIn(750);
			} else {
				input.removeClass("needsfilled");
			}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val(emailerror);
		}

		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});	



// #########################################################################################################
// #########################################################################################################
// #########################################################################################################
	
	// Place ID's of all required fields here.
	requiredFORM_CONSULTORIA = ["Solicitante","DDD","Telefone","Email","Mensagem"];
	// If using an ID other than #email or #error then replace it here
	email = $("#Email");
	errornotice = $("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Preencha este campo";
	emailerror = "E-mail incorreto";

	$("#FORM_CONSULTORIA").submit(function(){	
		//Validate required fields
		for (i=0;i<requiredFORM_CONSULTORIA.length;i++) {
			var input = $('#'+requiredFORM_CONSULTORIA[i]);
			if ((input.val() == "") || (input.val() == emptyerror)) {
				input.addClass("needsfilled");
				input.val(emptyerror);
				errornotice.fadeIn(750);
			} else {
				input.removeClass("needsfilled");
			}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val(emailerror);
		}

		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});	

// #########################################################################################################
// #########################################################################################################
// #########################################################################################################

	
	// Clears any fields in the form when the user clicks on them
	$(":input").focus(function(){		
	   if ($(this).hasClass("needsfilled") ) {
			$(this).val("");
			$(this).removeClass("needsfilled");
	   }
	});
});	
