// JavaScript Document
function popup_noscroll(url, w, h)
{
var wtela = screen.width
var htela = screen.height
var wjanela = w
var hjanela = h

window.open(url,'','width='+wjanela+', height='+hjanela+', left='+(wtela-wjanela)/2+', top='+(htela-hjanela)/2+', scrollbars=no, status=no')
}
function fs_validar_campos(formulario) {		
	for (i=0;i<formulario.elements.length;i++) {
		if (formulario.elements[i].id.toLowerCase().toString() == 'obrigatorio' && formulario.elements[i].value.toString().length < 2) {
			alert('O campo ' + formulario.elements[i].label + ' é obrigatório.');
			formulario.elements[i].focus();
			return false;
		}
	}
	
 if (!fs_verificar_emails(formulario)) {
		return(false);
	} else {	
		popUpWindow('', 200, 200, 450, 211);
		return(true);	}
	
	
}
function Hide(id) {
	if( document.getElementsByName )
	{
		var divs = document.getElementsByName( id );
		if( divs && divs.length > 0 )
		{	
			for( i=0;i<divs.length;i++ )
			{
				divs[i].style.display = "none";
			}
		}		
	}
}


function Show(id) {
	if( document.getElementsByName )
	{
		var divs = document.getElementsByName( id );
		if( divs && divs.length > 0 )
		{	
			for( i=0;i<divs.length;i++ )
			{
				divs[i].style.display = "block";
			}
		}		
	}
}

function ShowHide(id) {
	if( document.getElementsByName )
	{
		var divs = document.getElementsByName( id );
		if( divs && divs.length > 0 )
		{	
			for( i=0;i<divs.length;i++ )
			{
				if ( divs[i].style.display == "none" )
				{
					divs[i].style.display = "block";
				}
				else
				{
					divs[i].style.display = "none" 	
				}
			}
		}		
	}
}
function fs_verificar_emails(formulario){
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
	for (z=0;z<formulario.elements.length;z++) {	
		if (formulario.elements[z].ATR_MAIL == 'OK') {			
			if (!filter.test(formulario.elements[z].value)) {
				alert('Preencha o campo ' + formulario.elements[z].label + ' corretamente.');
				formulario.elements[z].focus();
				return(false);
			}
		}
	}
	return(true);	
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popup1234', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
