function ativamenu( subobj )
{
	subobj = document.getElementById( subobj );
	obj = subobj.parentNode;
	
	x = findPosX( obj );
	y = findPosY( obj );
	subobj.style.left = ( x + obj.offsetWidth ) + 'px';
	subobj.style.top  = y + 'px';
	subobj.style.display = 'block';
	subobj.style.whiteSpace = 'nowrap';
	w = subobj.offsetWidth;
	subobj.style.whiteSpace = '';
	subobj.style.display = 'none';
	subobj.style.width = w + 'px';
	obj.submenu = subobj;
	obj.onmouseout = function()
	{
		this.submenu.style.display = 'none';
	}
	obj.onmouseover = function()
	{
		this.submenu.style.display = 'block';
	}
}

function ativamenus()
{
	for( i = 1; i < 15; i++ )
	{
		if( document.getElementById( "submenu" + i ) )
			ativamenu( "submenu" + i );
	}
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function pub_flash( swf, w, h, trans ) {
	if( trans == null || trans == undefined ) trans = 0;
	document.write( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'">'+"\n" );
	document.write( '<param name="movie" value="'+swf+'" />'+"\n" );
	document.write( '<param name="quality" value="high" />'+"\n" );
	if( trans != 0 ) document.write( '<param name="wmode" value="transparent"></param>'+"\n" );
	document.write( '<param name="menu" value="false" />'+"\n" );
	document.write( '<embed src="'+swf+'" menu="false" quality="high"'+(trans!=0?' wmode="transparent"':'')+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></embed>'+"\n" );
	document.write( '</object>'+"\n" );
}

function chkemail( valor )
{
	valor = valor.toLowerCase();
	retorno = '';
	x = 0;
	arr = 0;
	for( c = 0; c < valor.length; c++ )
	{
		letra = asc( valor.substr( c, 1 ) );
		if( x == 0 )
		{
			if( ( letra >= 48 && letra <= 57 ) || ( letra >= 97 && letra <= 122 ) )
			{
				retorno = retorno + valor.substr( c, 1 );
				x = 1;
			}
		} else {
			if( ( letra >= 48 && letra <= 57 ) || ( letra >= 97 && letra <= 122 ) || ( letra == 46 ) || ( letra == 95 ) || ( letra == 64 ) )
			{
				if( ( letra == 64 ) && arr == 0 )
				{
					retorno = retorno + valor.substr( c, 1 );
					arr = 1;
				} else {
					if( !( letra == 46 && last == 46 ) && !( letra == 95 && last == 95 ) && !( letra == 46 && last == 64 ) )
					{
						if( x >= 1 ) retorno = retorno + valor.substr( c, 1 );
						x = x + 1;
					}
				}
			}
		}
		last = letra;
	}
	valor = retorno;
	retorno = '';  
	x = 0;
	pto = 0;
	for( c = ( valor.length - 1 ); c >= 0; c-- )
	{
		letra = asc( valor.substr( c, 1 ) );
		if( letra == 46 ) pto = 1;
		if( x == 0 )
		{
			if( ( letra >= 48 && letra <= 57 ) || ( letra >= 97 && letra <= 122 ) )
			{
				retorno = valor.substr( c, 1 ) + retorno;
				x = 1;
			}
		} else {
			if( ( letra >= 48 && letra <= 57 ) || ( letra >= 97 && letra <= 122 ) || ( letra == 46 ) || ( letra == 95 ) || ( letra == 64 ) )
			{
				if( x >= 1 ) retorno = valor.substr( c, 1 ) + retorno;
				x = x + 1;
			}
		}
	}
   	
	if( arr == 0 || pto == 0 ) retorno = '';
  	
	return retorno;

}

function sonumero( valor )
{
	retorno = '';
	for( c = 0; c < valor.length; c++ )
	{
		letra = asc( valor.substr( c, 1 ) );
		if( letra >= 48 && letra <= 57 ) retorno = retorno + valor.substr( c, 1 );
	}
	return retorno;
}

function asc(each_char)
{
	var n = 0;
	var char_str = ' !"#$%&' + "'" + '()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
	for (i = 0; i < char_str.length; i++)
	{
		if (each_char == char_str.substring(i, i+1)) break;
	}
	return i + 32;
}

function textmax( obj, max )
{
	str = obj.value;
	if( str.length > max ) obj.value = str.substring( 0, max );
}

function validaformcomissoes( obj )
{
	var erro = '';
	if( !erro && obj.nome.value.length <= 3 ) erro = 'Preencha corretamente o campo Nome';
	if( !erro && !obj.email.value ) erro = 'Preencha corretamente o campo E-mail';
	if( !erro && obj.mensagem.value.length <= 5 ) erro = 'Preencha corretamente o campo Mensagem';
	if( erro )
	{
		alert( erro );
		return false;
	}
	return true;
}

function validaformcontato( obj )
{
	var erro = '';
	if( !erro && obj.nome.value.length <= 3 ) erro = 'Preencha corretamente o campo Nome';
	if( !erro && !obj.email.value ) erro = 'Preencha corretamente o campo E-mail';
	if( !erro && obj.mensagem.value.length <= 5 ) erro = 'Preencha corretamente o campo Mensagem';
	if( erro )
	{
		alert( erro );
		return false;
	}
	return true;
}

function validacadastrese( obj )
{
	var erro = '';
	if( !erro && obj.nome.value.length <= 3 ) erro = 'Preencha corretamente o campo Nome';
	if( !erro && !obj.email.value ) erro = 'Preencha corretamente o campo E-mail';
	if( !erro && !obj.oab.value ) erro = 'Preencha corretamente o campo OAB com seu registro';
	if( erro )
	{
		alert( erro );
	} else {
		return confirm( "Confirma o cadastro do e-mail "+obj.email.value+" e Registro OAB "+obj.oab.value+" ?" );
	}
	return false;
}

function fotopopup( url, w, h )
{
	var nome = url.replace(/\//g,'_').replace(/\./,'_');
	window.open( url, nome, 'width='+(w+20)+',height='+(h+30)+',left=50,top=50' );
}

function jornaloab()
{
	if( window.screen )
	{
		var w = screen.availWidth;
		if( w < 1024 )
			alert( "Para melhor visualização do Jornal OAB, recomendamos a resolução de 1024x768. Clique em Ok para continuar" );
	}
	window.open( 'jornal/', 'jornaloab', 'width=1024,height=500,left=0,top=0,scrollbars=yes,scrolling=yes,fullscreen=yes,status=no,toolbar=no,menubar=no' );
}

function jornaloabfecha()
{
	window.close();
}