function ceponly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else
   return false;
}




function validacnpj(Campo){
var i;
var Valida=true;
var s = Campo;
var c = s.substr(0,12);
var dv = s.substr(12,2);
var d1 = 0;
for (i = 0; i < 12; i++){d1 += c.charAt(11-i)*(2+(i % 8));}
if (d1 == 0) Valida=false;
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(0) != d1){Valida=false;}
d1 *= 2;
for (i = 0; i < 12; i++){d1 += c.charAt(11-i)*(2+((i+1) % 8));}
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(1) != d1){Valida=false;}
return Valida; 
}


function validacpf(cpf){  
// ******* Verifico se os números digitados são iguais ********
// sem está verificação, se os números forem iguais aparecerá que o CPF é válido
  iguais = true;
  for(i=0; i<=9; i++) {
    if(cpf.charAt(i) != cpf.charAt(i+1)) {
      iguais = false;
      break;
    }
  }
// ************************************************************
  subtot1 = 0
  subtot2 = 0
 	 for(n=0; n <= 8; n++) {
	    n1 = parseInt(cpf.charAt(n)) * (n + 1);
	    subtot1 = subtot1 + n1; // mesma coisa que sbtot1 += n1
	    n2 = parseInt(cpf.charAt(n+1)) * (n+1);
	    subtot2 = subtot2 + n2;
 	}
	 resto1 = subtot1 % 11;// pegando o resto da divisão
	 resto2 = subtot2 % 11;
	 if(resto1 == 10) resto1 = 0;
	 if(resto2 == 10) resto2 = 0;
	 resto1 = resto1.toString();
	 resto2 = resto2.toString();
	 if(resto1 == cpf.charAt(9) && resto2 == cpf.charAt(10) && iguais == false) {
	 	Valida=true;
	 }
	 else {
	 	Valida=false;
	 }
 return Valida;  
}




function validadata(pStr)
{
reDate = /^\d{2}\/\d{2}\/\d{4}$/;
	if (reDate.test(pStr) && pStr.length>0) {
		if(parseInt(pStr.substring(0,2))<=31 && parseInt(pStr.substring(3,5))<=12 && parseInt(pStr.substring(6,10))<=2050 && parseInt(pStr.substring(6,10))>=1900 )
		{return true;}else{return false;}
	} else{return false;}
} 





function validaemail(pStr)
{
reEmail = /^[\w!#$%&*+\/=?^`{|}~-]+(\.[\w!#$%&*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
if (reEmail.test(pStr) && pStr.length>0) {return true;} else{return false;}
}

function Val(field,tipo)
{
if (tipo=="txt")pat=/[0-9]/;
if (tipo=="num")pat=/[^0-9]/;
if (tipo=="tel")pat=/[^0-9\-]/;
if (tipo=="dt")pat=/[^0-9\/]/;
if (tipo=="dec")pat=/[^0-9\,]/;
idx = field.value.search( pat );
while ( idx > -1 ) {field.value = field.value.replace( pat, '' ); idx = field.value.search( pat );}
}


function formCheckLogin(formobj){
/*Nome dos Campos*/var fieldRequired = Array("email","senha");
/* Nome p/ Exibição*/var fieldDescription = Array("E-mail","Senha");
var alertMsg = "";
for (var i = 0; i < fieldRequired.length; i++){
	var obj = formobj.elements[fieldRequired[i]];
	if (obj){
	switch(obj.type){//Um case pra cada tipo de campo
	case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
	}
	}
}
if (alertMsg!=""){alert("Os seguintes campos são obrigatórios:\n" + alertMsg);return false;}else{return true;}
//EXTRas - Não vazios, mas inválidos --------------------^
}


function formCheck(formobj){
/*Nome dos Campos*/var fieldRequired = Array("Email","Senha");
/* Nome p/ Exibição*/var fieldDescription = Array("E-mail","Senha");
var alertMsg = "";
for (var i = 0; i < fieldRequired.length; i++){
	var obj = formobj.elements[fieldRequired[i]];
	if (obj){
	switch(obj.type){//Um case pra cada tipo de campo
	case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
	}
	}
}
if (alertMsg!=""){alert("Os seguintes campos são obrigatórios:\n" + alertMsg);return false;}else{return true;}
//EXTRas - Não vazios, mas inválidos --------------------^
}


function formCheckPedido(formobj){
// Nome dos Campos
var fieldRequired = Array("Mensagem");
// Nomes para Exibição
var fieldDescription = Array("Mensagem");

var alertMsg = "";
for (var i = 0; i < fieldRequired.length; i++){
	var obj = formobj.elements[fieldRequired[i]];
	if (obj){
	switch(obj.type){//Um case pra cada tipo de campo
	case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
	}
	}
}
//EXTRas - Não vazios, mas inválidos --------------------v
//EXTRAS - Não brancos, mas inválidos --------------------^

if (alertMsg!=""){alert("O seguinte campo é obrigatório:\n" + alertMsg);return false;}else{return true;}
}	


function formCheckBusca(formobj){
	// Nome dos Campos
	var fieldRequired = Array("busca","por");
	// Nomes para Exibição
	var fieldDescription = Array("busca","livros ou teses ou artigos");
	
	var alertMsg = "";
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
		switch(obj.type){//Um case pra cada tipo de campo
		case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
		}
		}
	}
	//EXTRas - Não vazios, mas inválidos --------------------v
	if(formobj.busca.value== "Palavra-chave, Título, Autor, ISBN"){alertMsg += " - busca\n";}
	//EXTRAS - Não brancos, mas inválidos --------------------^
	if (alertMsg!=""){alert("O seguinte campo é obrigatório:\n" + alertMsg);return false;}else{return true;}
}


function limparPadrao(campo) {        
	if (campo.value == campo.defaultValue) 
	{
		campo.value = "";
	}
}


function escreverPadrao(campo) {        
	if (campo.value == "") 
	{
		campo.value = campo.defaultValue;
	}
}


function formCheckAvisoSelo(formobj){

/*Nome dos Campos*/var fieldRequired = Array("Nome","Sobrenome","Email");
/* Nome p/ Exibição*/var fieldDescription = Array("Nome","Sobrenome","E-mail");
var alertMsg = "";
for (var i = 0; i < fieldRequired.length; i++){
	var obj = formobj.elements[fieldRequired[i]];
	if (obj){
	switch(obj.type){//Um case pra cada tipo de campo
	case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
	}
	}
}
	//EXTRas - Não vazios, mas inválidos --------------------v
	if(formobj.Email.value != "" && validaemail(formobj.Email.value)==false){alertMsg += " - E-mail Inválido\n";}
	//EXTRAS - Não brancos, mas inválidos --------------------^

if (alertMsg!=""){alert("Os seguintes campos são obrigatórios:\n" + alertMsg);return false;}else{return true;}

}

function formCheckAvisoArtigo(formobj){

/*Nome dos Campos*/var fieldRequired = Array("Nome","Email");
/* Nome p/ Exibição*/var fieldDescription = Array("Nome","E-mail");
var alertMsg = "";
for (var i = 0; i < fieldRequired.length; i++){
	var obj = formobj.elements[fieldRequired[i]];
	if (obj){
	switch(obj.type){//Um case pra cada tipo de campo
	case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
	}
	}
}
	//EXTRas - Não vazios, mas inválidos --------------------v
	if(formobj.Email.value != "" && validaemail(formobj.Email.value)==false){alertMsg += " - E-mail Inválido\n";}
	//EXTRAS - Não brancos, mas inválidos --------------------^

if (alertMsg!=""){alert("Os seguintes campos são obrigatórios:\n" + alertMsg);return false;}else{return true;}

}

function formCheckContato(formobj){
	// Nome dos Campos
	var fieldRequired = Array("Nome","Instituicao","Email","EmailConfirma","Tel","CEP");
	// Nomes para Exibição
	var fieldDescription = Array("Nome completo","Instituição ou Empresa","E-mail","Confirmação do e-mail","Telefone","CEP");
	
	var alertMsg = "";
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
		switch(obj.type){//Um case pra cada tipo de campo
		case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
		}
		}
	}
	//EXTRas - Não vazios, mas inválidos --------------------v
	if(formobj.Email.value != "" && validaemail(formobj.Email.value)==false){alertMsg += " - E-mail Inválido\n";}
	
	if (formobj.Email.value != "" && formobj.EmailConfirma.value != ""){
	if (formobj.Email.value != formobj.EmailConfirma.value) {alertMsg += " - Confirmar E-mail Inválido\n";}
	
	if(formobj.CEP.value != "" && formobj.CEP.value.length<8){alertMsg += " - Cep Inválido\n";}
	} 
	//EXTRAS - Não brancos, mas inválidos --------------------^
	if (alertMsg!=""){alert("Os seguintes campos são obrigatórios:\n" + alertMsg);return false;}else{return true;}
	
}

function formCheckRecomendaProf(formobj){
	// Nome dos Campos
	var fieldRequired = Array("Nome", "Email","Titulo","Autor");
	// Nomes para Exibição
	var fieldDescription = Array("Nome", "E-mail","Título livro original","Autor");
	// Msg Superior
	var alertMsg = "Os seguintes campos são obrigatórios:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){var obj = formobj.elements[fieldRequired[i]];if (obj){switch(obj.type){	case "select-one":if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;case "select-multiple":if (obj.selectedIndex == -1){alertMsg += " - " + fieldDescription[i] + "\n";}break;case "text":case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;default:}if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}}}
	
	//EXTRas - Não vazios, mas inválidos --------------------v
	if(formobj.Email.value != "" && validaemail(formobj.Email.value)==false){alertMsg += " - E-mail Inválido\n";}
	//EXTRAS - Não brancos, mas inválidos --------------------^
	
	if (alertMsg.length == l_Msg){return true;}else{alert(alertMsg);return false;}
}	


function formCheckAvaliacaoProf(formobj){

/*Nome dos Campos*/var fieldRequired = Array("Nome","Email");
/* Nome p/ Exibição*/var fieldDescription = Array("Nome","E-mail");
var alertMsg = "";
for (var i = 0; i < fieldRequired.length; i++){
	var obj = formobj.elements[fieldRequired[i]];
	if (obj){
	switch(obj.type){//Um case pra cada tipo de campo
	case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
	default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
	}
	}
}
	//EXTRas - Não vazios, mas inválidos --------------------v
	if(formobj.Email.value != "" && validaemail(formobj.Email.value)==false){alertMsg += " - E-mail Inválido\n";}
	//EXTRAS - Não brancos, mas inválidos --------------------^

if (alertMsg!=""){alert("Os seguintes campos são obrigatórios:\n" + alertMsg);return false;}else{return true;}

}


function formCheckAutorProf(formobj){
	/*Nome dos Campos*/var fieldRequired = Array("Nome","Email","Titulo","Descricao");
	/*Nomes para Exibição*/var fieldDescription = Array("Nome","E-mail","Título da Obra","Descrição");
		
	var alertMsg = "";
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
		switch(obj.type){//Um case pra cada tipo de campo
		case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
		}
		}
	}
	//EXTRas - Não vazios, mas inválidos --------------------v
	if(formobj.Email.value != "" && validaemail(formobj.Email.value)==false){alertMsg += " - E-mail Inválido\n";}
	//EXTRAS - Não brancos, mas inválidos --------------------^

if (alertMsg!=""){alert("Os seguintes campos são obrigatórios:\n" + alertMsg);return false;}else{return true;}
}
	
	
function formCheckAvise(formobj){
	/*Nome dos Campos*/var fieldRequired = Array("Nome","Email");
	/*Nomes para Exibição*/var fieldDescription = Array("Nome","E-mail");
	
	var alertMsg = "";
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
		switch(obj.type){//Um case pra cada tipo de campo
		case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
		}
		}
	}
	//EXTRas - Não vazios, mas inválidos --------------------v
	if(formobj.Email.value != "" && validaemail(formobj.Email.value)==false){alertMsg += " - E-mail Inválido\n";}
	//EXTRAS - Não brancos, mas inválidos --------------------^

if (alertMsg!=""){alert("Os seguintes campos são obrigatórios:\n" + alertMsg);return false;}else{return true;}
}
	
	
function formCheckIndique(formobj){
	/*Nome dos Campos*/var fieldRequired = Array("Nome","Email","Amigo1","Email_Amigo1");
	/*Nomes para Exibição*/	var fieldDescription = Array("Nome","E-mail","Nome do Amigo","E-mail do Amigo");

	var alertMsg = "";
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
		switch(obj.type){//Um case pra cada tipo de campo
		case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
		}
		}
	}
	//EXTRas - Não vazios, mas inválidos --------------------v
	if(formobj.Email.value != "" && validaemail(formobj.Email.value)==false){alertMsg += " - E-mail Inválido\n";}
	if(formobj.Email_Amigo1.value != "" && validaemail(formobj.Email_Amigo1.value)==false){alertMsg += " - E-mail do Amigo Inválido\n";}
	//EXTRAS - Não brancos, mas inválidos --------------------^

if (alertMsg!=""){alert("Os seguintes campos são obrigatórios:\n" + alertMsg);return false;}else{return true;}
}	
	

function formCheckRecomendaLeitor(formobj){
	/*Nome dos Campos*/var fieldRequired = Array("Nome", "Email","Titulo","Autor");
	/*Nomes para Exibição*/var fieldDescription = Array("Nome", "E-mail","Título livro original","Autor");
	
		var alertMsg = "";
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
		switch(obj.type){//Um case pra cada tipo de campo
		case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
		}
		}
	}
	//EXTRas - Não vazios, mas inválidos --------------------v
	if(formobj.Email.value != "" && validaemail(formobj.Email.value)==false){alertMsg += " - E-mail Inválido\n";}
	//EXTRAS - Não brancos, mas inválidos --------------------^

if (alertMsg!=""){alert("Os seguintes campos são obrigatórios:\n" + alertMsg);return false;}else{return true;}

}	

function formCheckPreform(formobj){
	/*Nome dos Campos*/var fieldRequired = Array("Email","Senha");
	/* Nome p/ Exibição*/var fieldDescription = Array("E-mail","Senha");
	var alertMsg = "";
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
		switch(obj.type){//Um case pra cada tipo de campo
		case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
		}
		}
	}
	
	if (alertMsg!=""){alert("Os seguintes campos são obrigatórios:\n" + alertMsg);return false;}else{return true;}
	//EXTRas - Não vazios, mas inválidos --------------------^
}


function formCheckNovidade(formobj){
	// Nome dos Campos
	var fieldRequired = Array("Nome","Email");
	// Nomes para Exibição
	var fieldDescription = Array("Nome","E-mail");
	
	var alertMsg = "";
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
		switch(obj.type){//Um case pra cada tipo de campo
		case "select-one":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "select-multiple":if (obj.selectedIndex == -1 ||  obj.options[obj.selectedIndex].value == ""){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "text":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "password":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		case "textarea":if (obj.value == "" || obj.value == null){alertMsg += " - " + fieldDescription[i] + "\n";}break;
		default:if (obj.type == undefined){var blnchecked = false;for (var j = 0; j < obj.length; j++){if (obj[j].checked){blnchecked = true;}}if (!blnchecked){alertMsg += " - " + fieldDescription[i] + "\n";}}
		}
		}
	}
	//EXTRas - Não vazios, mas inválidos --------------------v
	if(formobj.Email.value != "" && validaemail(formobj.Email.value)==false){alertMsg += " - E-mail Inválido\n";}
	
	//EXTRAS - Não brancos, mas inválidos --------------------^
	if (alertMsg!=""){alert("Os seguintes campos são obrigatórios:\n" + alertMsg);return false;}else{return true;}
	
}


x=0;
function ApArea(){
if(x<9){M=eval('A' + (x+1) + '.style');
M.display='';x++;}}
function DpArea(){
if(x>0){M=eval('A' + x + '.style');
M.display='none';x--;}}


j=0;
function ApAutor(){
if(j<9){M=eval('M' + (j+1) + '.style');
M.display='';j++;}}
function DpAutor(){
if(j>0){M=eval('M' + j + '.style');
M.display='none';j--;}}