function correctPNG() {
	for(var i=0; i<document.images.length; i++) {
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}
window.attachEvent("onload", correctPNG);

function NovaJanela(pagina,nome,w,h,scroll,toolbar){
    var win = null;

	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',toolbar='+toolbar+',resizable=no'
	win = window.open(pagina,nome,settings);
}

var ie4 = (document.all) ? 1:0;
function HideLayer(Layer) {
	if (ie4) {
		document.all(Layer).style.visibility="hidden";
	} else {
		document.getElementById(Layer).style.visibility="hidden";
	}
}

function ShowLayer(Layer) {
	if (ie4) {
		document.all(Layer).style.visibility="visible";
	} else {
		document.getElementById(Layer).style.visibility="visible";
	}
}

function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function FF_ImprimirDOC(URL){
	frames['IMSG'].location.href=URL;
	//Focus IE/FF
	if (document.all) {frames['IMSG'].document.body.focus();}
	else {frames['IMSG'].contentDocument.body.focus();}
}

function MM_preloadImages() {
	var d=document; if(d.images){if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() {
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) {
	var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() {
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function getById(elemento) {
	return document.getElementById(elemento);
}

function elemento(elemento) {
	return getById(elemento);
}

function isVisivel(elemento) {
	return getById(elemento).style.display == 'block';
}

function mostra(elemento) {
	getById(elemento).style.display = 'block';
}
function esconde(elemento) {
	getById(elemento).style.display = 'none';
}

function mostraEsconde(elemento) {
	if (isVisivel(elemento))
		esconde(elemento);
	else
		mostra(elemento);
}

function escondeObjeto(elemento) {
	elemento.style.display = 'none';
}

function mostraObjeto(elemento) {
	elemento.style.display = 'block';
}

function numeroAleatorio(limInf, limSup) {
	return Math.floor(Math.random()*(1 + limSup - limInf) + limInf);
}

function onUpdating(){
    FF_showPopWin('<span class=txt5>Aguarde...</span>', 300, 120, null, false, 'Aviso');
}
   
function onUpdated() {
    hidePopWin(false);
}

function CarregaFlash(caminho,largura,altura,bgcolor)
{
	if (arguments[4] != null) {
		wmode = arguments[4]; // Para forçar o wmode=transparent quando necessario
	} else {
		wmode = "opaque";
	}
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+largura+'" height="'+altura+'">');
	document.write('<param name="allowScriptAccess" value="sameDomain">');
	document.write('<param name="movie" value="'+caminho+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="bgcolor" value="'+bgcolor+'">');
//	document.write('<param name="scale" value="noscale" />');
	document.write('<param name="salign" value="lt" />');
	document.write('<param name="wmode" value="'+wmode+'" />');
	document.write('<param name="menu" value="false">');
	document.write('<embed src="'+caminho+'" quality="high" bgcolor="'+bgcolor+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowScriptAccess="sameDomain" wmode="'+wmode+'" salign="lt" width="'+largura+'" height="'+altura+'"></embed>');
	document.write('</object>');
}

function AlterarCorControle(Controle,CorBG,CorText)
{
    if (CorBG == "")
    {
        document.getElementById(Controle.id).style.backgroundColor = '#FFFFFF';
    }
    else
    {
        document.getElementById(Controle.id).style.backgroundColor = CorBG;
    }
    if (CorText == "")
    {
        document.getElementById(Controle.id).style.color = '#000000';
    }
    else
    {
        document.getElementById(Controle.id).style.color = CorText;
    }
}
