

function mudaData(x,data){
	//Seleciona Data
	
	
	lista = x.parentNode.className;
	lista_node = x.parentNode;
	lista_item = data;
	//lista_item = lista_item.substring(lista_item.length-1,lista_item.length)
	classe = lista.substring(0,lista.length-1) + lista_item;
	x.parentNode.className = classe;
	
	for(a=0; a<lista_node.getElementsByTagName('li').length; a++){
		lista_node.getElementsByTagName('li')[a].className = '';
		if (lista_node.getElementsByTagName('li')[a] == x){
			lista_node.getElementsByTagName('li')[a].className = 'ativo';
			x = a;
		}
		
	}
	
	for(b=0; b<lista_node.parentNode.getElementsByTagName('blockquote').length; b++){
		if ( lista_node.parentNode.getElementsByTagName('blockquote')[b].className.indexOf('areAba')==0 ){
			lista_node.parentNode.getElementsByTagName('blockquote')[b].className = 'areAba';
		}
	}
	lista_node.parentNode.getElementsByTagName('blockquote')[x].className = 'areAba ativo';	
}	
	
	//Seleciona Notícias
/*	nota_lista = x.parentNode.parentNode.getElementsByTagName('ul')[1];
	nota_itens = nota_lista.getElementsByTagName('li').length;
	nota_pos = nota_itens*lista_item;
	for (i=0; nota_lista.getElementsByTagName('li').length>i; i++){
		if( ( (i>=nota_pos-nota_itens) ) && (i<nota_pos) )
			nota_lista.getElementsByTagName('li')[i].className='ativo';
		else
			nota_lista.getElementsByTagName('li')[i].className='';
	}
}*/

function mudaDestaque(x){
	area = x.parentNode.parentNode;
	num = x.innerHTML - 1;
	for (u=0; area.getElementsByTagName('ul').length>u; u++){
		for (i=0; area.getElementsByTagName('ul')[u].getElementsByTagName('li').length>i; i++){
			if (i == num)
				area.getElementsByTagName('ul')[u].getElementsByTagName('li')[i].className='ativo';
			else
				area.getElementsByTagName('ul')[u].getElementsByTagName('li')[i].className='';
		}
	}
}



function mudaImagens(x,y){
	imgPorPag = 4;
	area = x.parentNode;
	lista = area.parentNode.getElementsByTagName('ul')[0];
	listaItem = lista.getElementsByTagName('li');
	seta = area.getElementsByTagName('span');
	
	for(c=0; c<listaItem.length; c=c+imgPorPag){
		if(listaItem[c].className == 'ativo'){
			liAtivo = c;
			break;
		}
	}
	
	//proximo
	if (y == 'p'){
		if ( (liAtivo+imgPorPag) < listaItem.length ){
			for(num=liAtivo; num<(liAtivo+imgPorPag); num++){
				listaItem[num].className = '';
				if(listaItem[num+imgPorPag]) listaItem[num+imgPorPag].className = 'ativo';
			}
			if ( seta[0].className.indexOf(' off')>0 ) seta[0].className = seta[0].className.substring(0, seta[0].className.indexOf(' off'));
		}
		else{
			x.className = x.className+' off';
		}
	}
	
	//anterior
	if (y == 'a'){
		if ( liAtivo > 0 ){
			for(num=liAtivo; num<(liAtivo+imgPorPag); num++){
				if(listaItem[num]) listaItem[num].className = '';
				listaItem[num-imgPorPag].className = 'ativo';
			}
			if ( seta[1].className.indexOf(' off')>0 ) seta[1].className = seta[1].className.substring(0, seta[1].className.indexOf(' off'));
		}
		else{
			x.className = x.className+' off';
		}
	}
	
}



function limpaCampo(campo){	
	if(campo.value == campo.title)
		campo.value = '';
	campo.className = 'text valido';
}
function checaCampo(campo){	
	while(campo.value.indexOf(' ') == 0){
		campo.value = campo.value.substring(1, campo.value.length);
	}
	if((campo.value == '') || (campo.value.toLowerCase() == campo.title.toLowerCase())){
		campo.value = campo.title;
		campo.className = tiraString(campo.className,'valido');
	}
}
function tiraString(campo,string){
	string = ' '+string;
	if (campo.indexOf(string)>0){
		campo = campo.substring(0, campo.indexOf(string));
	}
	return campo;
}



function abrePopup(){
	document.getElementById('siteSombra').style.height= document.body.clientHeight+'px';
	document.getElementById('siteSombra').style.display = 'block';
	document.getElementById('sitePopup').style.display = 'block';
}
function fechaPopup(botao){
	form = botao.parentNode.getElementsByTagName('form')[0];
	form.reset();
	for(e=0;e<form.elements.length;e++){
		form.elements[e].className = tiraString(form.elements[e].className,'valido');
	}
	document.getElementById('siteSombra').style.display = '';
	document.getElementById('sitePopup').style.display = '';
}
