/*#########################################################

    IDENTIFICA O BROWSER 

###########################################################*/

function Is() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.minor < 4.04));
    this.ns4 = (this.ns && (this.major >= 4));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie4  = (this.ie && (this.major >= 4));
    this.op3 = (agent.indexOf("opera") != -1);
}

var is = new Is();

/*#########################################################

    SELECIONA O "DOCUMENT OBJECT" conforme o browser
	NS4 / IE4

###########################################################*/

if(is.ns4) {
    doc = "document";
    sty = "";
    htm = ".document"
    xpos = "e.contentX";
    ypos = "e.contentY";
} else if(is.ie4) {
    doc = "document.all";
    sty = ".style";
    htm = ""
    xpos = "event.x";
    ypos = "event.y";
}

/*#########################################################
	
		Msgbox

###########################################################*/

   function msg(mensagem)
	{
	alert(mensagem);

	}
	

/*#########################################################
	
	Troca Imagem com várias frames

###########################################################*/

  function chgf(imagem,ficheiro,nome_frame)
	{
	tmp = eval("parent." + [nome_frame] + ".document." + [imagem]);
	tmp.src = ficheiro;
	}

/*#########################################################
	
	Troca Imagem na mesma página

###########################################################*/

  function chg(imagem,ficheiro)
	{
	if (document.images)
		{
		document.images[imagem].src=ficheiro.src;	
		}
	}

/*#########################################################
	
		Instala Folha de Estilo NS4 / IE4
			( Conforme o Browser )
###########################################################*/

function FolhaEstilo(path)
	{
	if(is.ns4) 
		{
	 	document.write('<LINK REL=StyleSheet HREF="' + path + 'NS_cdm.css" TYPE="text/css">')
		// msg('Netscape')
		} 
	else
		{
		document.write ('<LINK REL=StyleSheet HREF="' + path + 'IE_cdm.css" TYPE="text/css">')
		// msg('Explorer')
		}
	}
	
/*#########################################################
	
	Abre Janela Pequena só com imagem 

	Utiliza a p&aacute;gina ASP imagem_g.asp
	- Se nao existir o nome da Imagem grande  na BD, retira "_p" &aacute; imagem pequena
	- Se nao existir tamanho na BD Utiliza o tamanho natural da Imagem
	Tipo=true - abre sempre na mesma janela ; false - em janelas diferentes
###########################################################*/
function imagem_grande(caminhoEimagem,tipo) 
{
	if (tipo)
	{
		Window_nome = "nome"
	}
	else
	{
		Window_nome=""
	}
	var janela = window.open("imagem_g.asp?imagem=" + caminhoEimagem, Window_nome,"width=100,height=100,toolbar=0,menubar=0,location=0,directories=0,status=0,resizable=1,scrollbars=0");

}

function window_open(caminhoEimagem) 
{
	var janela = window.open(caminhoEimagem, "window","width=790,height=570,toolbar=0,menubar=0,location=0,directories=0,status=0,resizable=1,scrollbars=1");
	janela.moveTo('0','0');
}
/*#########################################################
	
	Mensagem na Barra de Status

###########################################################*/
// Copyright (c) 1996-1997 Tomer Shiran. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.geocities.com/~yehuda/
// stop the banner if it is currently running
function stopBanner() {
	// if banner is currently running
	if (bannerRunning)
		// stop the banner
		clearTimeout(timerID)

	// timer is now stopped
	bannerRunning = false
}

// start the banner
function startBanner() {
	// make sure the banner is stopped
	stopBanner()
	
	// start the banner from the current position
	showBanner()
}

// type-in the current message
function showBanner() {

	// assign current message to variable
	var text = ar[currentMessage]

	// if current message has not finished being displayed
	if (offset < text.length) {
		// if last character of current message is a space
		if (text.charAt(offset) == " ")
			// skip the current character
			offset++			

		// assign the up-to-date to-be-displayed substring
		// second argument of method accepts index of last character plus one
		var partialMessage = text.substring(0, offset + 1) 

		// display partial message in status bar
		window.status = partialMessage

		// increment index of last character to be displayed
		offset++ // IE sometimes has trouble with "++offset"

		// recursive call after specified time
		timerID = setTimeout("showBanner()", speed)

		// banner is running
		bannerRunning = true
	} else {
		// reset offset
		offset = 0

		// increment subscript (index) of current message
		currentMessage++

		// if subscript of current message is out of range
		if (currentMessage == ar.length)
			// wrap around (start from beginning)
			currentMessage = 0

		// recursive call after specified time
		timerID = setTimeout("showBanner()", pause)

		// banner is running
		bannerRunning = true
	}
}
