﻿
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function abre_jan(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
 //close layer
var d = document;

function divabre() {
	clearTimeout(tid);
	divclipTo(110);
}

function divfecha() {
	tid = setTimeout("tiddivfecha()",100);
	// divclipTo(65);
}

function tiddivfecha() {
	divclipTo(120);
}	

var tid = 0;

function divclipTo(num) {
	objDiv = divgetObj('divBarratop');
	objDiv.clip='rect(0,132,'+num+',0)';
}
function divgetObj(str) {
	if (d.layers){
		return d.layers[str];
	} else if (d.all && !d.getElementById) {
		return d.all[str].style;
	} else {
		return d.getElementById(str).style;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function divSecreto(divN){
	var elem = document.getElementById(divN);
	if (screen.width>800)
	{
		elem.style.display = "";
	}
	else
	{
		elem.style.display = "none";
	}
}

self.name='main';

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function go()
{
var a = window. open('','','scrollbars=yes,width=300,height=300');
a.document.open("text/html");
a.document.write('<html><head><link rel="stylesheet" href="css/css.css" /><style type="text/css">#frame{background-image:none;background-color:#FFFFFF;}</style></head><body style="padding-left:20px;background-image:none;background-color:#FFFFFF;">');
a.document.write('<div align="center" style="margin-bottom:25px"><b>Igreja Metodista Wesleyana - Terceira Regi&atilde;o Eclesi&aacute;stica</b></div>');
a.document.write(document.getElementById('impressao').innerHTML);
a.document.write('</body></html>');
a.document.close();
a.print();
a.window.close()
}

var ieBlink = (document.all)?true:false;
function doBlink(){
	if(ieBlink){
		obj = document.getElementsByTagName('BLINK');
		for(i=0;i<obj.length;i++){
			tag=obj[i];
			tag.style.visibility=(tag.style.visibility=='hidden')?'visible':'hidden';
		}
	}
}

function checkRequired(forma)
	{
		var frm = document.getElementById(forma);
		var num_patt = /^[0-9]{1,9}$/;
		var mail_patt = /^[A-Za-z][\w-\.]*\@[A-Za-z0-9]+(\.[\w-]+)*\.[A-Za-z]{2,3}$/;

		var fields = ['usuario', 'senha', 'senha_2', 'Nome', 'Sexo', 'denominacao', 'Regiao', 'endereco', 'CEP', 'Cidade', 'pais'];

		for(var i=0; i<fields.length; i++)
		{
			if (frm[fields[i]].value == '')
			{
				alert ('Todos os campos com * devem ser preenchidos');
				frm[fields[i]].focus();
				return false;
			}
		}

		if (!mail_patt.test(frm['usuario'].value)) {
				alert ('E-mail inválido');
				frm['usuario'].focus();
				return false;
		}


		return true;
	}
	
function checkRequired1(newsletter)
	{
		var frm = document.getElementById(newsletter);
		var num_patt = /^[0-9]{1,9}$/;
		var mail_patt = /^[A-Za-z][\w-\.]*\@[A-Za-z0-9]+(\.[\w-]+)*\.[A-Za-z]{2,3}$/;

		var fields = ['email'];

		for(var i=0; i<fields.length; i++)
		{
			if (frm[fields[i]].value == '')
			{
				alert ('O campo e-mail deve ser preenchido');
				frm[fields[i]].focus();
				return false;
			}
		}

		if (!mail_patt.test(frm['email'].value)) {
				alert ('E-mail inválido');
				frm['email'].focus();
				return false;
		}


		return true;
	}
	
function valida_form() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=valida_form.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
	if (val) { nm=val.name; if ((val=val.value)!="") {
	  if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
		if (p<1 || p==(val.length-1)) errors+='O campo '+nm+' precisa ser um e-mail válido.\n';
	  } else if (test!='R') { num = parseFloat(val);
		if (isNaN(val)) errors+='O campo '+nm+' precisa ser um número.\n';
		if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
		  min=test.substring(8,p); max=test.substring(p+1);
		  if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
	} } } else if (test.charAt(0) == 'R') errors += 'O campo '+nm+' é obrigatório.\n'; }
  } if (errors) alert('O(s) seguinte(s) erro(s) ocorreu(ram):\n\n'+errors);
  document.VF_returnValue = (errors == '');
}