// JavaScript Document

	var divPopup = {}
	divPopup.o = 0;
	divPopup.w = 0;
	divPopup.h = 0;

	function abreMenu(obj, w, h)
	{
		obj.style.width  = w + 'px';
		obj.style.height = h + 'px';
	}
	
	function fechaMenu(obj, w, h)
	{
		obj.style.width  = w + 'px';
		obj.style.height = h + 'px';
	}
	
	function fechaMenu2(obj, w, h)
	{
		divPopup.o = obj;
		divPopup.w = w;
		divPopup.h = h;
		animacao = setInterval(function()
		{
			divPopup.o.style.width  = divPopup.w + 'px';
			divPopup.o.style.height = divPopup.h + 'px';
			clearInterval(animacao);
		}, 1500);
	}
	
	//Chama flash no site (correção do IE)
	function exibeFash(swf, width, height, flashvar, wmode, cache)
	{
		noCache  = cache    || cache    == undefined ? "" : "?" + new Date();
		wmode    = wmode    || wmode    == undefined ? "opaque" : "transparent";
		flashvar =             flashvar == undefined ? "" : flashvar;
		
		monta_swf  = "";
		monta_swf += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+ width +"\" height=\""+ height +"\" title=\"Header\">";
		monta_swf += "<param name=\"movie\" value=\""+ swf + noCache +"\" />";
		monta_swf += "<param name=\"quality\" value=\"high\" />";
		monta_swf += "<param name=\"wmode\" value=\""+ wmode +"\" />";
		monta_swf += "<param name=\"flashvars\" value=\""+ flashvar +"\" />";
		monta_swf += "<embed src=\""+ swf + noCache +"\" flashvars= \""+ flashvar +"\"quality=\"high\" wmode=\""+ wmode +"\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+ width +"\" height=\""+ height +"\"></embed>";
		monta_swf += "</object>";
		
		document.write(monta_swf);
	}
	
	// Muda o tamanho da fonte do conteúdo
	function selectStyle(tit, obj){
		// Muda o destaque de posição
		c = 0;
		getA = document.getElementsByTagName("a");
		for(var i=0; i<getA.length; i++)
		{
			if(getA[i].className.substr(0, 2) == "px")
			{
				if(getA[i] != obj)
				{
					getA[i].className = "px1"+c;
				}
				else
				{
					getA[i].className = "px1"+c+" destaque";
				}
				c++
			}
		}
		
		// Habilidar e desabilitar o stylesheet
		var ct = document.getElementById("conteudo");
		ct.className = tit;
		
		/*alert(ct.className)*/
	}
	
	var count = 0;
	// Função que faz o banner aparecer ou sumir de acordo com a resolução do usuário
	function alinhaBanner()
	{
		// Checka o browser e calcula o tamanho da tela
		var isNetscape = navigator.appName=="Netscape";
		if (isNetscape) 
		{
			w = window.innerWidth;
			h = window.innerHeight;
		} 
		else 
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
		
		sky = document.getElementById('skyscraper');
		rM = document.getElementById('resolucaoMaior');
		
		if(rM != undefined || sky != undefined)
		{
			if(w < 960)
			{
				rM.style.width = '768px';
				sky.style.display = 'none';
			}
			else if(count > 0)
			{
				rM.style.width = '940px';
				sky.style.display = 'block';
			}
		}
		count++;
	}
	
	function inicializa()
	{
		alinhaBanner();
	}
	
	onresize=alinhaBanner;
	onload=inicializa;
	
	
/*******************************************************************************************************************************\
		GALERIA DE FOTOS DOS ESPECIAIS *****************************************************************************************|
\*******************************************************************************************************************************/

		conta_galeria = 0;
		var isNetscape = navigator.appName=="Netscape";
		function mudaGaleria(action)
		{
			if(isNetscape)
			{
				galeria = document.getElementById('galeria');
			}
			imagens = galeria.getElementsByTagName('div');
			
			conta_galeria = action == "+" ? parseInt(conta_galeria)+1 : parseInt(conta_galeria)-1;
			conta_galeria = parseInt(conta_galeria) < 0 || parseInt(conta_galeria) > imagens.length-1 ? parseInt(conta_galeria) < 0 ? imagens.length-1 : 0 : parseInt(conta_galeria);
			
			for(var i=0; i<imagens.length; i++)
			{
				imagens[i].style.display = conta_galeria != i ? "none" : "block";
			}
			
			texto = galeria.getElementsByTagName("b")[0];
			texto.innerHTML = (conta_galeria+1) + " de " + imagens.length;
		}
		
		function mostraResultado()
		{
			if(isNetscape)
			{
				galeria = document.getElementById('galeria');
			}
			
			imagens = galeria.getElementsByTagName('div')
			
			document.write((parseInt(conta_galeria)+1) + " de " + imagens.length);
		}
		
		
		function abrePop(url, w, h)
		{
			w += 20;
			h += 25;
			centerX = (screen.width-w)/2;
			centerY = (screen.height-h)/2;
			window.open(url, 'ampliar', 'width='+w+', height='+h+', top='+centerY+', left='+centerX+'');
		}
	
/*******************************************************************************************************************************\
		FUNÇÕES ANTIGAS DO SITE ************************************************************************************************|
\*******************************************************************************************************************************/
	
	
	function verificaEmail(mail)
	{
		str = new String(mail);
		
		if (str.charAt(str.length-1) == '.') {// Ultimo caracter é ponto
			return false;
		}
		
		var arroba = str.indexOf('@',0);
		if (arroba > 0){ // Tem arroba
			var ponto = str.indexOf('.',arroba);                                           
			if (ponto > 0){ // Tem ponto
				if (str.length-1 > ponto){ // Tem algo depois do ponto
					if ((arroba + 1) != ponto){ // Tem algo entre a arroba e o ponto
						// É um E-mail !!!
						return true;
					}
					return false;
				}
				return false;
			}
			return false;
		}
		return false;
	}
	
	
	function alertaEmail(objeto) {
		if(objeto.value != '') {
			var controle = verificaEmail(objeto.value);
			if(controle === false) {
				alert('Digite um endereço de e-mail válido!');
				objeto.focus();
				objeto.select();
				return false;
			} else {
				return true;
			}
		}
	}
	
	function abreJanela(url, name, height, width,scrollbars) {
	  var str = "height=" + height + ",innerHeight=" + height;
	  str += ",width=" + width + ",innerWidth=" + width + ',resizable=yes,scrollbars=' + scrollbars + ',menubar=no,status=no';
	  if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 5;
	
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;
	
		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	  }
	  window.open(url, name, str);
	}
	
	
	function abreJanelaGaleria(url, name) {
	  var str = "resizable=yes,scrollbars=yes,menubar=no,status=no, left=10, top=10, width=200, height=200";
	  window.open(url, name, str);
	}
	
	// O BLOCO DE FUNÇÕES ABAIXO VALIDA AS DATAS CRIADAS PELA CLASSE COMBO_DATA DO PHP
	var obData	= new Date();
	var focoDia = new String(obData.getDate());
	var focoMes = new String(obData.getMonth());
	var focoAno = new String(obData.getFullYear());
	
	function focusData(obDia, obMes, obAno) {
		focoDia = obDia.value;
		focoMes = obMes.value;
		focoAno = obAno.value;
	}
	
	function verificaData(obDia, obMes, obAno) {
		var dia = obDia.value;
		var mes = obMes.value;
		var ano = obAno.value;
		var controle = true;
		
		switch(mes) {
			case '02':
				ano = ano % 4;
				if (ano > 0) { // se não for ano bissexto
					if (dia >= 29) { controle = false; }
				} else {
					if (dia >= 30) { controle = false; }			
				}
			break;
	
			case '04':
			case '06':
			case '09':
			case '11':
				if (dia == 31) { controle = false; }
			break;
		}
		
		if(controle === false) {
			alert('A data selecionada não é válida!');
			obDia.value = focoDia;
			obMes.value = focoMes;
			obAno.value = focoAno;
			return false;
		} else { return true; }
	}
	// AQUI TERMINA O BLOCO DE FUNÇÕES QUE VALIDAM DATA
	
	function buscaSite() {
		valor = document.busca.it_busca.value;
		if (valor.length == 0) {
			alert ("Por favor, digite um texto para realizar a busca !!!");
			return false;
			//this.location = '../home/index.php';
		} else {
			this.location = '../busca/index.php?texto_busca=' + valor;
			return false;
		}    
	/*
		valor = objeto.value;
		this.location = '../busca/index.php?texto_busca=' + valor;
	*/    
	}	
	
	function buscaSiteOffice() {
		valor = document.buscaOffice.it_buscaOffice.value;
		if (valor.length == 0) {
			alert ("Por favor, digite um texto para realizar a busca !!!");
			return false;
			//this.location = '../home/index.php';
		} else {
			this.location = '../busca/index.php?texto_busca=' + valor;
			return false;
		}    
	/*
		valor = objeto.value;
		this.location = '../busca/index.php?texto_busca=' + valor;
	*/    
	}
	
	function votar(secao) {
		voto = 0;
		qtd  = document.form.enquete.length;
		
		for(i=0; i < qtd; i++) {
			if(document.form.enquete[i].checked === true) {
				voto = i + 1;
			}
		}
	
		if(voto > 0) {
			abreJanela('../enquetes/materia.php?id_secao='+secao+'&id_conteudo='+voto,'enquete', 284, 408, 'auto');
			document.form.enquete[voto - 1].checked = false;
		} else {
			alert('Selecione qual das opções corresponde à sua opção de resposta!');
		}
	}
	
	function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
		var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
	
		// bloqueia caracteres especiais e letras, aceita somente numeros
		if((event.keyCode > 32 && event.keyCode < 48) ||
		   (event.keyCode > 57 && event.keyCode < 65) ||
		   (event.keyCode > 90 && event.keyCode < 97) ||
		   (event.keyCode < 45 || event.keyCode > 57)){
				event.returnValue = false;
		}
	
		/*if(document.all) { // Internet Explorer
			nTecla = evtKeyPress.keyCode;
		} else if(document.layers) { // Nestcape
			nTecla = evtKeyPress.which;
		}*/
	
		// Internet Explorer, Netscape e Opera
		var nTecla = evtKeyPress.keyCode ? evtKeyPress.keyCode : evtKeyPress.which ? evtKeyPress.which : evtKeyPress.charCode;
	
	
		sValue = objForm[strField].value;
	
		// Limpa todos os caracteres de formatação que
		// já estiverem no campo.
		sValue = sValue.toString().replace( "-", "" );
		sValue = sValue.toString().replace( "-", "" );
		sValue = sValue.toString().replace( ".", "" );
		sValue = sValue.toString().replace( ".", "" );
		sValue = sValue.toString().replace( "/", "" );
		sValue = sValue.toString().replace( "/", "" );
		sValue = sValue.toString().replace( "(", "" );
		sValue = sValue.toString().replace( "(", "" );
		sValue = sValue.toString().replace( ")", "" );
		sValue = sValue.toString().replace( ")", "" );
		sValue = sValue.toString().replace( " ", "" );
		sValue = sValue.toString().replace( " ", "" );
		fldLen = sValue.length;
		mskLen = sMask.length;
	
		i = 0;
		nCount = 0;
		sCod = "";
		mskLen = fldLen;
	
		while (i <= mskLen) {
			bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
			bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
	
			if (bolMask) {
				sCod += sMask.charAt(i);
				mskLen++;
			} else {
				sCod += sValue.charAt(nCount);
				nCount++;
			}
	
			i++;
		}
	
		objForm[strField].value = sCod;
	
		if (nTecla != 8) { // backspace
			if (sMask.charAt(i-1) == "9") { // apenas números...
				return ((nTecla > 47) && (nTecla < 58)); // números de 0 a 9
			} else { // qualquer caracter...
				return true;
			}
		} else {
			return true;
		}
	}
	
	function mascaraMoeda(formulario, campo, maximo, evento)
	{
		// Internet Explorer, Netscape e Opera
		var tecla = evento.keyCode ? evento.keyCode : evento.which ? evento.which : evento.charCode;
		valor   = formulario[campo].value;
		valor   = valor.replace( "/", "" );
		valor   = valor.replace( "/", "" );
		valor   = valor.replace( ",", "" );
		valor   = valor.replace( ".", "" );
		valor   = valor.replace( ".", "" );
		valor   = valor.replace( ".", "" );
		valor   = valor.replace( ".", "" );
		tamanho = valor.length;
	
		if (tamanho < maximo && tecla != 8)
		{
			tamanho = valor.length + 1;
		}
		if (tecla == 8)
		{
			tamanho = tamanho - 1;
		}
		if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
		{
			if ( tamanho <= 2 )
			{
				formulario[campo].value = valor;
			}
			if ( (tamanho > 2) && (tamanho <= 5) )
			{
				formulario[campo].value = valor.substr( 0, tamanho - 2 ) + ',' + valor.substr( tamanho - 2, tamanho );
			}
			if ( (tamanho >= 6) && (tamanho <= 8) )
			{
				formulario[campo].value = valor.substr( 0, tamanho - 5 ) + '.' + valor.substr( tamanho - 5, 3 ) + ',' + valor.substr( tamanho - 2, tamanho );
			}
			if ( (tamanho >= 9) && (tamanho <= 12) )
			{
				formulario[campo].value = valor.substr( 0, tamanho - 8 ) + '.' + valor.substr( tamanho - 8, 3 ) + '.' + valor.substr( tamanho - 5, 3 ) + ',' + valor.substr( tamanho - 2, tamanho );
			}
			if ( (tamanho >= 13) && (tamanho <= 16) )
			{
				formulario[campo].value = valor.substr( 0, tamanho - 11 ) + '.' + valor.substr( tamanho - 11, 3 ) + '.' + valor.substr( tamanho - 8, 3 ) + '.' + valor.substr( tamanho - 5, 3 ) + ',' + valor.substr( tamanho - 2, tamanho );
			}
		} else {
			evento.returnValue = false;
		}
	}
	
//BOX DA HANZO
function setAction(carrierId, hanzo_form) {
 	if (carrierId == '9999') {
 		var channelSelected = hanzo_form.channelId.selectedIndex;
		 window.open(' http://200.155.11.162/hanzo/vivo_WNews.html', 'result', 'toolbar=no,width=227,height=190');
 		//window.open('http://www.wnews.com.br/site/hanzo/vivo_WNews.html ', 'result', 'toolbar=no,width=227,height=190');
 		hanzo_form.mobile.value="";
 		hanzo_form.mobile.disabled=true;
 		hanzo_form.carrierId.selectedIndex=0;
 		} else if (carrierId == '0') { 
 			hanzo_form.mobile.disabled=true;
 		} else {
 			hanzo_form.mobile.disabled=false;
 			}
		}


function manda(hanzo_form) {
 	if (hanzo_form.carrierId.value=='9999'){
 		var channelSelected = hanzo_form.channelId.selectedIndex; 
 		window.open('http://200.155.11.162/hanzo/vivo_WNews.html', 'result', 'toolbar=no,width=227,height=190');
 		//window.open(' http://www.wnews.com.br/site/hanzo/vivo_WNews.html', 'result', 'toolbar=no,width=227,height=190');
 		} else {
 		hanzo_form.submit();
 	}
}

// FIM BOX DA HANZO
function setAction2(carrierId) {
	if (carrierId == '9999') {
		var channelSelected = document.forms["subscribeForm"].channelId.selectedIndex;
		//window.open('http://200.155.11.162/hanzo/vivo_WNews.html', 'result', 'toolbar=no,width=227,height=190');
		window.open('http://www.wnews.com.br/site/hanzo/vivo_WNews_.html', 'result', 'toolbar=no,width=227,height=190');
		document.forms["subscribeForm"].mobile.value="";
		document.forms["subscribeForm"].mobile.disabled=true;
		document.forms["subscribeForm"].carrierId.selectedIndex=0;
	} else if (carrierId == '0') {
		document.forms["subscribeForm"].mobile.disabled=true;
	} else {
		document.forms["subscribeForm"].mobile.disabled=false;
	}
}

function manda2() {
	if (document.forms["subscribeForm"].carrierId.value=='9999'){
		var channelSelected = document.forms["subscribeForm"].channelId.selectedIndex;
		//window.open('http://200.155.11.162/hanzo/vivo_WNews.html', 'result', 'toolbar=no,width=227,height=190');
		window.open('http://www.wnews.com.br/site/hanzo/vivo_WNews_.html', 'result', 'toolbar=no,width=227,height=190');
	} else {
		document.forms["subscribeForm"].submit();
	}
}