img_on         = new Image(150,90);
img_on.src     = "/bcaimg/Arr.gif";
img_off         = new Image(150,90);
img_off.src     = "./../../bcncocv/home_arquivos/noArr.gif";

function aImg(obj){
	imgOn = eval("img_on.src");
	nome = obj.substr(0, obj.toString().length-1);
	var aux = document.getElementById(obj);
	aux.src = imgOn;
}

function dImg(obj){
	imgOn = eval("img_off.src");
	nome=obj.substr(0, obj.toString().length-1);
	var aux = document.getElementById(obj);
	aux.src = imgOn;
}

function Trim(String){
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for (i = 0; i < String.length; i++)
	{
		if (String.substr(i, 1) != ' ' &&
			String.substr(i, 1) != '\t')
			break;
	}

	for(j = String.length - 1; j >= 0; j--)
	{
		if (String.substr(j, 1) != ' ' &&
			String.substr(j, 1) != '\t')
		break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}

function submitPesquisa() {
	var termo = new String();
	termo = document.frmPesquisaGeral.PESQUISA_termo.value;

	if (termo.indexOf('%') > 0){
		alert('O termo para pesquisa não pode conter o caracter \'%\'');
		document.frmPesquisaGeral.PESQUISA_termo.focus();
		return;
	}
	if (termo == '') {
		alert('Introduza um termo para pesquisa');
		document.frmPesquisaGeral.PESQUISA_termo.focus();
		return false;
	}
	if (termo.length < 3) {
		alert(' Introduza, pelo menos 3 caracteres. ');
		document.frmPesquisaGeral.PESQUISA_termo.focus();
		return false;
	}

	document.frmPesquisaGeral.submit();
}

/* abre um canal e fecha os outros*/
function eXpand2(obj,id){
	//Compatible IE 6, Mozilla 1.4.1 , Firebird 0.6.1+
	for (i=1;i <= 100; i++){
		if(document.getElementById(obj+i) != null){
			if (document.all){
				if(i==id)
					document.getElementById(obj+i).style.display = (document.getElementById(obj+i).style.display == "none" ) ? "inline" : "none";
				else
					document.getElementById(obj+i).style.display = (document.getElementById(obj+i).style.display == "inline" ) ? "none" : "none";
			}else{
				if(i==id)
					document.getElementById(obj+i).style.display = (document.getElementById(obj+i).style.display == "none" ) ? "table-row" : "none";
				else
					document.getElementById(obj+i).style.display = (document.getElementById(obj+i).style.display == "table-row" ) ? "none" : "none";
			}
		} else
			break;
	}
}

function eXpand(obj){
	//Compatible IE 6, Mozilla 1.4.1 , Firebird 0.6.1+
	var aux = document.getElementById(obj);

	if (document.all)
		aux.style.display = (aux.style.display == "none" ) ? "inline" : "none";
	else
		aux.style.display = (aux.style.display == "none" ) ? "table-row" : "none";
}

window.onresize=reDo;

function reDo(){window.location.reload();}

var hdrjanela = null;

function openWin(sUrl, w, h) {
	if (hdrjanela && !hdrjanela.closed) hdrjanela.close();
	hdrjanela = window.open(sUrl,'','top=0, left=0, location=0, toolbar=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=1');
	if (w != null && h != null) hdrjanela.resizeTo(w, h);
}

function openImg(sUrl) {
	if (hdrjanela && !hdrjanela.closed){
		hdrjanela.focus();
	} else {
		hdrjanela = window.open('','','top=0, left=0, location=0, toolbar=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=1');
		hdrjanela.document.write('<html><head><title>Imagem</title></head><body leftmargin="2" topmargin="2"><img border="1" style="border-color:#000000" src="' + sUrl + '" align="absmiddle"></body></html>');

		var iWidth = hdrjanela.document.images[0].width + 20;
		var iHeight = hdrjanela.document.images[0].height + 40;
		hdrjanela.resizeTo(iWidth, iHeight);
		hdrjanela.focus();
	}
}

function openMedalhas(sUrl){
	var width = 431;
	var height = 650;
	var nLeft = (screen.width - width)/2;
	var nTop = (screen.height - height)/2;

	var janela = window.open(sUrl, '_splash', 'width=' + width + ', height=' + height + ', top=' + nTop + ', left=' + nLeft + ',scrollbars=yes');
	janela.focus();
	window.opener = top;
}

var img_id = 0;

var tmpHTML = '';

/*
	Array Format: Text, URL, SID, Childs?
*/

function menuWiz(sid, a, level)
{
	tmpHTML += (
	'<div id="' + sid + 'Container" style="z-index: 2000' + level + ';">' +
	'	<div id="' + sid + 'Content" style="position: relative; z-index: ' + level + '; left: 50; filter:alpha(opacity=90); text-align: left;">'
	);

	var tam;
	if (level==4){
		tam = 155;
		//tam = 120;
		//tam2 = 155;
	}
	else {
		tam = 150;
		//tam = 200;
		//tam2 = 150;
	}

	tmpHTML += (
	'<div id=navlist style="width:' + tam + 'px;">'
	);

	for(var i=0; i<a.length; i++)
	{
		var txt = a[i][0];
		var url = a[i][1];
		var childSid = a[i][2];
		var childs = a[i][3];

		tmpHTML += (
		'<a ' +
		'onmouseover="' + (level==4?'ypSlideOutMenu.showMenu(\'' + childSid + '\');' : '') + 'ypSlideOutMenu.showMenu(\'' + sid + '\');' +
		(childs==true?'ypSlideOutMenu.showMenu(\'' + childSid + '\');' : '') +
		'" onmouseout="' + (level==4?'ypSlideOutMenu.hideMenu(\'' + childSid + '\');' : '') + 'ypSlideOutMenu.hideMenu(\'' + sid + '\');' +
		(childs==true?'ypSlideOutMenu.hideMenu(\'' + childSid + '\');' : '') +
		'" href="' + (childs==true?'javascript:void(0);':url) + '">' + txt +  '</a>' +
		(childs==true? '<img align="right" src="../../../bancocv/bcaimg/arr_indigo.gif">':'') +
		(i == (a.length-1) ? '':'<div onmouseover="' + (level==4?'ypSlideOutMenu.showMenu(\'' + childSid + '\');' : '') + 'ypSlideOutMenu.showMenu(\'' + sid + '\');"></div>')
		);
	}

	tmpHTML += (
	'	</div>' +
	'  </div>' +
	'</div>'
	);
}

function menuFlush()
{
	document.write(tmpHTML);
}