function pulacampo(idobj, idproximo)	{
	var str = new String(document.getElementById(idobj).value);
	var mx = new Number(document.getElementById(idobj).maxLength);
	if (str.length == mx){
		document.getElementById(idproximo).focus();		
	}
}

function validar_num(campo)
{
nome=campo.name
num = limpa_string(campo.value);
campo.value = num;
}

function limpa_string(S) // Deixa so os digitos no numero
{
var Digitos = "0123456789";
var temp = "";
var digito = "";
for (var i=0; i<S.length; i++)
{
digito = S.charAt(i);
if (Digitos.indexOf(digito)>=0)
{
temp=temp+digito
}
}
return temp
}


var SubStr="";
var Index=0;
var Atualizar=0;

  function one2two(one,two) {
	var oneSelected = one.selectedIndex;
	var twoLength   = two.length;
	var selectedArray = new Array();

	if(oneSelected == -1) {
	  window.alert('Escolha um item da lista');
	  return;
	}

	two.options[twoLength] = new Option(one.options[oneSelected].text,one.options[oneSelected].value);
	one.options[oneSelected] = null;
	two.options[twoLength].selected = true;
  }

function transfereItem(item,item_chegada){

	var oneSelected = item.selectedIndex;
	var twoLength   = item_chegada.length;
	var oneLength   = item.length;    
	
	/*if(twoLength == 5 || oneLength == 0){
	  if(item_chegada.name == 'listacargo_usuario' || item_chegada.name == 'listaarea_usuario'){
	     window.alert('No minimo 1 e no máximo 5 itens');
	     return false;
	  }
	}

	if(oneLength == 1){
	  if(item_chegada.name == 'listacargo' || item_chegada.name == 'listaarea'){
	     window.alert('No minimo 1 e no máximo 5 itens');
	     return false;
	  }
	}
	*/

	if(oneSelected == -1) {
	  window.alert('Escolha um item da lista');
	  return false;
	}

	item_chegada.options[twoLength] = new Option(item.options[oneSelected].text,item.options[oneSelected].value);
	item.options[oneSelected] = null;
	item_chegada.options[twoLength].selected = true;

}

function Excluir(form,pagina,id,parametros){
	if (confirm("Tem certeza que deseja excluir este registro?")) {
	  action = pagina+'?acao=EXCLUIR&id='+id;
	  if(parametros != ''){
		  action = action + parametros;
	  }
	  form.action = action;
	  form.submit(); 	
	}
}
function get_random(maxNum)
{
  if (Math.random && Math.round)
  {
    var ranNum= Math.round(Math.random()*(maxNum-1));
    ranNum+=1;
    return ranNum;
  }
  else
  {
  today= new Date();
  hours= today.getHours();
  mins=   today.getMinutes();
  secn=  today.getSeconds();
  if (hours==19)
   hours=18;
  var ranNum= (((hours+1)*(mins+1)*secn)%maxNum)+1;
  return ranNum;
  }
}

function filmeFlash(filme,variaveis,id,largura,altura,acao,elemento){	
		flash = "";
		flash += "<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+"' id='"+id+"' align='middle'>"
		flash += "<param name='allowScriptAccess' value='sameDomain' />"
		flash += "<param name='movie' value='"+filme+"' />"
		flash += "<param name='quality' value='high' />"
		flash += "<param name='wmode' value='transparent' />"
		flash += "<param name='flashvars' value='"+variaveis+"' />"
		flash += "<param name='bgcolor' value='#ffffff' />"
		flash += "<embed wmode='transparent' flashvars='"+variaveis+"' src='"+filme+"' quality='high' bgcolor='#ffffff' width='"+largura+"' height='"+altura+"' name='swf_titulo' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer ' />"
		flash += "</object>"
		
		if(acao == 0){
			document.write(flash);
		}else{
			// se for igual a 1
			document.getElementById(elemento).innerHTML = flash;	
		}
}


function tituloFlash(texto,idelemento,filme,w,h){	
	flash = ""
	titulo = texto;
	elemento = idelemento;
	function imprimirTitulo(titulo){	
		flash += "<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='"+w+"' height='"+h+"' id='swf_titulo' align='middle'>"
		flash += "<param name='allowScriptAccess' value='sameDomain' />"
		flash += "<param name='movie' value='"+filme+"' />"
		flash += "<param name='quality' value='high' />"
		flash += "<param name='wmode' value='transparent' />"
		flash += "<param name='flashvars' value='titulo="+titulo+"' />"
		flash += "<param name='bgcolor' value='#ffffff' />"
		flash += "<embed wmode='transparent' flashvars='titulo="+titulo+"' src='"+filme+"' quality='high' bgcolor='#ffffff' width='"+w+"' height='"+h+"' name='swf_titulo' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer ' />"
		flash += "</object>"
		document.getElementById(elemento).innerHTML = flash;
	}
	imprimirTitulo(titulo);
}

function exibeFoto(posicao){
	if(posicao==1){
		document.getElementById('chamada_foto1').style.display = "";
		document.getElementById('chamada_foto2').style.display = "none";
		document.getElementById('chamada_foto3').style.display = "none";
		alterarClass('cham_principal',formato1);
	}
	if(posicao==2){
		document.getElementById('chamada_foto1').style.display = "none";
		document.getElementById('chamada_foto2').style.display = "";
		document.getElementById('chamada_foto3').style.display = "none";
		alterarClass('cham_principal',formato2);
	}
	if(posicao==3){
		document.getElementById('chamada_foto1').style.display = "none";
		document.getElementById('chamada_foto2').style.display = "none";
		document.getElementById('chamada_foto3').style.display = "";
		alterarClass('cham_principal',formato3);
	}
}

//Função para alterar class
function alterarClass(id,style){
	document.getElementById(id).className = style;
}

//Função para ocultar DIV
function ocultaDiv(id){
	document.getElementById(id).style.display = "none";
}

//Função para exibir DIV
function exibeDiv(id){
	document.getElementById(id).style.display = "";
}

//Função para mudar de estilo	
ant = ""
function tabs(id){	
	atual = id
	if (ant == ""){
		ant = id
	}

	function mostrar(x){		
		document.getElementById(x).style.display = "block"	
		ant = x;
	}

	function anterior(y){	
		document.getElementById(ant).style.display = "none"		
		mostrar(atual);
	}

	anterior(ant);
}

//Função para mudar de estilo
function buttonInteraction(x,id,style){
	if(x==1){
		function buttonOver(){
			document.getElementById(id).className = style
		}
		buttonOver()
	}else{	
		function buttonOut(){
			document.getElementById(id).className = style
		}
		buttonOut()
	}
}

<!--
function listaFavoritos(link, id) {
	window.location = 'http://www3.atarde.com.br/framework/componentes/cp_adicionar_favoritos.jsp?pagina='+link+'&id_noticia='+id;
}

function marcaBotao(idObjeto){
   bts = document.getElementsByTagName('button');
   for (i=0;i<bts.length;i++){
		if (bts[i].type == "button" && bts[i].name == "bt_foto"){
			if(idObjeto==bts[i].id){
				document.getElementById(bts[i].id).className= "img_atual";
			}else{
				document.getElementById(bts[i].id).className = "img_estatica";
			}
		}
   }
}
 
function imprimirNoticias() {
   var cont=0; 
   checks = document.getElementsByTagName('input');
   var ids; var primeira = true;
   for (i=0;i<checks.length;i++){
		if (checks[i].type == "checkbox" && checks[i].name == "id_noticia"){
			if (checks[i].checked) {
			    if (primeira==true){
			    	ids = checks[i].value;
					primeira = false;
				}else{
				    ids = ids +"+"+checks[i].value;
				}
				cont++;
			}
		}
   }
   if(cont==0){
		alert("Selecione pelo menos uma notícia.");
		return;
   }
	window.location = 'http://www3.atarde.com.br/framework/componentes/cp_imprimirnoticias.jsp?ids='+ids;
}

function enviarNoticias() {
   var cont=0; 
   checks = document.getElementsByTagName('input');
   var ids; var primeira = true;
   for (i=0;i<checks.length;i++){
		if (checks[i].type == "checkbox" && checks[i].name == "id_noticia"){
			if (checks[i].checked) {
			    if (primeira==true){
			    	ids = checks[i].value;
					primeira = false;
				}else{
				    ids = ids +"+"+checks[i].value;
				}
				cont++;
			}
		}
   }
   if(cont==0){
		alert("Selecione pelo menos uma notícia.");
		return;
   }
	NewWindow('http://www3.atarde.com.br/framework/componentes/cp_enviarnoticias.jsp?ids='+ids,'ENVIAR',320,393,0)
}
function checarOpcoes() {
	var cont=0; 
	checks = document.getElementsByTagName('input');
	var ids; var primeira = true;
	for (i=0;i<checks.length;i++){
		if (checks[i].type == "radio" && checks[i].name == "opcao"){
			if (checks[i].checked) {
				if (primeira==true){
					ids = checks[i].value;
					primeira = false;
				}else{
					ids = ids +"+"+checks[i].value;
				}
				cont++;
			}
		}
	}
	if(cont==0){
		alert("Selecione uma opção para votar.");
		return false;
	}else{
		return true;
	}
}
function obterOpcao() {
	var cont=0; 
	checks = document.getElementsByTagName('input');
	var ids; var primeira = true;
	for (i=0;i<checks.length;i++){
		if (checks[i].type == "radio" && checks[i].name == "opcao"){
			if (checks[i].checked) {
				if (primeira==true){
					ids = checks[i].value;
					primeira = false;
				}else{
					ids = ids +"+"+checks[i].value;
				}
				cont++;
			}
		}
	}

	return ids;

}
function excluirNoticias() {
   var cont=0; 
   checks = document.getElementsByTagName('input');
   var ids; var primeira = true;
   for (i=0;i<checks.length;i++){
		if (checks[i].type == "checkbox" && checks[i].name == "id_noticia"){
			if (checks[i].checked) {
			    if (primeira==true){
			    	ids = checks[i].value;
					primeira = false;
				}else{
				    ids = ids +"+"+checks[i].value;
				}
				cont++;
			}
		}
   }
   if(cont==0){
		alert("Selecione pelo menos uma notícia.");
		return;
   }
	TheNewWin =window.open("http://www3.atarde.com.br/framework/componentes/cp_excluirnoticias.jsp?ids="+ids,'Excluir','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0'); 
	TheNewWin.blur();
}

function expandirLista(){
	document.getElementById('lista_favoritos').style.overflow = "visible";
	document.getElementById('lista_favoritos').style.height = "auto";
}
function fecharLista(){
	document.getElementById('lista_favoritos').style.overflow = "hidden";
	document.getElementById('lista_favoritos').style.height = "22";
}

/*** Swap imagem ***/
<!--
function MM_swapImgRestore() { //v3.0
  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_preloadImages() { //v3.0
  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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  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];}
}
//-->


/*** data do cliente ***/
hoje = new Date();
dia = hoje.getDate();
dias = hoje.getDay();
mes = hoje.getMonth();
ano = hoje.getYear();

if (dia < 10){
  dia = "0" + dia;
}

   if (navigator.appName=="Netscape") {
	  ano = ano + 1900;
   }else{
	  ano = ano + 0;
   }

function CriaArray (n) {
  this.length = n;
}

NomeDia = new CriaArray(7);
NomeDia[0] = "Domingo";
NomeDia[1] = "Segunda-feira";
NomeDia[2] = "Terça-feira";
NomeDia[3] = "Quarta-feira";
NomeDia[4] = "Quinta-feira";
NomeDia[5] = "Sexta-feira";
NomeDia[6] = "Sábado";

NomeMes = new CriaArray(12);
NomeMes[0] = "Janeiro";
NomeMes[1] = "Fevereiro";
NomeMes[2] = "Março";
NomeMes[3] = "Abril";
NomeMes[4] = "Maio";
NomeMes[5] = "Junho";
NomeMes[6] = "Julho";
NomeMes[7] = "Agosto";
NomeMes[8] = "Setembro";
NomeMes[9] = "Outubro";
NomeMes[10] = "Novembro";
NomeMes[11] = "Dezembro";

function WriteDate() {
   document.write (" " + NomeDia[dias] + ", " + dia + " de " + NomeMes[mes] + " de " + ano + " ")
}
//-->


<!--
/*** favoritos ***/
function addbookmark(){

var bookmarkurl=document.location
var bookmarktitle=document.title
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}
//-->

/*** abrir pop up ***/
function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "','status=0,width=640,height=550,left = 50,top = 50');");
}
/*
Auto center window script- Eric King (http://redrival.com/eak/index.shtml)
Permission granted to Dynamic Drive to feature script in archive
For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
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+',resizable=no,status=no';
win = window.open(mypage,myname,settings)
}

/*
****************************************************************************************************
1. <body>
****************************************************************************************************
<a href="http://wsabstract.com" onclick="NewWindow(this.href,'name','400','400','yes');return false">Website Abstraction</a>

*/



/*

<script type="text/javascript" src="../js/fc_comum.js"></script>


*/

//******************************************************************
function EntrarSelect() {
  //inicializa variáveis globais
  SubStr="";
  Index=0;
}
//******************************************************************

//******************************************************************
function TeclarSelectPress(Select) {
  //se for ESC, reinicializa as variáveis
  if(event.keyCode==27) {
    EntrarSelect();
    Atualizar=1;
    return;
  }

  //concatena à letra que acabou de ser digitada
  SubStr+=(chr(event.keyCode)).toLowerCase();

  var TamSubStr=SubStr.length;
  var TamSelect=Select.length;
 
  //seleciona a próxima ocorrência que verifica a substring
  for(i=Select.selectedIndex ; i<TamSelect ; i++) {
    if(SubStr==(Select.options[i].text.substring(0,TamSubStr).toLowerCase())) {
      Index=i;
      Atualizar=1;
      break;
    }
  }
}
//******************************************************************

//******************************************************************
function TeclarSelectUp(Select) {
  //se o flag estiver acionado, atualizamos a posição
  if(Atualizar) {
    Select.selectedIndex=Index;
    Atualizar=0;
  }
}
//******************************************************************

  function one2two(one,two) {
	var oneSelected = one.selectedIndex;
	var twoLength   = two.length;
	var selectedArray = new Array();

	if(oneSelected == -1) {
	  window.alert('Escolha um item da lista');
	  return;
	}

	two.options[twoLength] = new Option(one.options[oneSelected].text,one.options[oneSelected].value);
	one.options[oneSelected] = null;
	two.options[twoLength].selected = true;
  }

function transfereItem(item,item_chegada){

	var oneSelected = item.selectedIndex;
	var twoLength   = item_chegada.length;
	var oneLength   = item.length;    
	
	/*if(twoLength == 5 || oneLength == 0){
	  if(item_chegada.name == 'listacargo_usuario' || item_chegada.name == 'listaarea_usuario'){
	     window.alert('No minimo 1 e no máximo 5 itens');
	     return false;
	  }
	}

	if(oneLength == 1){
	  if(item_chegada.name == 'listacargo' || item_chegada.name == 'listaarea'){
	     window.alert('No minimo 1 e no máximo 5 itens');
	     return false;
	  }
	}
	*/

	if(oneSelected == -1) {
	  window.alert('Escolha um item da lista');
	  return false;
	}

	item_chegada.options[twoLength] = new Option(item.options[oneSelected].text,item.options[oneSelected].value);
	item.options[oneSelected] = null;
	item_chegada.options[twoLength].selected = true;

}

//-->

function exibeDivirtase(posicao){
	if(posicao==1){
		document.getElementById('divirtase1').style.display = "";
		document.getElementById('divirtase2').style.display = "none";
		document.getElementById('divirtase3').style.display = "none";
		document.getElementById('divirtase4').style.display = "none";
	}
	if(posicao==2){
		document.getElementById('divirtase1').style.display = "none";
		document.getElementById('divirtase2').style.display = "";
		document.getElementById('divirtase3').style.display = "none";
		document.getElementById('divirtase4').style.display = "none";
	}
	if(posicao==3){
		document.getElementById('divirtase1').style.display = "none";
		document.getElementById('divirtase2').style.display = "none";
		document.getElementById('divirtase3').style.display = "";
		document.getElementById('divirtase4').style.display = "none";
	}
	if(posicao==4){
		document.getElementById('divirtase1').style.display = "none";
		document.getElementById('divirtase2').style.display = "none";
		document.getElementById('divirtase3').style.display = "none";
		document.getElementById('divirtase4').style.display = "";
	}
}

function fecharDhtml() {
        closeAd();
        id = 'sponsorAdDiv';
        NNtype = 'hidden';
        IEtype = 'hidden';
        WC3type = 'hidden';
    if (document.getElementById) {
        eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
    } else {
        if (document.layers) {
            document.layers[id].visibility = NNtype;
        } else {
            if (document.all) {
                eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
            }
        }
    }
}

 
function contarAcesso(canal) {
	var page_request = false;
	if (window.XMLHttpRequest){
	   page_request = new XMLHttpRequest();
	}else if (window.ActiveXObject){ // if IE
	   try{
	      page_request = new ActiveXObject("Msxml2.XMLHTTP");
	   }catch (e){
	      try{
		    page_request = new ActiveXObject("Microsoft.XMLHTTP");
		  }catch (e){	}
 	   }
	}else{
	   return false;
	}
	url = 'http://desenv.grupoatarde.com.br/framework/componentes/cp_estatistica.jsp';

	page_request.open('POST',url,true);
	page_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	page_request.send('canal_id='+canal);
	page_request.responseText;
}


function mostrar(nomelemento,valor) {

	var pub = document.getElementById(nomelemento);
	
	if (valor == 2) {
	pub.style.display='none';
	
	}
	
}