// Calendário
var mes = 0;
var ano = 0;
var dd   = 0;
var bmes = 0;
var bano = 0;
var bdd   = 0;
var vlink = "";
var not_cod = 0;
var can_cod = 0;
function calendarioImpresso(vmes, vano, dd, mes, ano)
{
  var day_of_week = new Array('D', 'S', 'T', 'Q', 'Q', 'S', 'S');
  var month_of_year = new Array('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
  var Calendar = new Date();
  var CCalendar = new Date();	
  var month = mes;
  var year  = ano;
  var ddia  = dd;
  var today = Calendar.getDate();
  var weekday = Calendar.getDay();
  var DAYS_OF_WEEK = 7;
  var DAYS_OF_MONTH = 31;
  var cal;
	
  Calendar.setDate(1);
  Calendar.setMonth(vmes);
  Calendar.setFullYear(vano);	
  var TR_start = '<tr>';
  var TR_end   = '</tr>';
  var highlight_start = '<td class="diasHoje">';
  var highlight_end = '</td>';
  var TD_start = '<td class="dias">';
  var TD_startweek = '<td class="diasdasemana">';
  var TD_end   = '</td>';
  var lin = 0;
  cal = '<table cellpadding="0" border="0" cellspacing="0" class="tabelaCalendario">';
  cal += '<tr>';
  cal += '<td colspan="7" class="mes">' +month_of_year[Number(vmes)]+ ' ' + vano + '</td>';
  //cal += '<td colspan="3" class="tiraDuvidaCalendario"><a href="#">O que é isso?</a></td>';
  cal += '</tr>';
  cal += TR_start;

  for(index=0; index < DAYS_OF_WEEK; index++)
  {
    cal += TD_startweek + day_of_week[index] + TD_end;
  }
		
  cal += TR_end;
  cal += TR_start;

  for(index=0; index < Calendar.getDay(); index++)
    cal += TD_start + ' ' + TD_end;

  for (index=0; index < DAYS_OF_MONTH; index++)
  {
    if ( Calendar.getDate() > index )
    {
      week_day =Calendar.getDay();
      if (week_day == 0)
        cal += TR_end+''+TR_start;

      if(week_day != DAYS_OF_WEEK)
      {
        var day = Calendar.getDate();
        var mtempo = Calendar.getTime();
		if(Number(day) == Number(ddia))
        {
          if(vlink == "ctdi_resultadobuscajornal")
          {
            cal += highlight_start  + '<a href="' + URL_JORNALHOJE + '?jhdt=' + year + '-' + (Number(vmes)+1) + '-' + day  + '">' + day  + '</a>' + highlight_end + TD_end;
          } else {
            cal += highlight_start  + '<a href="' + URL_JORNALHOJE + '?jhdt=' + year + '-' + (Number(vmes)+1) + '-' + day  + '">' + day  + '</a>' + highlight_end + TD_end;
          }
        } else {
          if((Number(day) > Number(ddia)) && (Number(mes) == Number(vmes) && Number(ano) == Number(vano)))
          {
            cal += TD_start + day + TD_end;
          } else {
            if(vlink == "ctdi_resultadobuscajornal")
            {
              cal += TD_start + '<a href="' + URL_JORNALHOJE + '?jhdt=' + year + '-' + (Number(vmes)+1) + '-' + day  + '">' + day + '</a>' + TD_end;
            } else {
              cal += TD_start + '<a href="' + URL_JORNALHOJE + '?jhdt=' + year + '-' + (Number(vmes)+1) + '-' + day  + '">' + day + '</a>' + TD_end;
            }
          }
        }
      }
      if(week_day == DAYS_OF_WEEK)
        cal += TR_end;
    }
    Calendar.setDate(Calendar.getDate()+1);
  }
  cal += '</table>';
  document.getElementById("corpoCalendario").innerHTML = cal;
}

// Formula 1: Função Corrida

// Mostrar Noticia
function mostrarnoticia(codcan,cannom)
{
  document.getElementById("idNmCaderno").innerHTML = document.getElementById("idCanal"+codcan).innerHTML;
  document.getElementById("idCtCaderno").innerHTML = document.getElementById(codcan).innerHTML;
  var curAr = document.getElementById("cont").value;
  document.getElementById("liCanal"+curAr).attributes["class"].value = "";
  document.getElementById("liCanal"+codcan).attributes["class"].value = "editoriaAtiva";  
  document.getElementById("cont").value = codcan;
//	document.getElementById("idCanal"+codcan).class = 
}
function Video(arquivo,largura,altura) 
{
	if(largura == null || largura == "") largura = 320;
	if(altura == null || altura == "") altura = 240;	
	document.write('<div id="chamada_videos">');	
	document.write('<object type="application/x-shockwave-flash"');
	document.write('id="single" name="single" data="http://www.opovo.com.br/player/interatividade.swf"');
	document.write('width="'+largura+'"');
	document.write('height="'+altura+'">');
	document.write('<param name="movie" value="http://www.opovo.com.br/player/interatividade.swf" />');
	document.write('<param name="FlashVars" value="file=http://www.opovo.com.br/videos_extras/'+arquivo+'.flv" />');
	document.write('<param name="allowfullscreen" value="true" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('</object>');
	document.write('</div>');	
}

function VideoNew(arquivo,largura,altura) {
	if(largura == null || largura == "") largura = 320;
	if(altura == null || altura == "") altura = 240;	
	document.write('<div id="chamada_videos">');	
	document.write('<object type="application/x-shockwave-flash"');
	document.write('id="single" name="single" data="http://www.opovo.com.br/player/interatividade.swf"');
	document.write('width="'+largura+'"');
	document.write('height="'+altura+'">');
	document.write('<param name="movie" value="http://www.opovo.com.br/player/interatividade.swf" />');
	document.write('<param name="FlashVars" value="file='+arquivo+'" />');
	document.write('<param name="allowfullscreen" value="true" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('</object>');
	document.write('</div>');	
}

var contador ; 
function contadordhtml()
{
	contador=setTimeout("fechadhtml()", 19800);
}
/* ICONES ADICIONAR */
function addFav () {
	var pagina = "http://www.opovo.com.br/";
	var titulo = "OPOVO.com.br";
	if(document.all){
		window.external.AddFavorite (pagina, titulo);
	} else {
		window.sidebar.addPanel (titulo, pagina, "");
	}
}
/* BANNERS */
function abreTV(){
	window.open('http://www3.opovo.com.br/transmissao-TV/index.html','tvopovo','width=700,height=400');
}
function expandSuperbanner(altura)
{
//	alert('teste');
	document.getElementById("superBanner").style.height = altura+"px";
	document.getElementById("superBannerSpan").style.height = altura+"px";
}

function expandSuperbannerEspecial(largura,altura){
//	alert('teste');
	if(largura != null){
		document.getElementById("superBannerSpan").style.width = largura+"px";
	}
	if(altura != null){
		document.getElementById("superBannerSpan").style.height = altura+"px";
	}
}

function contractSuperbanner()
{
	document.getElementById("superBanner").style.height = "90px";
	document.getElementById("superBanner").style.width = "728px";

	document.getElementById("superBannerSpan").style.height = "90px";
	document.getElementById("superBannerSpan").style.width = "728px";
}

function expandFlipbanner(altura)
{
	document.getElementById("flipBanner").style.height = "300px";
	document.getElementById("flipBanner").style.width = "180px";
}
function contractFlipbanner()
{
	document.getElementById("flipBanner").style.height = "100px";
	document.getElementById("flipBanner").style.width = "180px";
}

function expandSelo(altura)
{
	document.getElementById("selo").style.height = altura+"px";
}

function contractSelo()
{
	document.getElementById("selo").style.height = "60px";
}

/* BANNERS */

function Medalhas()
{
	Page = window.open('http://www3.opovo.com.br/medalhas','Medalhas','scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=520,height=600');
	Page.focus();		
}
function Perguntas(perguntasExtras)
{
	Page = window.open('http://www3.opovo.com.br/perguntasExtras/' + perguntasExtras + '.asp','Perguntas','scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=575,height=405');
	Page.focus();		
}
function Feirao()
{
	Page = window.open('http://www.opovo.com.br/wban_banner/feirao.html','Feirao','scrollbars=auto,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=640,height=480');
	Page.focus();
}

function Gourmet()
{
	Page = window.open('http://www.opovo.com.br/opovo/vidaearte/gourmet/index.html','Gourmet','scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=800,height=500');
	Page.focus();
}
function Biblioteca()
{
	Page = window.open('http://www.opovo.com.br/bibliotecaopovo/index.shtml','Biblioteca','scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=720,height=550');
	Page.focus();
}
function Classicos()
{
	window.open('http://www.opovo.com.br/opovo/colecao_classicos/index.html','Classicos','scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=729,height=500');
}
function Blog() {
	window.open('http://www.opovo.com.br/blogpolitica','BlogPolitica');
}
function Cosbel() {
	window.open('http://www.opovo.com.br/wban_banner/cosbel/cosbel.html','Cosbel','scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=400,height=273');
}
function fundaj() {
	window.open('http://www.opovo.com.br/fundaj','Fundaj');
}
function premioibest() {
	window.open('http://www.opovo.com.br/premioibest','PremioiBest');
}
function Entrevista() {
	window.open('http://adm2.opovo.com.br/aovivo','Entrevista');
}
function amdopovo() {
	window.open('http://www.opovo.com.br/amdopovo/aovivo_popup_amdopovo.html','radio','width=300,height=100');
}
function imprime(s)
{
	document.write(s);
}
function expDiv(){
	$('#Xspace').css('height', '300px');
	//$('#slotTopo').css('margin-bottom', '310px');
}
function colDiv(){
	$('#Xspace').css('height', '40px');
	//$('#slotTopo').css('margin-bottom', '50px');
}

function expandxspaceEspecial(largura){
//	alert('teste');
	document.getElementById("Xspace").style.width = "1150px";
}
function contractxspace()
{
	document.getElementById("Xspace").style.width = "960px";
}

function expandBR(){
	$('#bannerRetangulo').css('width', '550px');
	$('#bannerRetangulo').css('overflow', 'visible');
	$('#bannerRetangulo').css('left', '-250px');
}
function contractBR(){
	$('#bannerRetangulo').css('width', '300px');
	$('#bannerRetangulo').css('left', '0');
	$('#bannerRetangulo').css('overflow', 'hidden');
}

var tgs = new Array( 'div','td','tr');
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 1;
function ts( trgt,inc )
{
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 4 ) sz = 4;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}

//Banner Openx

function mostrarBannerOx(zona){
   // var n = {'nome': zona}
   // OA_show('nome');   
    
   var m3_u = (location.protocol=='https:'?'https://banners.opovo.com.br/openx/www/delivery/ajs.php':'http://banners.opovo.com.br/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=" + zona);
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
}

function mbTesteOx(zona){
	var OA_zones = {'zb':zona};
	OA_show('zb');
}

function AbreFutebolVivo(){
			window.open('http://admin3.opovo.com.br/futebol/aovivo.asp','FutebolAoVivo','width=610,height=520,scrollbars=yes');
		}
		
		function fechaDHTML(){
			$(document).ready(function(){
				$('#dhtml').css('display', 'none');
				$('#bannerGaleria').css('display', 'none');
			});
		}
		
		function fechaBarraFull(){
			$(document).ready(function(){
				$('#bannerBarraFull').css('display', 'none');
				$('#bgBarraFull').css('display', 'none');
				$('body').css('margin-bottom', '0px');
			});
		}
		
		
		$(document).ready(function(){
			var b = 0;				
			$('#bannerBarraFull').find('embed').each(function(){
			b = b + 1;
				if (b > 0){
				$('#bannerBarraFull').css('display', 'block');
				$('#bgBarraFull').css('display', 'block');
				$('body').css('margin-bottom', '70px');
				}
			});
			
			$('#bannerBarraFull').find('object').each(function(){
			b = b + 1;
				if (b > 0){
				$('#bannerBarraFull').css('display', 'block');
				$('#bgBarraFull').css('display', 'block');
				$('body').css('margin-bottom', '70px');
				}
			});
			
			var i = 0;				
			$('#dhtml').find('embed').each(function(){
			i = i + 1;
				if (i > 0){
				$('#dhtml').css('display', 'block');
				}
			});
			
			$('#dhtml').find('object').each(function(){
			i = i + 1;
				if (i > 0){
				$('#dhtml').css('display', 'block');
				}
			}); 
			
			$('#cxBannerSelo').find('embed').each(function(){
			i = i + 1;
				if (i > 0){
				$('#cxBannerSelo').css('display', 'block');
				}
			});
			
			$('#cxBannerSelo').find('object').each(function(){
			i = i + 1;
				if (i > 0){
				$('#cxBannerSelo').css('display', 'block');
				}
			});
			
					
			
			var f = 0;				
			$('#flipBanner').find('embed').each(function(){
			f = f + 1;
				if (f > 0){
				$('#flipBanner').css('display', 'block');
				}
			});
			
			$('#flipBanner').find('object').each(function(){
			f = f + 1;
				if (f > 0){
				$('#flipBanner').css('display', 'block');
				}
			});
		});
	
		
		
		
		$(document).ready(function(){
			var i = 0;
			$('.spBanner').find('embed').each(function(){
	        	i++;			                
	           		if(i>0){
	           		$('.spBanner').show();
	           		}        
	                });
	                
	                $('.spBanner').find('object').each(function(){
	                i++;                            
	                       if(i>0){
	                       $('.spBanner').show();
	                       }        
	                    });		        
			});
		
		$(document).ready(function(){				
			var i = 0;				
			$('#Xspace').find('embed').each(function(){
			i = i + 1;
				if (i > 0){
				$('#Xspace').css('display', 'block');
				//$('#slotTopo').css('margin-bottom', '50px');
				}
			});
			
			$('#Xspace').find('object').each(function(){
			i = i + 1;
				if (i > 0){
				$('#Xspace').css('display', 'block');
				//$('#slotTopo').css('margin-bottom', '50px');
				}
			});
		});
		
		$(document).ready(function(){				
			var i = 0;				
			$('#skyScrap').find('div').each(function(){
			i = i + 1;
				if (i > 0){
				$('#skyScrap').css('display', 'block');
				}
			});
			
			$('#skyScrap').find('embed').each(function(){
			i = i + 1;
				if (i > 0){
				$('#skyScrap').css('display', 'block');
				}
			});
			
			$('#skyScrap').find('object').each(function(){
			i = i + 1;
				if (i > 0){
				$('#skyScrap').css('display', 'block');
				}
			});	
			
			$('#listaCalendario').click(function(){
				$('#abaCalendario').show();
				$('#abaPilotos').hide();
				$('#abaEquipe').hide();
				$('#listaCalendario').addClass('itemAtivo');
				$('#listaPilotos').removeClass('itemAtivo');
				$('#listaEquipe').removeClass('itemAtivo');
			});
			
			$('#listaPilotos').click(function(){
				$('#abaCalendario').hide();
				$('#abaPilotos').show();
				$('#abaEquipe').hide();
				$('#listaCalendario').removeClass('itemAtivo');
				$('#listaPilotos').addClass('itemAtivo');
				$('#listaEquipe').removeClass('itemAtivo');
			});
			
			$('#listaEquipe').click(function(){
				$('#abaCalendario').hide();
				$('#abaPilotos').hide();
				$('#abaEquipe').show();
				$('#listaCalendario').removeClass('itemAtivo');
				$('#listaPilotos').removeClass('itemAtivo');
				$('#listaEquipe').addClass('itemAtivo');
			});
			
			var $one = $('#spOne').children('div');
				($one.length > 0) ? $('#spOne').show() : $('#spOne').hide();
		
			var $two = $('#spTwo').children('div');
				($two.length > 0) ? $('#spTwo').show() : $('#spTwo').hide();
				
			var $three = $('#spThree').children('div');
				($three.length > 0) ? $('#spThree').show() : $('#spThree').hide();
				
			var $four = $('#spFour').children('div');
				($four.length > 0) ? $('#spFour').show() : $('#spFour').hide();
				
			var $five = $('#spFive').children('div');
				($five.length > 0) ? $('#spFive').show() : $('#spFive').hide();
			
			var $cxBS = $('.cxBannerSelo').children('div');
				($cxBS.length > 0) ? $('.cxBannerSelo').show() : $('.cxBannerSelo').hide();

		});

//Caixa SMS Canais
	function cadSMS(dados){		
		var dados_s = dados.split('_');
		
		var step  = dados_s[0];
		var canal = dados_s[1];		

		$(document).ready(function(){				
				var md5    = $('#md5_'+step+'_'+canal).val();
				var cid    = $('#cid_'+step+'_'+canal).val();
				var ddd    = $('#ddd_'+step+'_'+canal).val();
				var fone   = $('#fone_'+step+'_'+canal).val();
				var msisdn = ddd+fone;
				var carr   = $('#opera_'+step+'_'+canal).val();
				var aceito = $('#aceito_'+step+'_'+canal).is(':checked');
				var urlenv = 'http://nextsms.supportcomm.com.br/midia/api_pin.php';
				var pin    = $('#senha_'+step+'_'+canal).val();
				
				if(step == 's1'){
					var check = ((ddd == '') || (ddd == 'DDD')) || ((fone == '') || (fone == 'Seu numero')) || (carr == '');
				}else{
					var check = ((ddd == '') || (ddd == 'DDD')) || ((fone == '') || (fone == 'Seu numero')) || (carr == '') || ((pin == '')||(pin == 'Digite sua senha'));
					var aceito = true;
				}
				
				//alert(step);
								
				var tudo = 'MD5 = '+md5+'\n CID = '+cid+'\n DDD = '+ddd+'\n FONE = '+fone+'\n OPERADORA = '+carr+'\n SENHA = '+pin;
				
				//alert(tudo);
				//alert(aceito);
				
				if(!check && aceito){
						if(step == 's1'){
							var data   = 'md5='+md5+'&parc=56&cid='+cid+'&step=send_code&carrier_integ='+carr+'&msisdn=55'+msisdn;
						}		
						else{
							var data   = 'md5='+md5+'&parc=56&cid='+cid+'&step=check_code&carrier_integ='+carr+'&msisdn=55'+msisdn+'&pincode='+pin;
						}
						
						$.ajax({
						type:"GET",
						url:urlenv,
						data:data							
						});
					$('#stepOne').hide();
					$('#stepTwo').show();
				}else{ 
					if(check && !aceito){
							alert('Preencha todos os campos!');
					}else if(check && aceito){
							alert('Preencha todos os campos!');				
					}else if(!check && !aceito){
							alert('Você deve marcar a caixa (li e aceito)');
					}
				}
		});
	}
	$(document).ready(function(){
		$('#next').click(function(){
			$('#stepOne').hide();
			$('#stepTwo').show();
		});
		$('#prev').click(function(){
			$('#stepOne').show();
			$('#stepTwo').hide();
		});
	});
	
	function clF(campo){
		var texto = ['DDD', 'Seu numero', 'Digite sua senha'];
		var valor = $('#'+campo).val();
		switch(valor){
			case texto[0]: $('#'+campo).val('');
			case texto[1]: $('#'+campo).val('');
			case texto[2]: $('#'+campo).val('');
		}
	}
	
//TVOPOVO e FOTOPOVO
	$(document).ready(function(){
			$('#abaTV').click(function(){
				$('#blocoVid').css('display', 'block');
				$('#blocoFotOPOVO').css('display', 'none');
				//$('#outrosVideos').show();
				//$('#outrasFotos').hide();
				
				$('#abaFoto').removeClass('ativa');
				$('#abaTV').addClass('ativa');
				$('#imgDestaque').attr('src', 'http://imgs.opovo.com.br/imgs/bgDestaqueTV.gif');
			});
			$('#abaFoto').click(function(){
				$('#blocoFotOPOVO').css('display', 'block');
				$('#blocoVid').css('display', 'none');
				//$('#outrosVideos').hide();
				//$('#outrasFotos').show()
				
				$('#abaTV').removeClass('ativa');
				$('#abaFoto').addClass('ativa');
				$('#imgDestaque').attr('src', 'http://imgs.opovo.com.br/imgs/bgDestaqueCamera.gif');
			});
			
			$('.showVid').click(function(){
				var src     = $(this).attr('src');
				var href    = $(this).attr('link');
				var title   = $(this).attr('title');
				var cart    = $(this).attr('cart');
				
				$('#viewVid').attr('src', src);
				$('#lkvideo').attr('href', href);
				$('#lkimgvid').attr('href', href);
				$('#lkvideo').text(title);
				$('#cartvideo').text(cart);
			});
			
			$('.showFot').click(function(){
				var src     = $(this).attr('src');
				var href    = $(this).attr('link');
				var title   = $(this).attr('title');
				var cart    = $(this).attr('cart');
				
				$('#viewFot').attr('src', src);
				$('#titfoto').attr('href', href);
				$('#lkimgFot').attr('href', href);
				$('#titfoto').text(title);
				$('#cartfoto').text(cart);
			});
	});
	
function expandFlipBannerDestaque()
{
	document.getElementById("flipBannerDestaque").style.clip = "auto";
}
function contractFlipBannerDestaque()
{
	document.getElementById("flipBannerDestaque").style.clip = "rect(0px, 772px, 64px, 708px)";
}

function expandBannerRetangulo()
{
	document.getElementById("bannerRetanguloSpan").style.clip = "auto";
}
function contractBannerRetangulo()
{
	document.getElementById("bannerRetanguloSpan").style.clip = "rect(0px, 600px, 250px, 301px)";
}

function expandBannerEtiqueta()
{
	document.getElementById("bannerEtiqueta").style.width = "340px";
	document.getElementById("bannerEtiqueta").style.height = "250px";
}
function contractBannerEtiqueta()
{
	document.getElementById("bannerEtiqueta").style.width = "40px";
	document.getElementById("bannerEtiqueta").style.height = "145px";
}

