// JavaScript Document




// -------------------------------------------------------------------------------------------------------------
// Codificação e Decodificação UTF-8
UTF8 = {
	encode: function(s){
		for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
			s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
		);
		return s.join("");
	},
	decode: function(s){
		for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
			((a = s[i][c](0)) & 0x80) &&
			(s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
			o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
		);
		return s.join("");
	}
};
//exemplo
// funciona tanto o teste quanto o teste2
function teste(n){
	document.write(
	
		UTF8.decode(UTF8.encode(n))
		
	);
}
function teste2(x){
	document.write(

x
		
	);
}
// -------------------------------------------------------------------------------------------------------------


// -------------------------------------------------------------------------------------------------------------
// abre pop up modelo: http://forum.wmonline.com.br/index.php?showtopic=38061
function abrir(pagina,largura,altura) {

//pega a resolução do visitante
w = screen.width;
h = screen.height;

//divide a resolução por 2, obtendo o centro do monitor
meio_w = w/2;
meio_h = h/2;

//diminui o valor da metade da resolução pelo tamanho da janela, fazendo com q ela fique centralizada
altura2 = altura/2;
largura2 = largura/2;
meio1 = meio_h-altura2;
meio2 = meio_w-largura2;

//abre a nova janela, já com a sua devida posição
window.open(pagina,'','height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+''); 
}

// abre pop up modelo: DW
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// -------------------------------------------------------------------------------------------------------------


// -------------------------------------------------------------------------------------------------------------
// Adicionar aos favoritos cross browser
function Favoritos(pagina,titulo,descricao){

// Gecko (Mozilla, Firefox, Firebird & Netscape)
if(window.sidebar)document.write("<a href=\"javascript:window.sidebar.addPanel('"+titulo+"','"+pagina+"','');\">"+descricao+"</a>");
else
// Internet Explorer
if(window.external)document.write("<a href=\"javascript:window.external.AddFavorite('"+pagina+"','"+titulo+"');\">"+descricao+"</a>");
else
// Opera & Outros
document.write("<a href='"+pagina+"' rel='sidebar' title='"+titulo+"'>"+descricao+"</a>");
}
// fonte: http://forum.wmonline.com.br/index.php?showtopic=116594
// -------------------------------------------------------------------------------------------------------------



// -------------------------------------------------------------------------------------------------------------
// CSS alternativos
function setActiveStyleSheet(title) {
var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			
		if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
}
// -------------------------------------------------------------------------------------------------------------




// -------------------------------------------------------------------------------------------------------------
// Ocultar Item/Itens
function esconder(){
document.getElementById('central').style.display='block';
}

// Ocultar Vários Objetos
function semana(seg,ter,qua,qui,sex,sab,dom){

	if(seg=="1"){
	document.getElementById('tb_programa1').style.display='block';
	document.getElementById('tb_programa2').style.display='none';
	document.getElementById('tb_programa3').style.display='none';
	document.getElementById('tb_programa4').style.display='none';
	document.getElementById('tb_programa5').style.display='none';
	document.getElementById('tb_programa6').style.display='none';
	document.getElementById('tb_programa7').style.display='none';
	}
	if(ter=="1"){
	document.getElementById('tb_programa1').style.display='none';
	document.getElementById('tb_programa2').style.display='block';
	document.getElementById('tb_programa3').style.display='none';
	document.getElementById('tb_programa4').style.display='none';
	document.getElementById('tb_programa5').style.display='none';
	document.getElementById('tb_programa6').style.display='none';
	document.getElementById('tb_programa7').style.display='none';
	}
	if(qua=="1"){
	document.getElementById('tb_programa1').style.display='none';
	document.getElementById('tb_programa2').style.display='none';
	document.getElementById('tb_programa3').style.display='block';
	document.getElementById('tb_programa4').style.display='none';
	document.getElementById('tb_programa5').style.display='none';
	document.getElementById('tb_programa6').style.display='none';
	document.getElementById('tb_programa7').style.display='none';
	}
	if(qui=="1"){
	document.getElementById('tb_programa1').style.display='none';
	document.getElementById('tb_programa2').style.display='none';
	document.getElementById('tb_programa3').style.display='none';
	document.getElementById('tb_programa4').style.display='block';
	document.getElementById('tb_programa5').style.display='none';
	document.getElementById('tb_programa6').style.display='none';
	document.getElementById('tb_programa7').style.display='none';
	}
	if(sex=="1"){
	document.getElementById('tb_programa1').style.display='none';
	document.getElementById('tb_programa2').style.display='none';
	document.getElementById('tb_programa3').style.display='none';
	document.getElementById('tb_programa4').style.display='none';
	document.getElementById('tb_programa5').style.display='block';
	document.getElementById('tb_programa6').style.display='none';
	document.getElementById('tb_programa7').style.display='none';
	}
	if(sab=="1"){
	document.getElementById('tb_programa1').style.display='none';
	document.getElementById('tb_programa2').style.display='none';
	document.getElementById('tb_programa3').style.display='none';
	document.getElementById('tb_programa4').style.display='none';
	document.getElementById('tb_programa5').style.display='none';
	document.getElementById('tb_programa6').style.display='block';
	document.getElementById('tb_programa7').style.display='none';
	}
	if(dom=="1"){
	document.getElementById('tb_programa1').style.display='none';
	document.getElementById('tb_programa2').style.display='none';
	document.getElementById('tb_programa3').style.display='none';
	document.getElementById('tb_programa4').style.display='none';
	document.getElementById('tb_programa5').style.display='none';
	document.getElementById('tb_programa6').style.display='none';
	document.getElementById('tb_programa7').style.display='block';
	}

}
//semana();
	document.getElementById('tb_programa1').style.display='block';
	document.getElementById('tb_programa2').style.display='none';
	document.getElementById('tb_programa3').style.display='none';
	document.getElementById('tb_programa4').style.display='none';
	document.getElementById('tb_programa5').style.display='none';
	document.getElementById('tb_programa6').style.display='none';
	document.getElementById('tb_programa7').style.display='none';

// Fim Ocultar Item/Itens
// -------------------------------------------------------------------------------------------------------------





// -------------------------------------------------------------------------------------------------------------
// Alterar Cor de Fundo
	function AlterarCor(bg,fg){
		document.bgColor=bg;  // esse funciona no firefox
		document.fgColor=fg;
		//document.getElementsById('central').style.background = bg;
		//document.getElementsByTagName('body').item(0).style.background = ''+bg+' url(_img/ucrz_fundo_body.png) repeat-x;';
		//document.getElementsById('body1').style.background = ''+bg+' url(_img/ucrz_fundo_body.png) repeat-x;';
	}
// uso: <a href="#" onClick="AlterarCor('#FF0000','#FFFF00');">cor</a>
// Fim Alterar Cor de Fundo
// Função de Teste
/*
	function bg(){
		//document.getElementById("body1").style.background = 'url(portfolio/sites/home/2008-kuriuwa-hotel.jpg) no-repeat left top';
		//document.getElementByTagName("topo").style.background = 'url(portfolio/sites/home/2008-kuriuwa-hotel.jpg) no-repeat left top';
		document.getElementsByTagName('body').item(0).style.background = '#114f73 url(_img/ucrz_fundo_body.png) repeat-x;';
	}
*/
// Fim Função de Teste
// -------------------------------------------------------------------------------------------------------------





// -------------------------------------------------------------------------------------------------------------
// Acessórios do site
function acessoriosTopo(){
var btVoltar = "<a href='javascript:window.history.back();' title='voltar'>voltar</a>";
var btImprimir = "<a href='javascript:window.print();' title='imprimir'>imprimir</a>";
var btMais = "<a class='mais' href='javascript:mudaTamanho(\"texto\", 1);' title='aumentar'>A+</a>";
var btMenos = "<a class='menos' href='javascript:mudaTamanho(\"texto\", -1);' title='diminuir'>A-</a>";

document.write("<div id='acessoriosTopo'>");
document.write(" . " + btVoltar + " . " + btImprimir + " . " + btMais + " . " + btMenos + " . ");
document.write("</div>");
}

function acessoriosRodape(){
var btTopo = "<a href='#topo' title='topo da página'>topo</a>";

document.write("<div id='acessoriosRodape'>");
document.write(" . " + btTopo + " . ");
document.write("</div>");
}
// Fim Acessórios do site
// -------------------------------------------------------------------------------------------------------------










// -------------------------------------------------------------------------------------------------------------
// mostra hora
function dataHora(){

var now = new Date(); 
var hours = now.getHours(); 
var minutes = now.getMinutes(); 
var timeValue = "" + ((hours >12) ? hours -12 :hours) 
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += (hours >= 12) ? " PM" : " AM" 
timerRunning = true; 

mydate = new Date(); 
myday = mydate.getDay(); 
mymonth = mydate.getMonth(); 
myweekday= mydate.getDate(); 
weekday= myweekday; 
myyear= mydate.getYear(); 
year = myyear;

if(myday == 0) 
day = "Domingo" 

else if(myday == 1) 
day = "Segunda" 

else if(myday == 2) 
day = "Ter&ccedil;a"

else if(myday == 3) 
day = "Quarta" 

else if(myday == 4) 
day = "Quinta" 

else if(myday == 5) 
day = "Sexta" 

else if(myday == 6) 
day = "S&aacute;bado" 

if(mymonth == 0) 
month = "03" 

else if(mymonth ==1) 
month = "02" 

else if(mymonth ==2) 
month = "03" 

else if(mymonth ==3) 
month = "04" 

else if(mymonth ==4) 
month = "05"

else if(mymonth ==5) 
month = "06" 

else if(mymonth ==6) 
month = "07" 

else if(mymonth ==7) 
month = "08" 

else if(mymonth ==8) 
month = "09" 

else if(mymonth ==9) 
month = "10" 

else if(mymonth ==10) 
month = "11" 

else if(mymonth ==11) 
month = "12" 


//document.write( day + myweekday + month + year + " - " + timeValue); 
document.write( day + ", " + myweekday + "/" + month + "/" + year + " - ");


}


// motrar data
function mueveReloj(){
	momentoActual = new Date()
	hora = momentoActual.getHours()
	minuto = momentoActual.getMinutes()
	segundo = momentoActual.getSeconds()
	
	str_segundo = new String (segundo)
	if (str_segundo.length == 1) 
		segundo = "0" + segundo
		
	str_minuto = new String (minuto)
	if (str_minuto.length == 1) 
		minuto = "0" + minuto

	str_hora = new String (hora)
	if (str_hora.length == 1) 
		hora = "0" + hora
		
	horaImprimible = hora + ":" + minuto + ":" + segundo + " . ";
	
	//document.form_reloj.reloj.value = horaImprimible
	//document.form_reloj2.reloj2.value = horaImprimible
	
	document.getElementById('motrarHora').innerHTML=horaImprimible;
	
	setTimeout("mueveReloj()",1000)

}
// fim mostrar hora
// -------------------------------------------------------------------------------------------------------------
