// JavaScript Document
function PageView(IdZona){
		 Ext.Ajax.request({
		 	url: '/sscripts/pageviews.class.php',
		 	params:{ op: 'new', IdZona: IdZona }
		 });
}

function Especial(pasta){
	window.open(pasta,"","width=750,height=550,scrollbars=no,status=yes");
	PageView(1);
}


/////////////////////////////// HOROSCOPO
function CarregaHoroscopo(){
	horoscopo.url = '/otempo/scripts/acoes.php?op=capa_horoscopo&x='+Math.random();
	horoscopo.modo = 'X';
	horoscopo.processaresultado = function(xmldoc) {	
									var nos  = xmldoc.getElementsByTagName('Signoo');
									if(xmldoc.hasChildNodes()&&nos.length>0) {
										for(var i=0;i<nos.length;i++) {
											var no = nos[i];
											var Imagem = no.childNodes[0].firstChild.nodeValue;
											var Signo = no.childNodes[1].firstChild.nodeValue;
											var Horoscopo = no.childNodes[2].firstChild.nodeValue;
											vetorHoroscopo[i]=Array(Imagem,Signo,Horoscopo);
										}
									}
									MostraHoroscopo();
									intervaloHoroscopo=setInterval("MostraHoroscopo()",speedHoroscopo);
								  }
	horoscopo.conectar();
}

function MostraHoroscopo(stt){
	if(stt==undefined){
		if(posicaoHoroscopo==undefined) posicaoHoroscopo=0;
		
		document.getElementById('horoscopo_span').innerHTML=
		    '<a onMouseOver="Javascript:MostraHoroscopo(\'Pause\')" onMouseOut="Javascript:MostraHoroscopo(\'Play\')"><img src="/otempo/img/'+vetorHoroscopo[posicaoHoroscopo][0]+'" width="70" height="70" border="0" align="left"></a><b class="Verde">'+vetorHoroscopo[posicaoHoroscopo][1]+'</b><br><br>'+vetorHoroscopo[posicaoHoroscopo][2];
		
		posicaoHoroscopo=posicaoHoroscopo+1;
		if(posicaoHoroscopo==vetorHoroscopo.length) posicaoHoroscopo=0;
		
	} else {
		clearInterval(intervaloHoroscopo);
		if(stt!="Pause"){
			if(stt=="anterior")	posicaoHoroscopo=posicaoHoroscopo-2;
			if(posicaoHoroscopo==-1) posicaoHoroscopo=vetorHoroscopo.length-1;
			if(posicaoHoroscopo==-2) posicaoHoroscopo=vetorHoroscopo.length-2;			
			MostraHoroscopo();
			intervaloHoroscopo=setInterval("MostraHoroscopo()",speedHoroscopo);
		}
	}
}

/////////////////////////////// FOTOS DO DIA
function CarregaFotosDia(IdEdicao,pastaup){
	pastaFotosDia=pastaup;
	fotosdia.url = '/otempo/scripts/acoes.php?op=capa_fotosdia&IdEdicao='+IdEdicao+'&x='+Math.random();
	fotosdia.modo = 'X';
	fotosdia.processaresultado = function(xmldoc) {	
									var nos  = xmldoc.getElementsByTagName('FotoDia');
									if(xmldoc.hasChildNodes()&&nos.length>0) {
										for(var i=0;i<nos.length;i++) {
											var no = nos[i];
											if(no.childNodes[0].firstChild) var foto1 = no.childNodes[0].firstChild.nodeValue;
											if(no.childNodes[1].firstChild) var legenda1 = no.childNodes[1].firstChild.nodeValue;
											if(no.childNodes[2].firstChild) var credito1 = no.childNodes[2].firstChild.nodeValue;
											if(no.childNodes[3].firstChild) var foto2 = no.childNodes[3].firstChild.nodeValue;
											if(no.childNodes[4].firstChild) var legenda2 = no.childNodes[4].firstChild.nodeValue;
											if(no.childNodes[5].firstChild) var credito2 = no.childNodes[5].firstChild.nodeValue;
											if(no.childNodes[6].firstChild) var foto3 = no.childNodes[6].firstChild.nodeValue;
											if(no.childNodes[7].firstChild) var legenda3 = no.childNodes[7].firstChild.nodeValue;
											if(no.childNodes[8].firstChild) var credito3 = no.childNodes[8].firstChild.nodeValue;
											if(foto1!=undefined) vetorFotosDia[0]=Array(foto1,legenda1,credito1);
											if(foto2!=undefined) vetorFotosDia[1]=Array(foto2,legenda2,credito2);
											if(foto3!=undefined) vetorFotosDia[2]=Array(foto3,legenda3,credito3);
										}
									}
									MostraFotosDia();
									intervaloFotosDia=setInterval("MostraFotosDia()",speedFotosDia);
								  }
	fotosdia.conectar();
}

function MostraFotosDia(stt){
	if(stt==undefined){
			
		if(vetorFotosDia==undefined||vetorFotosDia=="") {
			document.getElementById('url_fotodia').innerHTML="Nenhuma foto cadastrada";
			document.getElementById('bt_fotodia').style.display="none";
			return false;
		}
		
		if(posicaoFotosDia==undefined) posicaoFotosDia=0;
				//Foto
				document.getElementById('img_fotodia').src='/otempo/scripts/diminuator.php?pasta='+pastaFotosDia+'&arquivo='+vetorFotosDia[posicaoFotosDia][0]+'&w=160';
				document.getElementById('img_fotodia').alt=vetorFotosDia[posicaoFotosDia][2];
				document.getElementById('img_fotodia').caption=vetorFotosDia[posicaoFotosDia][2];
				document.getElementById('url_fotodia').href='/otempo/fotos/'+pastaFotosDia+'/'+vetorFotosDia[posicaoFotosDia][0];
				document.getElementById('url_fotodia').title=vetorFotosDia[posicaoFotosDia][1];
				//Legenda
				document.getElementById('url_fotodia2').innerHTML=vetorFotosDia[posicaoFotosDia][1];
				document.getElementById('url_fotodia2').title=vetorFotosDia[posicaoFotosDia][1];
				document.getElementById('url_fotodia2').href='/otempo/fotos/'+pastaFotosDia+'/'+vetorFotosDia[posicaoFotosDia][0];
		
		posicaoFotosDia=posicaoFotosDia+1;
		if(posicaoFotosDia==vetorFotosDia.length) posicaoFotosDia=0;
		
	} else {
		clearInterval(intervaloFotosDia);
		if(stt!="Pause"){
			if(stt=="anterior")	posicaoFotosDia=posicaoFotosDia-2;
			if(posicaoFotosDia==-1) posicaoFotosDia=vetorFotosDia.length-1;
			if(posicaoFotosDia==-2) posicaoFotosDia=vetorFotosDia.length-2;			
			MostraFotosDia();
			intervaloFotosDia=setInterval("MostraFotosDia()",speedFotosDia);
		}
	}
}

/////////////////////////////// EM TEMPO
function CarregaEmtempo(){
	emtempo.url = '/otempo/scripts/acoes.php?op=capa_emtempo&x='+Math.random();
	emtempo.modo = 'X';
	emtempo.processaresultado = function(xmldoc) {	
									var nos  = xmldoc.getElementsByTagName('Ultimas');
									if(xmldoc.hasChildNodes()&&nos.length>0) {
										for(var i=0;i<nos.length;i++) {
											var no = nos[i];
											Descricao = no.childNodes[0].firstChild.nodeValue;
											Url = no.childNodes[1].firstChild.nodeValue;
											IdNoticia= no.childNodes[2].firstChild.nodeValue;
											Titulo = no.childNodes[3].firstChild.nodeValue;
											vetorEmtempo[i]=Array(Descricao,Url,IdNoticia,Titulo);
										}
									}
									MostraEmtempo();
									intervaloEmtempo=setInterval("MostraEmtempo()",speedEmtempo);
								  }
	emtempo.conectar();
}

function MostraEmtempo(){	
	if(posicaoEmtempo==undefined) posicaoEmtempo=0;
	
	ultima='<font color="#FFCC00"<b>'+vetorEmtempo[posicaoEmtempo][0]+'</b></font>&nbsp;&raquo;&nbsp;<a href="'+vetorEmtempo[posicaoEmtempo][1]+'?IdNoticia='+vetorEmtempo[posicaoEmtempo][2]+'" class="Branco">'+vetorEmtempo[posicaoEmtempo][3]+'</a>';
	
	//Legenda
	document.getElementById('emtempo').innerHTML=ultima;
	
	posicaoEmtempo=posicaoEmtempo+1;
	if(posicaoEmtempo==vetorEmtempo.length) posicaoEmtempo=0;
}

/////////////////////////////// HOTSITES
function CarregaHotsites(){
	hotsites.url = '/otempo/scripts/acoes.php?op=capa_hotsites&x='+Math.random();
	hotsites.modo = 'X';
	hotsites.processaresultado = function(xmldoc) {	
									var nos  = xmldoc.getElementsByTagName('Hotsite');
									if(xmldoc.hasChildNodes()&&nos.length>0) {
										for(var i=0;i<nos.length;i++) {
											var no = nos[i];
											var Imagem = no.childNodes[0].firstChild.nodeValue;
											var Url = no.childNodes[1].firstChild.nodeValue;
											var Popup = no.childNodes[2].firstChild.nodeValue;
											var LarguraJanela = no.childNodes[3].firstChild.nodeValue;
											var AlturaJanela = no.childNodes[4].firstChild.nodeValue;
											vetorHotsites[i]=Array(Imagem,Url,Popup,LarguraJanela,AlturaJanela);
										}
									}
									MostraHotsites();
									//intervaloHotsites=setInterval("MostraHotsites()",speedHotsites);
								  }
	hotsites.conectar();
}

function MostraHotsites(stt){
	if(stt==undefined){
		if(posicaoHotsites==undefined) posicaoHotsites=0;
		
		if(vetorHotsites[posicaoHotsites][2]=="1"){
			vLink='<a href="Javascript:Hotsites(\''+vetorHotsites[posicaoHotsites][1]+'\',\''+vetorHotsites[posicaoHotsites][3]+'\',\''+vetorHotsites[posicaoHotsites][4]+'\')">';
		}else{
			vLink='<a href="'+vetorHotsites[posicaoHotsites][1]+'" target="_blank">';
		}
		
		document.getElementById('span_hotsites').innerHTML=vLink+'<img src="/otempo/img/hotsites/'+vetorHotsites[posicaoHotsites][0]+'" border="0"></a>';
		
		posicaoHotsites=posicaoHotsites+1;
		if(posicaoHotsites==vetorHotsites.length) posicaoHotsites=0;
		
	} else {
		//clearInterval(intervaloHotsites);
		if(stt!="Pause"){
			if(stt=="anterior")	posicaoHotsites=posicaoHotsites-2;
			if(posicaoHotsites==-1) posicaoHotsites=vetorHotsites.length-1;
			if(posicaoHotsites==-2) posicaoHotsites=vetorHotsites.length-2;			
			MostraHotsites();
			//intervaloHotsites=setInterval("MostraHotsites()",speedHotsites);
		}
	}
}

function Jornais(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="180" height="80">');
	document.write('<param name="movie" value="/admgeral/img/jornais.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="flashvars" value="jornal=otempo">');
	document.write('<embed src="/admgeral/img/jornais.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="180" height="80" flashvars="jornal=otempo" wmode="transparent"></embed>');
	document.write('</object>');
}

function Flash(imagem,largura,altura,wmode,flashvars){
	wmode = wmode || 'transparent';
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+largura+'" height="'+altura+'">');
	document.write('<param name="movie" value="'+imagem+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="'+wmode+'">');
	if(flashvars!="") document.write('<param name="flashvars" value="'+flashvars+'">');
	document.write('<embed src="'+imagem+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+largura+'" height="'+altura+'" wmode="'+wmode+'" flashvars="'+flashvars+'"></embed>');
	document.write('</object>');
}

function MostraEnquete(IdEnquete){
		window.open("/capa/enquete.php?IdEnquete="+IdEnquete+"&Voto=","enquete","width=400,height=500,scrollbars=no,status=yes");
		PageView(1);
}

function Chat(IdEntrevista){
	var largura_pagina = window.screen.width;
	var left = eval((largura_pagina/2)-370);
	var top = 30;		
	window.open("/chat/?IdEntrevista="+IdEntrevista,"","width=750,height=550,scrollbars=no,status=yes,top="+top+",left="+left);
		PageView(1);
}