// JavaScript Document
<!--

var CR = '%0D%0A';
var tamTop = 30;
var wSobra = 90;
var hSobra = 130;


//Adiciona favorito (no Explorer ou no Firefox)
function _addBookmark( title, url ) 
{
	if (window.sidebar) 
	{ 
		window.sidebar.addPanel( title, url, "" ); 		
	} else 
	if( document.all ) 
	{
		window.external.AddFavorite( url, title);
	} else 
	if( window.opera && window.print ) 
	{
		return true;
	}
}


//Substitui, em uma string, uma substring por outra
function strSubst( txt, c1, c2 )
{
	achou = txt.indexOf(c1);
	while ( achou >= 0 )
	{
		txt = txt.substring( 0, achou ) + c2 + txt.substring( achou + 1, txt.length );
		achou = txt.indexOf(c1);
	}
	return txt;
}

//Adiciona um bookmark da página
function addbookmark()
{	if ( document.all )
		window.external.AddFavorite("http://www.davidayrolla.com.br/",'DavidAyrolla.com.br')
}

//Muda a cor do campo quando estiver com o foco
function CorComFoco( campo ) { campo.style.backgroundColor="#EEFFFF" }

//Muda a cor do campo quando perder o foco
function CorSemFoco( campo ) { campo.style.backgroundColor="#EEEEEE" }

//Abre uma janela estilo "popup" centralizada
function OpenDialog( url )
{
	var w      = 600;
	var h      = 400;	
	var _height = window.screen.height - tamTop;
	var _width  = window.screen.width;
	var _top    = ( _height - h ) / 2;
	var _left   = ( _width  - w ) / 2;
	return window.open( url,'','top=' + _top + ',left=' + _left + ',width=' + w + ',height=' + h + ',menubar=no,directories=no,location=no,toolbar=no,resizable,scrollbars');	
}

//Liga/Desliga tonalidades de cinza
function Cinza( objeto, estado )
{
	if ( estado == 0 )
	{
		objeto.style.filter = 'none'	;
	}
	else
	{
		objeto.style.filter = 'alpha(opacity=50) gray';
	}
}


//Liga/Desliga trasnaparência do index
function Transparente( objeto, estado )
{
	if ( estado == 0 )
	{
		objeto.style.filter = 'none'	;
	}
	else
	{
		objeto.style.filter = 'alpha(opacity=65)';
	}
}


//Abre uma janela de imagem
function ExibeImagem( secao, nomeimagem, titulo, descricao )
{
	iHeight = window.screen.height - 100;
	iWidth = window.screen.width - 30;
	iTop = 0;
	iLeft = 0;

	janela = window.open( '','','width=' + iWidth + ',height=' + iHeight + ',top=' + iTop + ',left=' + iLeft + ',menubar=no,directories=no,location=no,toolbar=no,resizable=no,scrollbars,status=yes' );	
	janela.document.write( "<HTML><HEAD><TITLE>" + secao + " - " + titulo + "</TITLE>\r\n" );
	janela.document.write( "<SCRIPT language='javascript' src='code.js'></script>" );
	janela.document.write( "</HEAD>");
	janela.document.write( "<BODY topMargin=0 leftMargin=0 marginwidth=0 marginheight=0 bgcolor='white'><CENTER><BR>" );
	janela.document.write( "<IMG SRC='" + nomeimagem + "' name='imagem' border='0'>" );
	janela.document.write( "<BR><BR><HR><font face='Verdana' size=1>" + descricao + "<BR><BR>" );
    janela.document.write( "<b><a href='javascript:window.close();'>Fechar</a></b>" );
    janela.document.write( "</font></CENTER>" );
	
	//Se não é firefox nem opera...
	if( ( ! window.sidebar ) && ( ! window.opera ) )
	{
		janela.document.write( "<SCRIPT language='javascript'>MoveJan();</script>" );
	}		
	
	janela.document.write( "</BODY></HTML>" );
	
	//Se não é firefox nem opera...
	if( ( ! window.sidebar ) && ( ! window.opera ) )
	{	
		janela.document.location.reload( false );
	}	
	
}

function MoveJan( )
{
	w = window.document.images[0].width;
	h = window.document.images[0].height;
	if ( w > 0 )
	{ 
		_height = window.screen.height - tamTop;
		_width  = window.screen.width;
		_top    = ( ( _height - h ) / 2 ) - 50;
		_left   = ( ( _width  - w ) / 2 ) - 50;	
	    window.moveTo( _left, _top );
		window.resizeTo( w + wSobra, h + hSobra + 20 );			
	}
}