/* mostra captcha */

function ver_captcha(r, nivel)
{
		if (document.getElementById('divcaptcha').style.display == 'none')
		{
			document.getElementById('captcha').innerHTML = '<img src="'+nivel+'../captcha.phtml?r='+r+'&s=captcha" />';
			document.getElementById('divcaptcha').style.display = 'block';
			document.getElementById('divenvia').style.display = 'block';
		}
}

/* contador de caracteres */

function ContaObs(campo, contacampo, total)
{
	if(campo.value.length > total)
	{
		campo.value = campo.value.substring(0, total);
	}
   		contacampo.innerHTML = campo.value.length;
}

/* fontes */

var tam = 12;
var tam = readCookie ('fonte');

if (tam == 'null' || tam == 'undefined')
{
	var tam = 12;
}
else if (tam < 10)
{
	var tam = 12;
}

function tam_fonte(tipo,elemento){
	if (tipo=="aum") {
		if(tam<16) { tam = eval(eval(tam)+1); }
		createCookie('fonte',tam,365);
	} else if (tipo=="dim") {
		if(tam>10) { tam = eval(eval(tam)-1); }
		createCookie('fonte',tam,365);
	}

	tamlh = eval(eval(tam)+4);
	
	document.getElementById('psdotexto').style.fontSize = tam+'px';
	document.getElementById('psdotexto').style.lineHeight = tamlh+'px';
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}



var segundos = 4;

var controla = 0;
function playstop(){
	if(controla == 0){
		clearInterval(intX);
                document.getElementById("playpau").src="http://img.rpc.com.br/homenova/mpla.gif";
                document.getElementById("playpau").alt="Play";
		controla = 1;
	}else{
                controla = 0;
                div = "multi";
		intX = setInterval("troca(div,cont++,fim)", segundos * 1000);
                document.getElementById("playpau").src="http://img.rpc.com.br/homenova/mpau.gif";
                document.getElementById("playpau").alt="Pausa";
    	}
}

/* posicionamento do shopping */

var winW = 630, winH = 460;

function posicionashopping ()
{
        if (parseInt(navigator.appVersion)>3) {
         if (navigator.appName=="Netscape") {
                winW = window.innerWidth;
                winWD = ((winW-16-782)/2)+782;
                
                //winWD = winW-16-240;
         }
         if (navigator.appName.indexOf("Microsoft")!=-1) {
                winW = document.body.offsetWidth-4;
                winWD = ((winW-16-782)/2)+782+10;

                //winWD = winW-16-220;
         }
        }

        //alert (winWD + ' tamanho: ' + eval (winWD+163) + ' contra ' + winW);
        
        if (winW > 1000 && winWD+163 > winW)
        {
                document.getElementById('home').style.marginLeft = '30px';
		document.getElementById('barramenu').style.width = '935px';
		document.getElementById('divbanner').style.width = '935px';
                winWD = 782+30;
        }
        
        if (winW > 1000)
        { 
                document.getElementById('shopping2').style.left = ''+winWD+'px';        
                document.getElementById('shopping2').style.display = 'inline';
        }
}

function troca(div,i,eofim){
        
        if(document.getElementById(div+i).style.display == "block"){
                document.getElementById(div+i).style.display = "none";
                
                if(i < eofim){
                        aux = eval(1+i);
                        document.getElementById(div+aux).style.display="block";
                }else{
                        
                        if (div == 'multi')
                        {
                                cont = 1;
                                t = cont;
                        }
                        else if (div == 'tempo')
                        {                                
                                tcont = 0;
                                t = tcont;
                        }
                        
                        document.getElementById(div+t).style.display="block";
                }
        } 
}

function mOvr(src,clrOver,under,tr)
{
	isIE = ((navigator.appVersion.indexOf('MSIE')>=0));
        src2 = src.firstChild;

	if (isIE)
	{
        	src.style.cursor = 'hand';
	}
	else
	{
		src.style.cursor = 'pointer';
	}

        if (clrOver)
        {
		if (tr)
                {
                        src.parentNode.bgColor = clrOver;
                }
                else
                {
                        src.bgColor = clrOver;
                }
        }

        if (under)
        {
                src2.style.textDecoration = 'underline';
        }
}

function mOut(src,clrIn,tr)
{
        src2 = src.firstChild;
        src.style.cursor = 'default';

        if (clrIn)
        {
		if (tr)
                {
                        src.parentNode.bgColor = clrIn;
                }
                else
                {
                        src.bgColor = clrIn;
                }
        }

        src2.style.textDecoration = 'none';
}

function mClk(id)
{
        src = id.firstChild;
	target = src.target;
	
	if (target == '_blank')
	{
		window.open (src.href);
	}
	else
	{
        	top.location = src.href;
	}
}

function MM_findObj(n, d) { //v4.0
  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_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function RPC_Menu(layer)
{
	var nets = navigator.appName == "Netscape";
	var ns4 = (nets && parseInt(navigator.appVersion) == 4);
	var rpclayer = MM_findObj(layer+'_layer');

	if (!ns4)
	{
		if (rpclayer.style['visibility']=='visible' || rpclayer.style['visibility']=='show')
		{
			MM_showHideLayers(layer+'_layer','','hide');
			rpclayer.style['height'] = '1px';
		}
		else
		{
			MM_showHideLayers(layer+'_layer','','show');
			rpclayer.style['height'] = '';
		}
	}
}

function combo(targ,selObj,restore)
{ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function botao(nomeform)
{
   eval("document."+nomeform+".submit()");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function RPC_Janela (theURL,winName,features)
{
        var newWind = window.open(theURL,winName,features);
        if (newWind.opener == null)
        {
                newWind.opener = self;
        }
}

function $ (id)
{
	return document.getElementById (id);
}

function showswf(flash, w, h)
{
	var swfHTM ='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownloadocument.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+w+'" height="'+h+'">';
	swfHTM +='<param name="movie" value="'+flash+'" /><param name="quality" value="high" /><param name="flashvars" value="" /><param name="AllowScriptAccess" value="always" />';
        swfHTM += '<param name="allowFullScreen" value="true" />';
	swfHTM += '<param name="wmode" value="opaque" />';
	swfHTM +='<embed allowFullScreen="true" mode="opaque" src="'+flash+'" flashvars="" AllowScriptAccess="always" quality="high" width="'+w+'" height="'+h+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	document.write (swfHTM);
}

function showsigno(signo)
{
	for (i=1;i<=12;i++)
	{
		$('signo'+i).style.display = 'none';
		$('topsigno'+i).className = 'signo'+i+"off";
	}
	$('signo'+signo).style.display = 'block';
	$('topsigno'+signo).className = 'signo'+signo+"on";
}

function GazetaVer ()
{
	var data = document.buscarapida.edicao_ano.value+'-'+document.buscarapida.edicao_mes.value+'-'+document.buscarapida.edicao_dia.value;
	var url = "../edicaododia/?data="+data+" 23:00:00";
	document.location.href = url;
}

var segundos = 5;
var javiu = 0;

function minitroca(i,eofim){
		pub = 0;
        clearInterval(intX);
        cont = i;

        for (j=1;j<=eofim;j++)
        {
                document.getElementById('fotodogiro_'+j).style.display = "none";
                document.getElementById('botao'+j).className="num";
        }   

		if (pub == 1)
		{
			  document.getElementById('multi_pub').style.display="none";
			  document.getElementById('menuslideshow').style.display="block";
		}

		if (i == 2 && pub == 1 && javiu == 0)
		{
			  javiu = 1;
			  cont = 1;
			  document.getElementById('multi_pub').style.display="block";
			  document.getElementById('menuslideshow').style.display="none";
		} 
		else if(i <= eofim && i > 0)
		{
				aux = eval(i);
				document.getElementById('fotodogiro_'+aux).style.display="block";
				document.getElementById('botao'+aux).className="esse";
		}
		else if(i == 0)
		{
				cont = eofim;
				t = cont;
				document.getElementById('fotodogiro_'+t).style.display="block";
				document.getElementById('botao'+t).className="esse";
		}
		else
		{
				cont = 1;
				t = cont;
				javiu = 0;		
		
				document.getElementById('fotodogiro_'+t).style.display="block";
				document.getElementById('botao'+t).className="esse";
		}

        intX = setInterval("minitroca(++cont,"+eofim+","+pub+")", segundos * 1000);
}
