nie = (navigator.appName.indexOf("Microsoft") == -1);

function arr(n)  {
   this.length=n
   for (var i=0;i<n;i=i+1)  {
     this[i] = '';
   }
}
function mv(movieName) 
{
	if (navigator.appName.indexOf ("Microsoft") !=-1) {
		return document.all[movieName]
	} else {
		return document[movieName]
	}	
}
function loadMovie(id, movie, params)
{
	mv(id).LoadMovie(0, movie);
    for (p=0; p<params.length; p+=2)
        mv(id).SetVariable(params[p], params[p+1]);
}
function movieIsLoaded (theMovie) {
  if (typeof(theMovie) != "undefined") {
	return ((typeof(theMovie.PercentLoaded) != "undefined") && (theMovie.PercentLoaded() == 100));
  } else {
    return false;
  }
}
function movieIsReady (theMovie) {
	return (typeof(theMovie.PercentLoaded) != "undefined");
}

function getel(doc, id)
{
	if (doc.all)
		return doc.all[id];
	else
		return doc.getElementById(id);
}

function element_top(el)
{
	var et = 0
	while (el)
	{
		et += el.offsetTop
		el = el.offsetParent
	}
	return et
}

function element_left(el)
{
	var et = 0
	while (el)
	{
		et += el.offsetLeft
		el = el.offsetParent
	}
	return et
}

function escreve(s)
{
	document.write(s);
}

function ampliar(id, pw, ph, base)
{
	if (pw > 760)
		pw = 760;
	if (ph > 570)
		ph = 570;

	w = (screen.width-30);
	w = pw+10 > w ? w : pw+10;
	h = (screen.height-30);
	h = ph+10 > h ? h : ph+10;
	
	janela = window.open('about:blank','pict_big','toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=no,menubar=no,width='+(w)+',height='+(h)+',top='+(((screen.height-h)/2)-30)+',left='+(((screen.width-w)/2)-10))
	janela.document.write('<HTML><TITLE>Imagem ampliada</TITLE>');
	janela.document.write('<BODY style="margin: 0px; padding: 0px">');
	janela.document.write('<TABLE BORDER=0 cellpadding=0 cellspacing=0 width=100% height=100%><TR><TD width=100% height=100% align=center valign=middle>');
	janela.document.write('<A HREF="" onclick="window.close(); return false"><IMG id=pic ALT="Clique para fechar" SRC="' + base + 'ModuleHandlers/Content/picture.aspx?idContentPicture=' + (id) + '&w='+(janela.document.body.clientWidth-10)+'&h='+(janela.document.body.clientHeight-10)+'" BORDER=0 style="border: 1px solid gray"></a>');
	janela.document.write('</TD></TR></TABLE></BODY></HTML>');	
	
	janela.focus()
	
}

function escreveFlash(id, src, width, height, align, transparent, mozila, onmouseover, onmouseout)
{
    s = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + 
        (width) + '" height="' + (height) + '" id="' + 
        id + '" ' + (align != '' ? 'align="' + align + '"' : '') + 
        (onmouseover != '' ? ' onmouseover="' + onmouseover + '"' : '') +
        (onmouseout != '' ? ' onmouseout="' + onmouseout + '"' : '') +
        '><param name="quality" value="high" />' +
        (src != '' ? '<param name="movie" value="' + src + '" />' : '') +
        (transparent ? '<param name="wmode" value="transparent" />' : '') +
        '<param name="menu" value="false" />' +
        '</object>';
    escreve(s);
}

function newImage(arg) {
	if (document.images) {  
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}


function mainImprime()
{
    window.frames['ifcontent'].focus(); 
    window.frames['ifcontent'].imprime(); 
}

function imprime()
{
	setTimeout("window.print()", 500);
}

function loadBanners()
{
    bs = getel(window.parent.document, 'bannerTopo');
    isHome = typeof(window.parent.imain) == 'undefined';
    if (bs.innerHTML != bannerSuperiorHtml)
        bs.innerHTML = bannerSuperiorHtml;
    bs.style.visibility = (bannerSuperiorHtml != '') || (!isHome) ? 'visible' : 'hidden';
    bs.style.display = (bannerSuperiorHtml != '') || (isHome) ? 'block' : 'none';

    if (bannersEsquera)
    {    
        for (i=1; i<=2; i++)
        {
            b = getel(window.parent.document, 'bannerEsquerda' + (i));
            if (b)
            {
                b.style.display = i <= bannersEsquera.length ? 'block' : 'none';
                newHtml = i <= bannersEsquera.length ? bannersEsquera[i-1] : '';
                if (b.innerHTML != newHtml)
                    b.innerHTML = newHtml;
            }
        }
    }
    if (typeof(bannersDireita) != 'undefined')
    {    
        for (i=1; i<=6; i++)
        {
            b = getel(window.parent.document, 'bannerDireita' + (i));
            if (b)
            {
                b.style.display = i <= bannersDireita.length ? 'block' : 'none';
                newHtml = i <= bannersDireita.length ? bannersDireita[i-1] : '';
                if (b.innerHTML != newHtml)
                    b.innerHTML = newHtml;
            }
        }
    }
}

var ie5=document.all && !window.opera
var lastHeight = 0;
var autoHeight = 0;
var autoHSet = 0;
function adjustIFrameSize () 
{
	iframeElement = getel(window.parent.document, 'ifcontent');
	iframeWindow = window.parent.frames[name];
    iframeElement.style.height = '';
    h = document.documentElement.scrollHeight;
	if (h < 250)
		h = 250;
	iframeElement.style.height = (h) +'px';
	lastHeight = h;
	if ((autoHeight) && (!autoHSet))
	{
	    autoHSet = 1;
	    setTimeout('autoH()', 500);
	}
}

function autoH()
{
	if (document.documentElement.scrollHeight != lastHeight)
	{
        scrollPos = window.parent.document.documentElement.scrollTop;
		adjustIFrameSize();
	    window.parent.document.documentElement.scrollTop = scrollPos;
	}
    setTimeout('autoH()', 500);
}

function contentBeforePrint(){
    getel(document, 'cabPrint').style.display = 'block';
}

function contentAfterPrint(){
    getel(document, 'cabPrint').style.display = 'none';
}

function fonte(aumenta)
{
	df = getel(document, 'divFonteTexto');
	size = df.style.fontSize.substr(0, df.style.fontSize.length-2);
	if ((size <= 11) && !aumenta)
	{
		alert(fonteMinTxt);
		return;
	}
	if ((size >= 17) && aumenta)
	{
		alert(fonteMaxTxt);
		return;
	}
	if (aumenta)
	{
		size++;
		size++;
	}
	else
	{
		size--;
		size--;
	}
	df.style.fontSize = (size) + "px";
	var expire = new Date();
	expire.setTime(new Date().getTime() + 3600000*24*5000);
	document.cookie = 'fontSize'+"="+escape((size) + '')+ ";expires="+expire.toGMTString();
	adjustIFrameSize();
}

function indica()
{
	ifc = window.frames['ifcontent'];
	iurl = 'indique.aspx?1=1';
	if (ifc.idcontent != 0)
		iurl += '&idContent=' + (ifc.idcontent);
	if (ifc.idcontentsection != 0)
		iurl += '&idContentSection=' + (ifc.idcontentsection);
	ifc.location = htmlbase + iurl;
}

function abreGaleria(id, idContentPicture)
{
	janela = window.open(htmlbase + 'galeria.aspx?idContent=' + (id) + (typeof(idContentPicture) != 'undefined' ? '&idContentPicture=' + (idContentPicture) : ""),'galeria','toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=no,menubar=no,width=611,height=477,top='+((screen.height-477)/2)+',left='+((screen.width-611)/2));
	janela.focus();
}
