// Fun��o para Over dos Botoes

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Fun��o para validar os campos do formul�rio de contato
function validaform()
{
	var error = 0;
	if(document.form.nome.value == ""){
		alert("Digite seu nome.");
		error = 1;
		document.form.nome.focus();
	}
	
	if(error != 1 && document.form.email.value == ""){
		alert("Digite seu email.");
		error = 1;
		document.form.email.focus();
	}
	
	if(error != 1 && document.form.telefone.value == ""){
		alert("Digite seu Telefone para contato.");
		error = 1;
		document.form.telefone.focus();
	}
	
	if(error != 1 && document.form.mensagem.value == ""){
		alert("Digite sua Mensagem");
		error = 1;
		document.form.mensagem.focus();
	}
	
	if(error != 1 && document.form.nome.value != "" && document.form.email.value != "" &&
					document.form.telefone.value != "" && document.form.mensagem.value != ""){
		document.form.submit();
	}
}

//Função para validar os campos do formulário de contato
function validaCadastroDiplomando(theForm)
{
	if (isBlank(theForm.fldNome)){
		alert("Preencha o campo Nome.");
		theForm.fldNome.focus();
		return false;
	}
	if (theForm.fldCurso.value == 0){
		alert("Preencha o campo Curso.");
		theForm.fldCurso.focus();
		return false;
	}
	if (isBlank(theForm.fldColacao)){
		alert("Preencha o campo Data de Colação de Grau.");
		theForm.fldColacao.focus();
		return false;
	}
	if (isBlank(theForm.fldRg)){
		alert("Preencha o campo Nº da Identidade (RG).");
		theForm.fldRg.focus();
		return false;
	}
	if (isBlank(theForm.fldCpf)){
		alert("Preencha o campo CPF.");
		theForm.fldCpf.focus();
		return false;
	}
	if (isBlank(theForm.fldLogradouro)){
		alert("Preencha o campo Logradouro.");
		theForm.fldLogradouro.focus();
		return false;
	}
	if (isBlank(theForm.fldNumeroComplemento)){
		alert("Preencha o campo Número e Complemento.");
		theForm.fldNumeroComplemento.focus();
		return false;
	}
	if (isBlank(theForm.fldCep)){
		alert("Preencha o campo CEP.");
		theForm.fldCep.focus();
		return false;
	}
	if (isBlank(theForm.fldCidade)){
		alert("Preencha o campo Cidade.");
		theForm.fldCidade.focus();
		return false;
	}
	if (theForm.fldUf.value == 0){
		alert("Preencha o campo UF.");
		theForm.fldUf.focus();
		return false;
	}
	if (isBlank(theForm.fldFoneResidencial)){
		alert("Preencha o campo Telefone Residencial.");
		theForm.fldFoneResidencial.focus();
		return false;
	}
	if (isBlank(theForm.fldFoneCelular)){
		alert("Preencha o campo Teledone Celular.");
		theForm.fldFoneCelular.focus();
		return false;
	}
	if (isBlank(theForm.fldEmail)){
		alert("Preencha o campo Email.");
		theForm.fldEmail.focus();
		return false;
	}

	if (!isBlank(theForm.fldEmail)){				
		arroba = theForm.fldEmail.value.indexOf("@");
		ponto = theForm.fldEmail.value.indexOf(".");
		if (arroba == "-1" || ponto == "-1") { 
			alert("Email Invalido!");
			theForm.fldEmail.focus();
			return false;
		}
	}
	
	if (theForm.ckConcordo.checked == false){
	      alert("Para concluir o cadastro é preciso concordar com os termos do portal.");
	      theForm.ckConcordo.focus();
	      return false;
	}
	
	return true;
}

function validaContato(theForm){
	
    if (isBlank(theForm.nome)){
      alert("Preencha o campo Nome.");
      theForm.nome.focus();
      return false;}
	
    if (isBlank(theForm.telefone)){
      alert("Preencha o campo Telefone.");
      theForm.telefone.focus();
      return false;}
   	
	if (isBlank(theForm.email)){
		alert("Preencha o campo E-mail.");
		theForm.email.focus();
		return false;
	}
		
		if (!isBlank(theForm.email)){				
		arroba = theForm.email.value.indexOf("@");
		ponto = theForm.email.value.indexOf(".");
			if (arroba == "-1" || ponto == "-1") { 
			alert("E-mail Invalido!");
			theForm.email.focus();
		return false;}						
  		}	

	if (isBlank(theForm.empresa)){
	      alert("Preencha o campo Empresa.");
	      theForm.empresa.focus();
	      return false;}
	
    if (isBlank(theForm.mensagem)){
      alert("Preencha o campo Mensagem.");
      theForm.mensagem.focus();
      return false;}
	
    return true;
}


function isBlank(txtField){
	if (txtField.value)
	return (false);
	else
	return(true);
}

$(function(){
	  $("#fldColacao").datepicker({
	    dateFormat: 'dd/mm/yy',
	    dayNames: [
	    'Domingo','Segunda','Terçaa','Quarta','Quinta','Sexta','Sábado','Domingo'
	    ],
	    dayNamesMin: [
	    'D','S','T','Q','Q','S','S','D'
	    ],
	    dayNamesShort: [
	    'Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'
	    ],
	    monthNames: [
	    'Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro',
	    'Outubro','Novembro','Dezembro'
	    ],
	    monthNamesShort: [
	    'Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set',
	    'Out','Nov','Dez'
	    ],
	    nextText: 'Próximo',
	    prevText: 'Anterior'
	  });
	});

function abrir(URL) {

  var width = 650;
  var height = 350;
  
  var left = 99;
  var top = 99;

  window.open(URL,'janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
